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.idp.session.impl;
    18
    19  import java.util.Map;
    20  import java.util.concurrent.ConcurrentHashMap;
    21
    22  import edu.internet2.middleware.shibboleth.common.session.impl.AbstractSession;
    23  import edu.internet2.middleware.shibboleth.idp.session.AuthenticationMethodInformation;
    24  import edu.internet2.middleware.shibboleth.idp.session.ServiceInformation;
    25  import edu.internet2.middleware.shibboleth.idp.session.Session;
    26
    27  /** Session information for user logged into the IdP. */
    28  public class SessionImpl extends AbstractSession implements Session {
    29
    30      /** Serial version UID. */
    31      private static final long serialVersionUID = 2927868242208211623L;
    32
    33      /** Secret key associated with the session. */
    34      private byte[] sessionSecret;
    35
    36      /** The list of methods used to authenticate the user. */
    37      private Map<String, AuthenticationMethodInformation> authnMethods;
    38
    39      /** The list of services to which the user has logged in. */
    40      private Map<String, ServiceInformation> servicesInformation;
    41
    42      /**
    43       * Constructor.
    44       *
    45       * @param sessionId ID of the session
    46       * @param secret a secret to associate with the session
    47       * @param timeout inactivity timeout for the session in milliseconds
    48       */
    49      public SessionImpl(String sessionId, byte[] secret, long timeout) {
    50          super(sessionId, timeout);
    51
    52          sessionSecret = secret;
    53          authnMethods = new ConcurrentHashMap<String, AuthenticationMethodInformation>(2);
    54          servicesInformation = new ConcurrentHashMap<String, ServiceInformation>(2);
    55      }
    56
    57      /** {@inheritDoc} */
    58      public synchronized byte[] getSessionSecret() {
    59          return sessionSecret;
    60      }
    61
    62      /** {@inheritDoc} */
    63      public synchronized Map<String, AuthenticationMethodInformation> getAuthenticationMethods() {
    64          return authnMethods;
    65      }
    66
    67      /** {@inheritDoc} */
    68      public synchronized Map<String, ServiceInformation> getServicesInformation() {
    69          return servicesInformation;
    70      }
    71
    72      /**
    73       * Gets the service information for the given entity ID.
    74       *
    75       * @param entityId entity ID to retrieve the service information for
    76       *
    77       * @return the service information or null
    78       */
    79      public synchronized ServiceInformation getServiceInformation(String entityId) {
    80          return servicesInformation.get(entityId);
    81      }
    82  }