View Javadoc

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  /*
19   * Copyright 2008 University Corporation for Advanced Internet Development, Inc.
20   *
21   * Licensed under the Apache License, Version 2.0 (the "License");
22   * you may not use this file except in compliance with the License.
23   * You may obtain a copy of the License at
24   *
25   * http://www.apache.org/licenses/LICENSE-2.0
26   *
27   * Unless required by applicable law or agreed to in writing, software
28   * distributed under the License is distributed on an "AS IS" BASIS,
29   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30   * See the License for the specific language governing permissions and
31   * limitations under the License.
32   */
33  
34  package edu.internet2.middleware.shibboleth.idp.session.impl;
35  
36  import java.util.List;
37  import java.util.Vector;
38  
39  import org.joda.time.DateTime;
40  import org.opensaml.util.storage.AbstractExpiringObject;
41  
42  import edu.internet2.middleware.shibboleth.idp.session.Session;
43  
44  /** Session store entry. */
45  public class SessionManagerEntry extends AbstractExpiringObject {
46  
47      /** Serial version UID. */
48      private static final long serialVersionUID = -9160494097986587739L;
49  
50      /** User's session. */
51      private Session userSession;
52  
53      /** Indexes for this session. */
54      private List<String> indexes;
55  
56      /**
57       * Constructor.
58       * 
59       * @param session user session
60       * @param lifetime lifetime of session
61       */
62      public SessionManagerEntry(Session session, long lifetime) {
63          super(new DateTime().plus(lifetime));
64          userSession = session;
65          indexes = new Vector<String>();
66          indexes.add(userSession.getSessionID());
67      }
68  
69      /**
70       * Gets the user session.
71       * 
72       * @return user session
73       */
74      public Session getSession() {
75          return userSession;
76      }
77  
78      /**
79       * Gets the ID of the user session.
80       * 
81       * @return ID of the user session
82       */
83      public String getSessionId() {
84          return userSession.getSessionID();
85      }
86  
87      /**
88       * Gets the list of indexes for this session.
89       * 
90       * @return list of indexes for this session
91       */
92      public List<String> getSessionIndexes() {
93          return indexes;
94      }
95  
96      /** {@inheritDoc} */
97      public DateTime getExpirationTime() {
98          return userSession.getLastActivityInstant().plus(userSession.getInactivityTimeout());
99      }
100 }