abstracted keystore loader to new function
parent
3dfe6df410
commit
985a4619fa
|
@ -87,20 +87,11 @@ public class RsaSigner extends AbstractJwtSigner implements InitializingBean {
|
||||||
public RsaSigner(String algorithmName, KeyStore keystore, String alias, String password) throws GeneralSecurityException {
|
public RsaSigner(String algorithmName, KeyStore keystore, String alias, String password) throws GeneralSecurityException {
|
||||||
super(algorithmName);
|
super(algorithmName);
|
||||||
|
|
||||||
Assert.notNull(keystore, "An keystore must be supplied");
|
|
||||||
Assert.notNull(alias, "A alias must be supplied");
|
|
||||||
Assert.notNull(password, "A password must be supplied");
|
|
||||||
|
|
||||||
setKeystore(keystore);
|
setKeystore(keystore);
|
||||||
setAlias(alias);
|
setAlias(alias);
|
||||||
setPassword(password);
|
setPassword(password);
|
||||||
|
|
||||||
KeyPair keyPair = keystore.getKeyPairForAlias(alias, password);
|
loadKeysFromKeystore();
|
||||||
|
|
||||||
Assert.notNull(keyPair, "Either alias and/or password is not correct for keystore");
|
|
||||||
|
|
||||||
publicKey = keyPair.getPublic();
|
|
||||||
privateKey = keyPair.getPrivate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,10 +127,29 @@ public class RsaSigner extends AbstractJwtSigner implements InitializingBean {
|
||||||
// unsupported algorithm will throw a NoSuchAlgorithmException
|
// unsupported algorithm will throw a NoSuchAlgorithmException
|
||||||
signer = Signature.getInstance(JwsAlgorithm.getByName(super.getAlgorithm()).getStandardName()); // ,PROVIDER);
|
signer = Signature.getInstance(JwsAlgorithm.getByName(super.getAlgorithm()).getStandardName()); // ,PROVIDER);
|
||||||
|
|
||||||
|
loadKeysFromKeystore();
|
||||||
|
|
||||||
logger.debug(JwsAlgorithm.getByName(getAlgorithm()).getStandardName() + " RSA Signer ready for business");
|
logger.debug(JwsAlgorithm.getByName(getAlgorithm()).getStandardName() + " RSA Signer ready for business");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the public and private keys from the keystore, identified with the configured alias and accessed with the configured password.
|
||||||
|
* @throws GeneralSecurityException
|
||||||
|
*/
|
||||||
|
private void loadKeysFromKeystore() throws GeneralSecurityException {
|
||||||
|
Assert.notNull(keystore, "An keystore must be supplied");
|
||||||
|
Assert.notNull(alias, "A alias must be supplied");
|
||||||
|
Assert.notNull(password, "A password must be supplied");
|
||||||
|
|
||||||
|
KeyPair keyPair = keystore.getKeyPairForAlias(alias, password);
|
||||||
|
|
||||||
|
Assert.notNull(keyPair, "Either alias and/or password is not correct for keystore");
|
||||||
|
|
||||||
|
publicKey = keyPair.getPublic();
|
||||||
|
privateKey = keyPair.getPrivate();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue