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