/***********************************************************************
 * 
 *  Copyright (C) 2006 Novell, Inc. All Rights Reserved.
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; version 2.1
 *  of the License.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Library Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, Novell, Inc.
 * 
 *  To contact Novell about this file by physical or electronic mail, 
 *  you may find current contact information at www.novell.com.
 * 
 *  Author: Juan Carlos Luciani <jluciani@novell.com>
 *  
 ***********************************************************************/

package com.novell.casa.jaas;

import java.security.Principal;

import com.novell.casa.authtoksvc.IdentityToken;

/*
 * CasaPrincipal class.
 * 
 * This class implements the principal class for
 * identities authenticated by Casa.
 * 
 */
public final class CasaPrincipal implements Principal
{
   private final String m_name;
   private final String m_realm;
   private final String m_identStoreUrl;
   private final javax.naming.directory.Attributes m_attributes;
   
   /*
    * Constructor
    */
   public CasaPrincipal(IdentityToken identityToken) throws Exception
   {
      // Get the necessary information from the identity token
      m_name = identityToken.getIdentityId();
      m_realm = identityToken.getSourceName();
      m_identStoreUrl = identityToken.getSourceUrl();
      m_attributes = identityToken.getAttributes();
   }

   /*
    *  (non-Javadoc)
    * @see java.security.Principal#getName()
    */
   public final String getName()
   {
      return m_name;
   }
   
   /*
    * Returns the name associated with the source of the identity data.
    */
   public final String getRealm()
   {
      return m_realm;
   }

   /*
    * Returns the url associated with the source of the identity data.
    */
   public final String getIdentStoreUrl()
   {
      return m_identStoreUrl;
   }

   /*
    * Returns the identity attributes.
    */
   public final javax.naming.directory.Attributes getAttributes()
   {
      return m_attributes;
   }
}
