View Javadoc

1   /*
2    * Copyright 2006 University Corporation for Advanced Internet Development, Inc.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package edu.internet2.middleware.shibboleth.common.session;
18  
19  /**
20   * Session managers are responsible for creating, managing, and destroying Shibboleth sessions.
21   * 
22   * Session managers produce a {@link LoginEvent} during session creation and a {@link LogoutEvent} during session
23   * destruction. These events are published in the root application context, that is the highest ancestor, of the
24   * application context presented to a session manager.
25   * 
26   * @param <SessionType> type of session object managed
27   */
28  public interface SessionManager<SessionType extends Session> {
29  
30      /**
31       * Creates an empty Shibboleth session. The created session only contains an session ID. No other properties are
32       * populated.
33       * 
34       * @return a Shibboleth session
35       * 
36       * @since 1.1
37       */
38      public SessionType createSession();
39  
40      /**
41       * Creates a Shibboleth session.
42       * 
43       * @param principal the principal name of the user
44       * 
45       * @return a Shibboleth session
46       * 
47       * @deprecated use {@link #createSession()}
48       */
49      public SessionType createSession(String principal);
50  
51      /**
52       * Destroys the session.
53       * 
54       * @param index the index of the session.
55       */
56      public void destroySession(String index);
57  
58      /**
59       * Gets the user's session based on a session index.
60       * 
61       * @param index the index of the session
62       * 
63       * @return the session
64       */
65      public SessionType getSession(String index);
66  
67      /**
68       * Indexes a session by the given string. This index is in addition too the session's ID.
69       * 
70       * @param session session to index
71       * @param index additional index
72       * 
73       * @return true if the given session is assigned the given index, false if not. This operation may fail if the given
74       *         index is already assigned to another session or if the given session is not managed by this session
75       *         manager.
76       * 
77       * @since 1.1
78       */
79      public boolean indexSession(SessionType session, String index);
80  
81      /**
82       * Removes the given index from its associated session.
83       * 
84       * @param index index to be removed.
85       * 
86       * @since 1.1
87       */
88      public void removeSessionIndex(String index);
89  }