Search in sources :

Example 76 with SessionID

use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.

the class SSOProviderImpl method createSSOToken.

/**
     * Creates a single sign on token.
     *
     * @param tokenId  single sign on token ID.
     * @param clientIP client IP address
     * @return single sign on token.
     * @throws SSOException                  if the single sign on token cannot be created.
     * @throws UnsupportedOperationException Thrown to indicate that the
     *                                       requested operation is not supported.
     * @deprecated Use #createSSOToken(String, String)
     */
public SSOToken createSSOToken(String tokenId, String clientIP) throws SSOException, UnsupportedOperationException {
    try {
        SessionID sessionId = new SessionID(tokenId);
        Session session = sessionCache.getSession(sessionId);
        if (checkIP && !isIPValid(session, clientIP)) {
            throw new Exception(SSOProviderBundle.getString("invalidIP"));
        }
        SSOToken ssoToken = new SSOTokenImpl(session);
        return ssoToken;
    } catch (Exception e) {
        if (debug.messageEnabled()) {
            debug.message("could not create SSOToken for token ID \"" + tokenId + "\" (" + e.getMessage() + ")");
        }
        throw new SSOException(e);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) SSOException(com.iplanet.sso.SSOException) SessionID(com.iplanet.dpro.session.SessionID) SSOException(com.iplanet.sso.SSOException) SessionException(com.iplanet.dpro.session.SessionException) Session(com.iplanet.dpro.session.Session)

Example 77 with SessionID

use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.

the class AuthContext method logoutUsingTokenID.

/**
     * Logs out the user and also invalidates the single sign on token
     * associated with this <code>AuthContext</code>.
	 *
	 * This method causes the logout to happen on the server and the 
	 * correct SPI hooks to be called.
     *
     * @throws AuthLoginException if an error occurred during logout.
     *
     * @supported.api
     */
public void logoutUsingTokenID() throws AuthLoginException {
    if (localFlag) {
        return;
    }
    if (ssoToken != null) {
        try {
            organizationName = ssoToken.getProperty(ISAuthConstants.ORGANIZATION);
            ssoTokenID = ssoToken.getTokenID().toString();
            authURL = sessionCache.getSession(new SessionID(ssoTokenID)).getSessionServiceURL();
        } catch (Exception e) {
            throw new AuthLoginException(e);
        }
    }
    if (authURL != null) {
        authServiceURL = getAuthServiceURL(authURL.getProtocol(), authURL.getHost(), Integer.toString(authURL.getPort()), authURL.getPath());
    }
    // Construct the XML
    try {
        StringBuilder xml = new StringBuilder(100);
        String[] authHandles = new String[1];
        authHandles[0] = ssoToken.getTokenID().toString();
        xml.append(MessageFormat.format(AuthXMLTags.XML_REQUEST_PREFIX, (Object[]) authHandles));
        if (appSSOToken != null) {
            xml.append(AuthXMLTags.APPSSOTOKEN_BEGIN);
            xml.append(appSSOToken.getTokenID().toString()).append(AuthXMLTags.APPSSOTOKEN_END);
        }
        xml.append(AuthXMLTags.LOGOUT_BEGIN).append(AuthXMLTags.LOGOUT_END).append(AuthXMLTags.XML_REQUEST_SUFFIX);
        // Send the request to be processes
        receivedDocument = processRequest(xml.toString());
        // Check set the login status
        checkAndSetLoginStatus();
    } catch (AuthLoginException le) {
        // Login has failed
        loginStatus = Status.FAILED;
        loginException = le;
    }
}
Also used : AuthLoginException(com.sun.identity.authentication.spi.AuthLoginException) SessionID(com.iplanet.dpro.session.SessionID) AuthLoginException(com.sun.identity.authentication.spi.AuthLoginException) SSOException(com.iplanet.sso.SSOException) AMSecurityPropertiesException(com.sun.identity.security.AMSecurityPropertiesException) IOException(java.io.IOException) AuthException(com.sun.identity.authentication.service.AuthException)

Example 78 with SessionID

use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.

the class AuthUtils method getLogoutCookie.

/**
     * Returns the Logout cookie.
     *
     * @param ac the AuthContextLocal object
     * @param cookieDomain the cookieDomain
     * @return Logout cookie .
     */
public static Cookie getLogoutCookie(AuthContextLocal ac, String cookieDomain) {
    LoginState loginState = getLoginState(ac);
    SessionID sid = loginState.getSid();
    String logoutCookieString = getLogoutCookieString(sid);
    Cookie logoutCookie = createCookie(logoutCookieString, cookieDomain);
    logoutCookie.setMaxAge(0);
    return logoutCookie;
}
Also used : Cookie(javax.servlet.http.Cookie) SessionID(com.iplanet.dpro.session.SessionID)

Example 79 with SessionID

use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.

the class SessionCount method decrementSessionCount.

/**
     * Decrements the session count
     * @param is the <code>InternalSession</code> for the user
     *
     */
static void decrementSessionCount(InternalSession is) {
    String uuid = is.getUUID();
    if (!caseSensitiveUUID && uuid != null) {
        uuid = uuid.toLowerCase();
    }
    SessionID sid = is.getID();
    if ((deploymentMode == SINGLE_SERVER_MODE) || (deploymentMode == MULTI_SERVER_MODE && useLocalSessionsInMultiServerMode())) {
        Set sessions = (Set) uuidSessionMap.get(uuid);
        if (sessions != null) {
            sessions.remove(sid);
            if (sessions.isEmpty()) {
                uuidSessionMap.remove(uuid);
            }
        }
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) SessionID(com.iplanet.dpro.session.SessionID)

Example 80 with SessionID

use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.

the class InternalSession method addRestrictedToken.

/**
     * Add new restricted token pointing at the same session to the list.
     *
     * @param sid The session ID.
     * @param restriction The token restriction.
     * @return The existing session ID instance if this TokenRestriction was already mapped to a session ID,
     * <code>null</code> otherwise.
     */
SessionID addRestrictedToken(SessionID sid, TokenRestriction restriction) {
    SessionID previousValue = restrictedTokensByRestriction.putIfAbsent(restriction, sid);
    if (previousValue == null) {
        restrictedTokensBySid.put(sid, restriction);
        updateForFailover();
        return null;
    }
    return previousValue;
}
Also used : SessionID(com.iplanet.dpro.session.SessionID)

Aggregations

SessionID (com.iplanet.dpro.session.SessionID)105 Test (org.testng.annotations.Test)44 SessionException (com.iplanet.dpro.session.SessionException)31 SSOToken (com.iplanet.sso.SSOToken)23 InternalSession (com.iplanet.dpro.session.service.InternalSession)18 SSOException (com.iplanet.sso.SSOException)18 AuthContextLocalWrapper (org.forgerock.openam.core.rest.authn.core.wrappers.AuthContextLocalWrapper)17 HttpServletResponse (javax.servlet.http.HttpServletResponse)16 HttpServletRequest (javax.servlet.http.HttpServletRequest)15 Session (com.iplanet.dpro.session.Session)14 URL (java.net.URL)9 Map (java.util.Map)9 AuthLoginException (com.sun.identity.authentication.spi.AuthLoginException)8 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 SMSException (com.sun.identity.sm.SMSException)4 Token (org.forgerock.openam.cts.api.tokens.Token)4 SessionIDExtensions (com.iplanet.dpro.session.SessionIDExtensions)3 TokenRestriction (com.iplanet.dpro.session.TokenRestriction)3 SessionInfo (com.iplanet.dpro.session.share.SessionInfo)3