View Javadoc

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