use of org.forgerock.openam.sts.STSInitializationException in project OpenAM by OpenRock.
the class SoapSTSAgentCredentialsAccessImpl method decryptAgentPassword.
private String decryptAgentPassword(String encryptedAgentPassword, KeyStore soapSTSInternalKeystore) throws STSInitializationException {
try {
KeyStore.SecretKeyEntry entry = (KeyStore.SecretKeyEntry) soapSTSInternalKeystore.getEntry(SharedSTSConstants.AM_INTERNAL_PEK_ALIAS, new KeyStore.PasswordProtection(SharedSTSConstants.AM_INTERNAL_SOAP_STS_KEYSTORE_PW.toCharArray()));
JCEEncryption jceEncryption = new JCEEncryption();
final byte[] decodedPassword = Base64.decode(encryptedAgentPassword);
try {
jceEncryption.setPassword(new String(entry.getSecretKey().getEncoded(), StandardCharsets.UTF_8));
final byte[] decryptedPassword = jceEncryption.decrypt(decodedPassword);
return new String(decryptedPassword, StandardCharsets.UTF_8);
} catch (Exception e) {
throw new STSInitializationException(ResourceException.INTERNAL_ERROR, e.getMessage(), e);
}
} catch (NoSuchAlgorithmException | UnrecoverableEntryException | KeyStoreException e) {
throw new STSInitializationException(ResourceException.INTERNAL_ERROR, e.getMessage(), e);
}
}
use of org.forgerock.openam.sts.STSInitializationException in project OpenAM by OpenRock.
the class TokenRenewOperationProvider method get.
public RenewOperation get() {
// TODO: migrate to ThrowingProviders
try {
TokenRenewOperation tokenRenewOperation = new TokenRenewOperation();
tokenRenewOperation.setStsProperties(stsPropertiesMBean);
tokenRenewOperation.setTokenStore(tokenStore);
tokenRenewOperation.setTokenValidators(getTokenValidators());
tokenRenewOperation.setTokenRenewers(getTokenRenewers());
return new TokenRenewOperationWrapper(tokenRenewOperation, threadLocalAMTokenCache);
} catch (STSInitializationException e) {
logger.error("Exception caught initializing a RenewOperation: " + e, e);
throw new RuntimeException(e);
}
}
use of org.forgerock.openam.sts.STSInitializationException in project OpenAM by OpenRock.
the class TokenValidateOperationProvider method getFunctionalValidateOperation.
private ValidateOperation getFunctionalValidateOperation() {
TokenValidateOperation tokenValidateOperation = new TokenValidateOperation();
tokenValidateOperation.setStsProperties(stsPropertiesMBean);
tokenValidateOperation.setTokenStore(tokenStore);
try {
List<TokenValidator> tokenValidators = new ArrayList<>();
for (TokenType tokentype : validatedTokens) {
tokenValidators.add(operationFactory.getSimpleTokenValidator(tokentype));
}
tokenValidateOperation.setTokenValidators(tokenValidators);
} catch (STSInitializationException e) {
throw new RuntimeException(e);
}
return new TokenValidateOperationWrapper(tokenValidateOperation, threadLocalAMTokenCache);
}
use of org.forgerock.openam.sts.STSInitializationException in project OpenAM by OpenRock.
the class TokenIssueOperationProvider method get.
public IssueOperation get() {
//TODO: migrate to throwing providers
try {
TokenIssueOperation tokenIssueOperation = new TokenIssueOperation();
/*
The STS will not encrypt the issued tokens - the TokenGenerationService already offers functionality to
encrypt issued SAML assertions.
*/
tokenIssueOperation.setEncryptIssuedToken(false);
tokenIssueOperation.setStsProperties(stsPropertiesMBean);
tokenIssueOperation.setTokenStore(tokenStore);
/*
Set the tokenValidators which will be called to validate the tokens presented as ActAs or OnBehalfOf
elements
*/
tokenIssueOperation.setTokenValidators(getDelegationTokenValidators());
/*
Set the TokenDelegationHandlers (either empty if this sts instance will not process ActAs or OnBehalfOf elements,
or with the DefaultTokenDelegationHandler, or with user-specified custom handlers.
*/
tokenIssueOperation.setDelegationHandlers(tokenDelegationHandlers);
List<TokenProvider> tokenProviders = new ArrayList<TokenProvider>();
for (TokenType tokenType : issueTokenTypes) {
tokenProviders.add(operationFactory.getTokenProvider(tokenType));
}
tokenIssueOperation.setTokenProviders(tokenProviders);
return new TokenIssueOperationWrapper(tokenIssueOperation, threadLocalAMTokenCache);
} catch (STSInitializationException e) {
logger.error("Exception caught initializing a IssueOperation: " + e, e);
throw new RuntimeException(e);
}
}
use of org.forgerock.openam.sts.STSInitializationException in project OpenAM by OpenRock.
the class TokenCancelOperationProvider method getFunctionalCancelOperation.
private CancelOperation getFunctionalCancelOperation() {
TokenCancelOperation tokenCancelOperation = new TokenCancelOperation();
tokenCancelOperation.setStsProperties(stsPropertiesMBean);
tokenCancelOperation.setTokenStore(tokenStore);
try {
List<TokenCanceller> tokenCancellers = new ArrayList<>();
for (TokenType tokentype : validatedTokens) {
tokenCancellers.add(operationFactory.getTokenCanceller(tokentype));
}
tokenCancelOperation.setTokenCancellers(tokenCancellers);
} catch (STSInitializationException e) {
throw new RuntimeException(e);
}
return new TokenCancelOperationWrapper(tokenCancelOperation, threadLocalAMTokenCache);
}
Aggregations