Search in sources :

Example 26 with SSOTokenManager

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;
}
Also used : SSOTokenManager(com.iplanet.sso.SSOTokenManager) AuthContext(com.sun.identity.authentication.AuthContext) SSOException(com.iplanet.sso.SSOException) AuthContext(com.sun.identity.authentication.AuthContext) HashMap(java.util.HashMap) Map(java.util.Map) Date(java.util.Date)

Example 27 with SSOTokenManager

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();
    }
}
Also used : SSOTokenManager(com.iplanet.sso.SSOTokenManager) ForbiddenException(org.forgerock.json.resource.ForbiddenException) SSOToken(com.iplanet.sso.SSOToken) JsonValue(org.forgerock.json.JsonValue) SSOException(com.iplanet.sso.SSOException)

Example 28 with SSOTokenManager

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);
    }
}
Also used : SSOTokenManager(com.iplanet.sso.SSOTokenManager) SSOToken(com.iplanet.sso.SSOToken) SSOException(com.iplanet.sso.SSOException)

Example 29 with SSOTokenManager

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);
    }
}
Also used : SSOTokenManager(com.iplanet.sso.SSOTokenManager) SSOToken(com.iplanet.sso.SSOToken) Iterator(java.util.Iterator) SSOException(com.iplanet.sso.SSOException)

Example 30 with SSOTokenManager

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);
        }
    }
}
Also used : SSOTokenManager(com.iplanet.sso.SSOTokenManager) SSOException(com.iplanet.sso.SSOException)

Aggregations

SSOTokenManager (com.iplanet.sso.SSOTokenManager)53 SSOToken (com.iplanet.sso.SSOToken)48 SSOException (com.iplanet.sso.SSOException)39 IdRepoException (com.sun.identity.idm.IdRepoException)11 AMIdentity (com.sun.identity.idm.AMIdentity)9 AuthLoginException (com.sun.identity.authentication.spi.AuthLoginException)8 IOException (java.io.IOException)7 Map (java.util.Map)6 Set (java.util.Set)6 ForbiddenException (org.forgerock.json.resource.ForbiddenException)6 SessionException (com.iplanet.dpro.session.SessionException)5 InternalSession (com.iplanet.dpro.session.service.InternalSession)5 AuthPrincipal (com.sun.identity.authentication.internal.AuthPrincipal)5 AuthException (com.sun.identity.authentication.service.AuthException)5 Iterator (java.util.Iterator)5 AuthContext (com.sun.identity.authentication.AuthContext)4 SMSException (com.sun.identity.sm.SMSException)4 Response (com.iplanet.services.comm.share.Response)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 HashMap (java.util.HashMap)3