Top Description Inners Fields Constructors Methods
sun.security.pkcs11

pack-priv final Class SessionManager

extends Object
Class Inheritance
Imports
java.util.*, java.security.ProviderException, sun.security.util.Debug, sun.security.pkcs11.wrapper.*, java.util.concurrent.LinkedBlockingQueue, java.util.concurrent.atomic.AtomicInteger

Session manager. There is one session manager object per PKCS#11 provider. It allows code to checkout a session, release it back to the pool, or force it to be closed. The session manager pools sessions to minimize the number of C_OpenSession() and C_CloseSession() that have to be made. It maintains two pools: one for "object" sessions and one for "operation" sessions. The reason for this separation is how PKCS#11 deals with session objects. It defines that when a session is closed, all objects created within that session are destroyed. In other words, we may never close a session while a Key created it in is still in use. We would like to keep the number of such sessions low. Note that we occasionally want to explicitly close a session, see P11Signature. NOTE that sessions obtained from this class SHOULD be returned using either releaseSession() or closeSession() using a finally block when not needed anymore. Otherwise, they will be left for cleanup via the PhantomReference mechanism when GC kicks in, but it's best not to rely on that since GC may not run timely enough since the native PKCS11 library is also consuming memory. Note that sessions are automatically closed when they are not used for a period of time, see Session.
Author
Andreas Sterbenz
Since
1.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private final AtomicInteger
private static final Debug
private static final int
private int
private final Object
private final int
private final SessionManager.Pool
private final long
private final SessionManager.Pool
private final Token

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
private void
pack-priv void
private Session
pack-priv Session
pack-priv Session
pack-priv Session
pack-priv boolean
private Session
pack-priv Session
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

activeSessionsback to summary
private final AtomicInteger activeSessions
debugback to summary
private static final Debug debug
DEFAULT_MAX_SESSIONSback to summary
private static final int DEFAULT_MAX_SESSIONS
maxActiveSessionsback to summary
private int maxActiveSessions
maxActiveSessionsLockback to summary
private final Object maxActiveSessionsLock
maxSessionsback to summary
private final int maxSessions
objSessionsback to summary
private final SessionManager.Pool objSessions
openSessionFlagsback to summary
private final long openSessionFlags
opSessionsback to summary
private final SessionManager.Pool opSessions
tokenback to summary
private final Token token

Constructor Detail

SessionManagerback to summary
pack-priv SessionManager(Token token)

Method Detail

clearPoolsback to summary
pack-priv void clearPools()
closeSessionback to summary
private void closeSession(Session session)
demoteObjSessionback to summary
pack-priv void demoteObjSession(Session session)
ensureValidback to summary
private Session ensureValid(Session session)
getObjSessionback to summary
pack-priv Session getObjSession() throws PKCS11Exception
getOpSessionback to summary
pack-priv Session getOpSession() throws PKCS11Exception
killSessionback to summary
pack-priv Session killSession(Session session)
lowMaxSessionsback to summary
pack-priv boolean lowMaxSessions()
openSessionback to summary
private Session openSession() throws PKCS11Exception
releaseSessionback to summary
pack-priv Session releaseSession(Session session)
sun.security.pkcs11 back to summary

public final Class SessionManager.Pool

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private volatile boolean
private final SessionManager
private final AbstractQueue<Session>
private final int

Constructor Summary

AccessConstructor and Description
pack-priv
Pool(SessionManager mgr, boolean obj)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
pack-priv void
free()

pack-priv Session
poll()

pack-priv void
release(Session session)

pack-priv boolean
remove(Session session)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

closedback to summary
private volatile boolean closed
mgrback to summary
private final SessionManager mgr
poolback to summary
private final AbstractQueue<Session> pool
SESSION_MAXback to summary
private final int SESSION_MAX

Constructor Detail

Poolback to summary
pack-priv Pool(SessionManager mgr, boolean obj)

Method Detail

closeAllback to summary
pack-priv void closeAll()
freeback to summary
pack-priv void free()
pollback to summary
pack-priv Session poll()
releaseback to summary
pack-priv void release(Session session)
removeback to summary
pack-priv boolean remove(Session session)