/** * Compares all member variables of this object with the other object. * Returns only true, if all are equal in both objects. * * @param otherObject * The other SessionInfo object. * @return True, if other is an instance of Info and all member variables of * both objects are equal. False, otherwise. * @preconditions * @postconditions */ @Override public boolean equals(Object otherObject) { if (this == otherObject) { return true; } else if (!(otherObject instanceof SessionInfo)) { return false; } SessionInfo other = (SessionInfo) otherObject; return (this.slotID == other.slotID) && this.state.equals(other.state) && (this.deviceError == other.deviceError) && (this.flags == other.flags); }
/** * The overriding of this method should ensure that the objects of this * class work correctly in a hashtable. * * @return The hash code of this object. Gained from the slotID, state and * deviceError. * @preconditions * @postconditions */ @Override public int hashCode() { return ((int) slotID) ^ state.hashCode() ^ ((int) deviceError); }
/** * Constructor taking a CK_SESSION_INFO object that provides the * information. * * @param ckSessionInfo * The object providing the session information. * @preconditions (pkcs11Module <> null) * and (ckSessionInfo <> null) * @postconditions */ protected SessionInfo(CK_SESSION_INFO ckSessionInfo) { Util.requireNonNull("ckSessionInfo", ckSessionInfo); this.slotID = ckSessionInfo.slotID; this.state = new State(ckSessionInfo.state); this.deviceError = ckSessionInfo.ulDeviceError; this.flags = ckSessionInfo.flags; }
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; }
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; }