A
download SSOContextImpl.java
Language: Java
Copyright: (c) 2005 by Sun Microsystems/Ray Lai under Common Development and Distribution License
LOC: 69
Project Info
identity management security patterns(identitypatterns)
Server: java.net
Type: cvs
...terns\src\com\csp\identity\
   Assertion.java
   AssertionBuilder.java
   AssertionContext.java
   AssertionContextImpl.java
   Attribute.java
   AttributeStatement.java
   ...nticationStatement.java
   ...nDecisionStatement.java
   BinaryToken.java
   CredentialTokenizer.java
   SecurityToken.java
   SSOContext.java
   SSOContextImpl.java
   SSODelegator.java
   SSODelegatorException.java
   SSODelegatorFactory.java
   ...legatorFactoryImpl.java
   ...er_SampleFunction1.java
   SSOServiceProvider.java
   ...rviceProviderImpl1.java
   ...rviceProviderImpl2.java
   Subject.java
   TokenContext.java
   TokenContextImpl.java
   UsernameToken.java
   X509CertToken.java

/*
 * Program:    SSOContextImpl.java
 * Purpose:    Implementation for SSOContext
 * @author     Ray Lai (ray.lai@sun.com)
 * @version    1.0
 * Updated:    April 19, 2005, 8:37 AM
 * Copyright:  (c) 2005 by Sun Microsystems/Ray Lai under Common Development and Distribution License
 * Remarks:    Full program and documentation will be available under developer.java.net
 *             For simplicity, logger class is removed.
 * =====================================================================================
 * Design summary
 *
 * The SSOContext contains useful configuration and session information for each 
 * remote security service provider. it needs to be passed to the remote security
 * service provider when invoking createSSOConnection.
 */

package com.csp.identity;

import java.rmi.RemoteException;
import java.util.HashMap;
import java.util.Properties;
import com.csp.identity.*;

public class SSOContextImpl  implements com.csp.identity.SSOContext {
    
    protected String serviceName;
    protected Properties configProps;
    protected String protocolBinding;
    protected HashMap sessionInfo = new HashMap();
    protected com.csp.identity.SSOServiceProvider compRef;
    protected String status;
    protected final String REMOTE_SERVICE_CREATED = "CREATED";
    protected final String REMOTE_SERVICE_CLOSED = "CLOSED";
    protected final String REMOTE_SERVICE_ERROR = "ERROR";
    protected enum ServiceStatus { CREATED, CLOSED, ERROR };
       
    /** Constructor - Creates a new instance of SSOContextImpl */
    public SSOContextImpl() throws com.csp.identity.SSODelegatorException {
    }
    
    /**
     * Set session information in a HashMap. This stores specific session variables
     * that are relevant to a particular remote secure service provider
     *
     * @param String session variable name
     * @param String session variable value
     */
    public synchronized void setSessionInfo(String sessionVariable, String sessionValue) {
        this.sessionInfo.put(sessionVariable, sessionValue);
    }
    
    /**
     * Get session information from a HashMap. This stores specific session variables
     * that are relevant to a particular remote secure service provider
     * Need to cast the object type upon return
     *
     * @return Object  return in an Object (e.g. String).
     */
    public synchronized Object getSessionInfo(String sessionVariable) {
        return this.sessionInfo.get(sessionVariable);
    }
    
    /**
     * Remove session information from a HashMap. The HashMap stores specific session variables
     * that are relevant to a particular remote secure service provider
     *
     * @param String session variable name
     */
    public synchronized void removeSessionInfo(String sessionVariable) {
        this.sessionInfo.remove(sessionVariable);
    }
    
    /**
     * Get private configuration properties specific to a particular 
     * remote secure service provider. This object needs to be loaded during
     * initConfig(), by the constructor or manually
     *
     * @return Properties  a Properties object
     */
    public java.util.Properties getConfigProperties() {
        return configProps;
    }
    
 /**
     * Set private configuration properties specific to a particular 
     * remote secure service provider. This object needs to be loaded during
     * initConfig(), by the constructor or manually
     *
     * @param Properties  a Properties object
     */    
    public void setConfigProperties(java.util.Properties configProps) {
        this.configProps = configProps;
    }
        
    /**
     * Get protocol binding for the remote security service provider
     *
     * @return String protocol binding, e.g. SOAP, RMI (arbitrary name)
     */
    public String getProtocolBinding() {
        return this.protocolBinding;
    }
    
     /**
     * Set protocol binding for the remote security service provider
     *
     * @param String protocol binding, e.g. SOAP, RMI (arbitrary name)
     */
    public void setProtocolBinding(String protocolBinding) {
        this.protocolBinding = protocolBinding;
    }
    
    /**
     * Get service name of the remote security service provider.
     * This name needs to match the field 'serviceName' in the 
     * SSOServiceProvider implementation classes
     *
     * @return String service name, e.g. service1
     */
    public String getServiceName() {
        return this.serviceName;
    }
    
    /**
     * set service name
     *
     * @param String logical remote service name, e.g. service1
     *
     **/
    public void setServiceName(String serviceName) {
        this.serviceName = serviceName;
    }

    /**
     * Get component reference 
     *
     * @return SSOServiceProvider component reference to be stored in the HashMap
     *                           once a connection is created
     **/
    public com.csp.identity.SSOServiceProvider getCompRef() {
        return this.compRef;
    }
    
    /**
     * Set component reference 
     *
     * @param SSOServiceProvider component reference to be stored in the HashMap
     *                           once a connection is created
     **/
    public void setCompRef(com.csp.identity.SSOServiceProvider compRef) {
        this.compRef = compRef;
    }
    
    /**
     * Remove component reference 
     *
     **/    
    public void removeCompRef(){
        this.compRef = null;
    }
    
        
    /**
     * Look up the class name or URI by the service name
     *
     * This example hardcodes one class name for demo.
     * You may want to replace it by a Service Locator pattern
     *
     * @param String service name to look up
     * @return String class name (or URI) corresponding service
     **/
    public String serviceLocator(String serviceName) {
        
        // This example shows 2 remote security service providers 
        // hard-coded for demo purpose. 
        // You may want to use a Service Locator pattern here
        if (serviceName.equals("service1")) {
           return "com.csp.identity.SSOServiceProviderImpl1";
        } if (serviceName.equals("service2"))   {
            return "com.csp.identity.SSOServiceProviderImpl2";
        }
        return "com.csp.identity.SSOServiceProviderImpl2";
    }
    
    /**
     * set status of the remote service
     *
     * @param String status
     */
    public void setStatus(String status) {
        this.status = status;
    }
    
    /**
     * get status of the remote service
     *
     * @return String status
     */    
    public String getStatus() {
        return this.status;
    }
}

About Koders | Resources | Downloads | Support | Black Duck | Terms of Service | DMCA | Privacy Policy | Contact Us