use of iaik.pkcs.pkcs11.SessionInfo in project xipki by xipki.
the class IaikP11Slot method checkSessionLoggedIn.
private static boolean checkSessionLoggedIn(Session session) throws P11TokenException {
SessionInfo info;
try {
info = session.getSessionInfo();
} catch (TokenException ex) {
throw new P11TokenException(ex.getMessage(), ex);
}
if (LOG.isTraceEnabled()) {
LOG.debug("SessionInfo: {}", info);
}
State state = info.getState();
long deviceError = info.getDeviceError();
LOG.debug("to be verified PKCS11Module: state = {}, deviceError: {}", state, deviceError);
boolean isRwSessionLoggedIn = state.equals(State.RW_USER_FUNCTIONS);
boolean isRoSessionLoggedIn = state.equals(State.RO_USER_FUNCTIONS);
boolean sessionLoggedIn = ((isRoSessionLoggedIn || isRwSessionLoggedIn) && deviceError == 0);
LOG.debug("sessionLoggedIn: {}", sessionLoggedIn);
return sessionLoggedIn;
}
Aggregations