use of com.sun.identity.security.AMSecurityPropertiesException in project OpenAM by OpenRock.
the class AuthContext method getAppSSOToken.
/**
* Returns the application sso token. Can perform a check to ensure that
* the app token is still valid (requires a session refresh call to OpenAM)
*
* @param refresh true if we should check with OpenAM if the app token is valid
* @return a valid application's sso token.
*/
private SSOToken getAppSSOToken(boolean refresh) {
SSOToken appToken = null;
try {
appToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
} catch (AMSecurityPropertiesException aspe) {
if (authDebug.messageEnabled()) {
authDebug.message("AuthContext::getAppSSOToken: " + "unable to get app ssotoken " + aspe.getMessage());
}
}
if (refresh) {
// ensure the token is valid
try {
SSOTokenManager ssoTokenManager = SSOTokenManager.getInstance();
ssoTokenManager.refreshSession(appToken);
if (!ssoTokenManager.isValidToken(appToken)) {
if (authDebug.messageEnabled()) {
authDebug.message("AuthContext.getAppSSOToken(): " + "App SSOToken is invalid, retrying");
}
try {
appToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
} catch (AMSecurityPropertiesException aspe) {
if (authDebug.messageEnabled()) {
authDebug.message("AuthContext::getAppSSOToken: " + "unable to get app ssotoken " + aspe.getMessage());
}
}
}
} catch (SSOException ssoe) {
if (authDebug.messageEnabled()) {
authDebug.message("AuthContext.getAppSSOToken(): " + "unable to refresh app token: " + ssoe.getL10NMessage());
}
try {
appToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
} catch (AMSecurityPropertiesException aspe) {
if (authDebug.errorEnabled()) {
authDebug.error("AuthContext::getAppSSOToken: " + "unable to get app ssotoken " + aspe.getMessage());
}
}
}
}
if (authDebug.messageEnabled()) {
if (appToken == null) {
authDebug.message("Null App SSO Token");
} else {
authDebug.message("Obtained App Token= " + appToken.getTokenID().toString());
}
}
return appToken;
}
Aggregations