/*
* 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 providing a collection of utility functions for
* manipulating InternalSessions.
*/
public class SessionInfoFactory {
/**
* Generates a SessionInfo which is a summary state of the Session used to
* refresh remote instances of a Session.
*
* @param internalSession Non null InternalSession to summarise.
* @param sessionID SessionID of the caller making the request.
* @return Non null SessionInfo.
*
* @throws SessionException If there was a problem accessing the underlying Session.
*/
public SessionInfo getSessionInfo(InternalSession internalSession, SessionID sessionID) throws SessionException {
}
/**
* Validates the state of an Internal Session against a Session ID.
*
* Performs two checks, firstly that the Session matches the SessionID
* and secondly that the InternalSession is not timed out.
*
* @param internalSession InternalSession to check.
* @param sid SessionID to check with the InternalSession.
*
* @throws SessionException If the InternalSession has timed out.
*
* @throws IllegalArgumentException If the SessionID of the InternalSession
* and provided SessionID do not match.
*/
throws SessionException {
throw new IllegalArgumentException("Session id mismatch");
}
if (internalSession.isTimedOut()) {
sid));
} else {
sid));
}
}
}
/**
* Generates a SessionInfo object from the given InternalSession.
*
* @param internalSession Non null InternalSession to use.
* @param sid Session ID for the user performing the action.
* @return A non null SessionInfo instance if valid.
*
* @throws SessionException If there was an error storing the TokenRestriction on the SessionInfo.
*
* @throws IllegalAccessException If this method has not been called in-conjunction with
* SessionInfoFactory#validateSession
*/
throws SessionException {
if (restriction != null) {
try {
} catch (Exception e) {
throw new SessionException(e);
}
throw new IllegalArgumentException("Session id mismatch");
}
// replace master sid with the sid from the request (either master or
// restricted) in order not to leak the master sid
return info;
}
}