LocalOperations.java revision c184142912cff04e5442d8bf70febe477285fb1c
/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2014-2016 ForgeRock AS.
*/
/**
* Responsible for applying Session operations on the local Server instance.
*
* This will be based on invoking the {@link SessionService} directly. This implementation
* has been refactored out from {@link Session}.
*/
public class LocalOperations implements SessionOperations {
private final SessionAccessManager sessionAccessManager;
private final SessionInfoFactory sessionInfoFactory;
private final SessionServerConfig serverConfig;
private final SessionNotificationSender sessionNotificationSender;
private final SessionLogging sessionLogging;
private final SessionAuditor sessionAuditor;
private final SessionChangeAuthorizer sessionChangeAuthorizer;
/**
* Guice initialised constructor.
* @param debug Non null.
* @param sessionAccessManager access manager for returning the session information from the storage mechanism
* @param sessionInfoFactory the factory for creating session information objects from a session
* @param serverConfig session server config
* @param sessionNotificationSender notification sender for session removal notification
* @param sessionLogging special logging service for session removal logging
* @param sessionAuditor audit logger
* @param sessionChangeAuthorizer class for verifying permissions and authorisation for the current user to
* perform tasks on the session. Used during deleting a session and getting access
* to session info.
*
*/
final SessionServerConfig serverConfig,
final SessionLogging sessionLogging,
final SessionAuditor sessionAuditor,
this.sessionInfoFactory = sessionInfoFactory;
this.serverConfig = serverConfig;
this.sessionLogging = sessionLogging;
this.sessionAuditor = sessionAuditor;
}
/**
* Fetches the SessionInfo from the SessionService.
*
* @param session The Session to update.
* @param reset If true, then update the last modified timestamp of the Session.
* @return Null if there was an error locating the Session, otherwise non null.
*/
if (debug.messageEnabled()) {
"Local fetch SessionInfo for {0}\n" +
"Reset: {1}",
reset));
}
}
/**
* Destroy the Session using the SessionService.
*
* @param requester {@inheritDoc}
* @param session {@inheritDoc}
* @throws SessionException {@inheritDoc}
*/
if (debug.messageEnabled()) {
}
return;
}
InternalSession internalSessionToDestroy = sessionAccessManager.getInternalSession(session.getSessionID());
if (internalSessionToDestroy == null) {
// let us check if the argument is a session handle
}
if (internalSessionToDestroy != null) {
sessionChangeAuthorizer.checkPermissionToDestroySession(requester, internalSessionToDestroy.getSessionID());
}
}
/**
* Destroy a Internal Session, whose session id has been specified.
*
* @param sessionID
*/
}
}
/**
* Sets the property using the SessionService.
* {@inheritDoc}
*/
if (debug.messageEnabled()) {
"Local setProperty for {0} {1}={2}",
name,
value));
}
}
if (reset) {
}
}
}
throw new IllegalArgumentException("Session id mismatch");
}
}
// Attempt to load the session. If one is found, the InternalSesion is now local.
}
/**
* As opposed to locateSession() this one accepts normal or restricted token
* This is expected to be only called once the session is detected as local
*
* @param token
* @return
*/
}
}
return sess;
}
boolean checkRestriction) throws SessionException {
return null;
}
if (checkRestriction) {
try {
}
} catch (SessionException se) {
throw se;
} catch (Exception e) {
throw new SessionException(e);
}
}
return session;
}
/**
* Returns the restricted token
*
* @param masterSessionId master session id
* @param restriction TokenRestriction Object
* @return restricted token id
* @throws SessionException
*/
// locate master session
}
// attempt to reuse the token if restriction is the same
if (restrictedSessionID == null) {
if (previousValue == null) {
} else {
}
}
return restrictedSessionID.toString();
}
public String deferenceRestrictedID(Session session, SessionID restrictedID) throws SessionException {
}
public void setExternalProperty(SSOToken clientToken, SessionID sessionId, String name, String value) throws SessionException {
}
if (debug.messageEnabled()) {
}
}
//if the provided session ID was a restricted token, resolveToken will always validate the restriction, so there is no
//need to check restrictions here.
}
}
}
}
/**
* Simplifies the signalling that a Session has been removed.
* @param session Non null InternalSession.
* @param event An integrate from the SessionEvent class.
*/
}
}