use of com.iplanet.sso.SSOTokenManager in project OpenAM by OpenRock.
the class AMAuthUtils method getAuthInstant.
/**
* Returns time at which the particular authentication occured
* @param ssoToken valid user <code>SSOToken</code>
* @param authType valid Authentication Type.
* @param authValue valid Authentication value.
* @return long value of authentication time.
*/
public static long getAuthInstant(SSOToken ssoToken, String authType, String authValue) {
// Refreshing the SSOToken
try {
SSOTokenManager manager = SSOTokenManager.getInstance();
manager.refreshSession(ssoToken);
} catch (SSOException ssoExp) {
utilDebug.warning("AMAuthUtils.getAuthInstant : Cannot refresh " + "the SSO Token");
}
long retTime = 0;
AuthContext.IndexType indexType = AuthUtils.getIndexType(authType);
if (indexType == AuthContext.IndexType.MODULE_INSTANCE) {
Map moduleTimeMap = getModuleAuthTimeMap(ssoToken);
String strDate = (String) moduleTimeMap.get(authValue);
if (utilDebug.messageEnabled()) {
utilDebug.message("AMAuthUtils.getAuthInstant : " + "date from getAuthInstant = " + strDate);
}
if ((strDate != null) && (strDate.length() != 0)) {
Date dt = null;
try {
dt = DateUtils.stringToDate(strDate);
} catch (java.text.ParseException parseExp) {
utilDebug.message("AMAuthUtils.getAuthInstant : " + "Cannot parse Date");
}
if (dt != null) {
retTime = dt.getTime();
}
}
}
return retTime;
}
use of com.iplanet.sso.SSOTokenManager in project OpenAM by OpenRock.
the class IdentityResourceV2 method validateGoto.
/**
* Validates the current goto against the list of allowed gotos, and returns either the allowed
* goto as sent in, or the server's default goto value.
*
* @param context Current Server Context
* @param request Request from client to confirm registration
*/
/* package private for access by UserIdentityResourceV3
*/
Promise<ActionResponse, ResourceException> validateGoto(final Context context, final ActionRequest request) {
final JsonValue jVal = request.getContent();
JsonValue result = new JsonValue(new LinkedHashMap<String, Object>(1));
try {
SSOTokenManager mgr = SSOTokenManager.getInstance();
SSOToken ssoToken = mgr.createSSOToken(getCookieFromServerContext(context));
String gotoURL = URL_VALIDATOR.getRedirectUrl(ssoToken.getProperty(ISAuthConstants.ORGANIZATION), URL_VALIDATOR.getValueFromJson(jVal, RedirectUrlValidator.GOTO), ssoToken.getProperty("successURL"));
result.put("successURL", gotoURL);
return newResultPromise(newActionResponse(result));
} catch (SSOException ssoe) {
if (debug.errorEnabled()) {
debug.error("IdentityResource.validateGoto() :: Invalid SSOToken.", ssoe);
}
return new ForbiddenException(ssoe.getMessage(), ssoe).asPromise();
}
}
use of com.iplanet.sso.SSOTokenManager in project OpenAM by OpenRock.
the class LoginState method getSSOToken.
/**
* Returns the single sign on token associated with the session.
*
* @return the single sign on token associated with the session.
* @throws SSOException
*/
public SSOToken getSSOToken() throws SSOException {
if (!stateless && (session == null || session.getState() == INACTIVE)) {
return null;
}
try {
SSOTokenManager ssoManager = SSOTokenManager.getInstance();
SSOToken ssoToken = ssoManager.createSSOToken(sid.toString());
return ssoToken;
} catch (SSOException ex) {
DEBUG.message("Error retrieving SSOToken :", ex);
throw new SSOException(AuthD.BUNDLE_NAME, AMAuthErrorCode.AUTH_ERROR, null);
}
}
use of com.iplanet.sso.SSOTokenManager in project OpenAM by OpenRock.
the class CommandManager method destroySSOTokens.
private void destroySSOTokens() {
try {
SSOTokenManager mgr = SSOTokenManager.getInstance();
for (Iterator i = ssoTokens.iterator(); i.hasNext(); ) {
SSOToken token = (SSOToken) i.next();
mgr.destroyToken(token);
}
if (!importSvcCmd) {
Logger.token.set(null);
}
} catch (SSOException e) {
Debugger.error(this, "CommandManager.destroySSOTokens", e);
}
}
use of com.iplanet.sso.SSOTokenManager in project OpenAM by OpenRock.
the class AuthenticatedCommand method ldapLogin.
protected void ldapLogin() throws CLIException {
if (ssoToken == null) {
Authenticator auth = Authenticator.getInstance();
String bindUser = getAdminID();
ssoToken = auth.ldapLogin(getCommandManager(), bindUser, getAdminPassword());
} else {
try {
SSOTokenManager mgr = SSOTokenManager.getInstance();
mgr.validateToken(ssoToken);
} catch (SSOException e) {
throw new CLIException(e, ExitCodes.SESSION_EXPIRED);
}
}
}
Aggregations