A
download AuthenticationStatement.java
Language: Java
Copyright: (c) 2005 by Sun Microsystems/Ray Lai under Common Development and Distribution License
LOC: 41
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:    AuthenticationStatement.java
 * Purpose:    Creating SAML authentication statement
 * @author     Ray Lai (ray.lai@sun.com)
 * @version    1.0
 * Updated:    April 17, 2005, 1:31 PM
 * 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 licensing/copyright issues, sample service provider class such as OpenSAML is removed.
 * =====================================================================================
 */

package com.csp.identity;

import com.csp.saml.SAMLAuthenticationStatement;
import com.csp.saml.SAMLException;
import com.csp.saml.SAMLNameIdentifier;
import com.csp.saml.SAMLSubject;
import java.util.Date;

public class AuthenticationStatement extends com.csp.identity.Assertion {
    
    static final String ASSERTION_TYPE = "AUTHENTICATION";
    protected com.csp.identity.AuthenticationStatement authStateFactory;

    
    /** Constructor - Creates a new instance of AuthenticationStatement 
     *
     *  In production, you would probably want to make this constructor private
     *  and use the getInstance() to create a new instance
     */
    public AuthenticationStatement() {

    }

    /**
     *  Get instance of the existing authentication assertion statement
     *  If instance does not exist, create one (Singelton pattern!)
     *
     *  @return AuthenticationStatement instance of Authentication
     *               statement
     */
    public com.csp.identity.AuthenticationStatement getInstance() {
        if (authStateFactory == null) {
            //System.out.println("no auth statement exists before...");
            authStateFactory = new AuthenticationStatement();
            if (authStateFactory == null)
                System.out.println("WARN: authentication statement is null");
        }
        return this.authStateFactory;
    }
 
    /**
     * Create SAML authentication assertion statement
     *
     **/
    public void create() {    
        // customize your create() using your service provider classes
        SAMLSubject samlSubject;
        java.util.Date authInstant = new Date();
        String samlSubjectIP = this.getSubjectIP();
        String samlSubjectDNS = this.getSubjectDNS();
        SAMLNameIdentifier samlNameIdentifier;
        
        try {
           // Create SAML Subject object using custom /stub SAML service provider class
           samlNameIdentifier = 
                new SAMLNameIdentifier(this.subject.getSubjectName(), 
                this.subject.getSubjectNameQualifier(),"");
           samlSubject = new SAMLSubject(samlNameIdentifier, null, null, null);
                      
           // Create SAML authentication statement using custom /stub SAML service provider class
           SAMLAuthenticationStatement samlAuthStat = 
                new SAMLAuthenticationStatement(samlSubject, authInstant, samlSubjectIP, samlSubjectDNS, null);
           samlAuthStat.checkValidity();
           System.out.println("DEBUG - The current SAML authentication statement is valid!");
        }
        catch (SAMLException se) {
            System.out.println("ERROR - Invalid SAML authentication assertion statement");
            se.printStackTrace();
        }
    }
}

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