use of com.iplanet.dpro.session.Session in project OpenAM by OpenRock.
the class AuthD method initAuthSession.
private Session initAuthSession() throws SSOException, SessionException {
final Session authSession = getSessionService().getAuthenticationSession(defaultOrg, null);
if (authSession == null) {
debug.error("AuthD failed to get auth session");
throw new SessionException(BUNDLE_NAME, "gettingSessionFailed", null);
}
String clientID = authSession.getClientID();
authSession.setProperty("Principal", clientID);
authSession.setProperty("Organization", defaultOrg);
authSession.setProperty("Host", authSession.getID().getSessionServer());
if (LDAPUtils.isDN(clientID)) {
String id = "id=" + rdnValueFromDn(clientID) + ",ou=user," + ServiceManager.getBaseDN();
authSession.setProperty(Constants.UNIVERSAL_IDENTIFIER, id);
}
return authSession;
}
use of com.iplanet.dpro.session.Session in project OpenAM by OpenRock.
the class SessionCommand method getSessionList.
private List getSessionList(String name, String pattern) throws CLIException {
IOutput output = getOutputWriter();
List list = new ArrayList();
try {
String currentSessionHandler = curSession.getProperty(SESSION_HANDLE_PROP);
SearchResults result = curSession.getValidSessions(name, null);
String warning = getSearchResultWarningMessage(result);
if (warning.length() > 0) {
output.printlnMessage(warning);
}
Map<String, Session> sessions = (Map<String, Session>) result.getResultAttributes();
boolean isCurrentSession = false;
int i = 0;
for (Iterator iter = (Iterator) sessions.values().iterator(); iter.hasNext(); ) {
boolean isCurr = false;
Session sess = (Session) iter.next();
// need to check current session only if we have not found it.
if (!isCurrentSession) {
try {
isCurr = sess.getProperty(SESSION_HANDLE_PROP).equals(currentSessionHandler);
} catch (SessionException se) {
throw new CLIException(se, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
isCurrentSession = isCurr;
}
String userId = sess.getProperty(USER_ID);
if (userId != null) {
userId = dnToName(userId);
if (DisplayUtils.wildcardMatch(userId, pattern)) {
// -1 indicates that it is current session.
int idx = (isCurr) ? -1 : i++;
SessionData sData = createSessionData(idx, userId, sess);
if (idx == -1) {
list.add(0, sData);
} else {
list.add(sData);
}
}
}
}
} catch (SessionException se) {
throw new CLIException(se, ExitCodes.INVALID_OPTION_VALUE);
}
return list;
}
use of com.iplanet.dpro.session.Session in project OpenAM by OpenRock.
the class StatelessOperationsTest method shouldCheckPermissionToDestroySession.
@Test
public void shouldCheckPermissionToDestroySession() throws Exception {
// Given
Session requester = mock(Session.class);
// When
statelessOperations.destroy(requester, mockSession);
// Then
verify(mockSessionService).checkPermissionToDestroySession(requester, sid);
}
use of com.iplanet.dpro.session.Session in project OpenAM by OpenRock.
the class StatelessOperationsTest method shouldNotBlacklistSessionOnDestroyIfNotAllowed.
@Test(expectedExceptions = SessionException.class, expectedExceptionsMessageRegExp = "test")
public void shouldNotBlacklistSessionOnDestroyIfNotAllowed() throws Exception {
// Given
Session requester = mock(Session.class);
SessionException ex = new SessionException("test");
willThrow(ex).given(mockSessionService).checkPermissionToDestroySession(requester, sid);
// When
try {
statelessOperations.destroy(requester, mockSession);
} finally {
// Then
verifyZeroInteractions(mockSessionBlacklist);
}
}
use of com.iplanet.dpro.session.Session in project OpenAM by OpenRock.
the class StatelessOperationsTest method shouldBlacklistSessionOnDestroyWhenAllowed.
@Test
public void shouldBlacklistSessionOnDestroyWhenAllowed() throws Exception {
// Given
Session requester = mock(Session.class);
// When
statelessOperations.destroy(requester, mockSession);
// Then
verify(mockSessionLogging).logEvent(mockSessionFactory.getSessionInfo(mockSession.getSessionID()), SessionEvent.DESTROY);
verify(mockSessionBlacklist).blacklist(mockSession);
}
Aggregations