Lines Matching refs:session

38  * Session manager. There is one session manager object per PKCS#11
39 * provider. It allows code to checkout a session, release it
42 * The session manager pools sessions to minimize the number of
47 * The reason for this separation is how PKCS#11 deals with session objects.
48 * It defines that when a session is closed, all objects created within
49 * that session are destroyed. In other words, we may never close a session
52 * close a session, see P11Signature.
122 Session session = objSessions.poll();
123 if (session != null) {
124 return ensureValid(session);
126 session = opSessions.poll();
127 if (session != null) {
128 return ensureValid(session);
130 session = openSession();
131 return ensureValid(session);
135 Session session = opSessions.poll();
136 if (session != null) {
137 return ensureValid(session);
139 // create a new session rather than re-using an obj session
143 session = openSession();
144 return ensureValid(session);
146 session = objSessions.poll();
147 if (session != null) {
148 return ensureValid(session);
150 throw new ProviderException("Could not obtain session");
153 private Session ensureValid(Session session) {
154 session.id();
155 return session;
158 synchronized Session killSession(Session session) {
159 if ((session == null) || (token.isValid() == false)) {
164 System.out.println("Killing session (" + location + ") active: "
167 closeSession(session);
171 synchronized Session releaseSession(Session session) {
172 if ((session == null) || (token.isValid() == false)) {
176 if (session.hasObjects()) {
177 objSessions.release(session);
179 opSessions.release(session);
184 synchronized void demoteObjSession(Session session) {
189 System.out.println("Demoting session, active: " +
192 boolean present = objSessions.remove(session);
194 // session is currently in use
198 opSessions.release(session);
208 Session session = new Session(token, id);
218 return session;
221 private void closeSession(Session session) {
222 session.close();
237 boolean remove(Session session) {
238 return pool.remove(session);
246 Session session = pool.remove(n - 1);
247 return session;
250 void release(Session session) {
251 pool.add(session);
253 if (session.hasObjects()) {
262 if (session.isLive(time) && oldestSession.isLive(time)) {
267 while (i < n - 1) { // always keep at least 1 session open