use of com.iplanet.dpro.session.Session in project OpenAM by OpenRock.
the class PrivilegeAuthzModuleTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
final Map<String, PrivilegeDefinition> definitions = new HashMap<>();
definitions.put("evaluate", PrivilegeDefinition.getInstance("evaluate", PrivilegeDefinition.Action.READ));
definitions.put("blowup", PrivilegeDefinition.getInstance("destroy", PrivilegeDefinition.Action.MODIFY));
given(session.getClientDomain()).willReturn("/abc");
given(token.getTokenID()).willReturn(tokenID);
given(coreWrapper.convertOrgNameToRealmName("realmdn")).willReturn("/abc");
given(sessionCache.getSession(any(SessionID.class))).willReturn(session);
module = new PrivilegeAuthzModule(evaluator, definitions, factory, sessionCache, coreWrapper);
Session session = mock(Session.class);
given(subjectContext.getCallerSession()).willReturn(session);
given(session.getClientDomain()).willReturn("realmdn");
}
use of com.iplanet.dpro.session.Session in project OpenAM by OpenRock.
the class SessionCache method removeSID.
/**
* Removes the <code>SessionID</code> from session table.
*
* @param sid Session ID.
*/
public void removeSID(SessionID sid) {
if (sid == null || sid.isNull()) {
return;
}
Session session = readSession(sid);
if (session != null) {
long eventTime = System.currentTimeMillis();
// remove from sessionTable if there is no purge delay or it has elapsed
if (session.getPurgeAt() <= eventTime) {
deleteSession(sid);
session.cancel();
}
// ensure session has destroyed state and observers are notified (exactly once)
if (session.getRemoved().compareAndSet(false, true)) {
session.setState(DESTROYED);
SessionEvent event = new SessionEvent(session, SessionEvent.DESTROY, eventTime);
SessionEvent.invokeListeners(event);
}
}
}
use of com.iplanet.dpro.session.Session in project OpenAM by OpenRock.
the class SessionCookies method getLBCookie.
/**
* Returns load balancer cookie value for the Session.
* @param sid Session ID for load balancer cookie.
* @return load balancer cookie value.
* @throws SessionException if session is invalid.
*/
public String getLBCookie(SessionID sid) throws SessionException {
String cookieValue = null;
lbCookieName = SystemProperties.get(Constants.AM_LB_COOKIE_NAME, "amlbcookie");
if (sessionDebug.messageEnabled()) {
sessionDebug.message("Session.getLBCookie()" + "lbCookieName is:" + lbCookieName);
}
if (sid == null || StringUtils.isBlank(sid.toString())) {
throw new SessionException(SessionBundle.rbName, "invalidSessionID", null);
}
if (SystemProperties.isServerMode()) {
SessionService sessionService = InjectorHolder.getInstance(SessionService.class);
if (!sessionService.isSiteEnabled()) {
cookieValue = WebtopNaming.getLBCookieValue(sid.getSessionServerID());
return lbCookieName + "=" + cookieValue;
}
}
if (RESET_LB_COOKIE_NAME) {
if (SystemProperties.isServerMode()) {
SessionService sessionService = InjectorHolder.getInstance(SessionService.class);
if (sessionService.isSessionFailoverEnabled() && sessionService.isLocalSite(sid)) {
cookieValue = WebtopNaming.getLBCookieValue(sessionService.getCurrentHostServer(sid));
}
} else {
Session sess = sessionCache.readSession(sid);
if (sess != null) {
cookieValue = sess.getProperty(lbCookieName);
}
}
}
if (StringUtils.isBlank(cookieValue)) {
cookieValue = WebtopNaming.getLBCookieValue(sid.getExtension().getPrimaryID());
}
return lbCookieName + "=" + cookieValue;
}
use of com.iplanet.dpro.session.Session in project OpenAM by OpenRock.
the class MonitoredOperationsTest method setPropertyTest.
@Test
public void setPropertyTest() throws SessionException {
//given
Session mockSession = mock(Session.class);
String name = "name";
String value = "value";
//when
testMoniteredOperations.setProperty(mockSession, name, value);
//then
verify(mockSessionOperations, times(1)).setProperty(mockSession, name, value);
verify(mockStore).storeSetPropertyTime(anyLong(), any(SessionMonitorType.class));
}
use of com.iplanet.dpro.session.Session in project OpenAM by OpenRock.
the class MonitoredOperationsTest method logoutTest.
@Test
public void logoutTest() throws SessionException {
//given
Session mockSession = mock(Session.class);
//when
testMoniteredOperations.logout(mockSession);
//then
verify(mockSessionOperations, times(1)).logout(mockSession);
verify(mockStore).storeLogoutTime(anyLong(), any(SessionMonitorType.class));
}
Aggregations