/** * Returns the string representation of this object. * * @return The string representation of object */ @Override public String toString() { return Util.concatObjectsCap(100, "State: ", state, "\nDevice Error: 0x", Long.toHexString(deviceError), "\nFlags: 0x", Util.toFullHex(flags), "\nRead/Write Session: ", isRwSession(), "\nSerial Session: ", isSerialSession()); }
private static boolean checkSessionLoggedIn(final 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; }
/** * Get information about this session. * * @return An object providing information about this session. * @exception TokenException * If getting the information failed. * @preconditions * @postconditions (result <> null) */ public SessionInfo getSessionInfo() throws TokenException { CK_SESSION_INFO ckSessionInfo; try { ckSessionInfo = pkcs11Module.C_GetSessionInfo(sessionHandle); } catch (sun.security.pkcs11.wrapper.PKCS11Exception ex) { throw new PKCS11Exception(ex); } return new SessionInfo(ckSessionInfo); }
private 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); if (deviceError != 0) { LOG.error("deviceError {}", deviceError); return false; } boolean sessionLoggedIn; if (userType == PKCS11Constants.CKU_SO) { sessionLoggedIn = state.equals(State.RW_SO_FUNCTIONS); } else { sessionLoggedIn = state.equals(State.RW_USER_FUNCTIONS) || state.equals(State.RO_USER_FUNCTIONS); } LOG.debug("sessionLoggedIn: {}", sessionLoggedIn); return sessionLoggedIn; }