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);
}
}
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;
}
}
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;
}
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);
}
}
}
}
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;
}
Aggregations