Search in sources :

Example 1 with SessionInfo

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;
}
Also used : State(iaik.pkcs.pkcs11.State) P11TokenException(org.xipki.security.exception.P11TokenException) TokenException(iaik.pkcs.pkcs11.TokenException) P11TokenException(org.xipki.security.exception.P11TokenException) SessionInfo(iaik.pkcs.pkcs11.SessionInfo)

Aggregations

SessionInfo (iaik.pkcs.pkcs11.SessionInfo)1 State (iaik.pkcs.pkcs11.State)1 TokenException (iaik.pkcs.pkcs11.TokenException)1 P11TokenException (org.xipki.security.exception.P11TokenException)1