FileDocCategorySizeDatePackage
SecurityPolicyAssertionCreator.javaAPI DocExample11685Tue May 29 16:56:48 BST 2007com.sun.xml.ws.security.impl.policy

SecurityPolicyAssertionCreator

public class SecurityPolicyAssertionCreator extends Object implements com.sun.xml.ws.policy.spi.PolicyAssertionCreator
author
K.Venugopal@sun.com

Fields Summary
private static HashSet
implementedAssertions
private static final String[]
nsSupportedList
Constructors Summary
public SecurityPolicyAssertionCreator()
Creates a new instance of SecurityPolicyAssertionCreator

    //    Constants.SUN_WSS_SECURITY_CLIENT_POLICY_NS,
    //    Constants.SUN_WSS_SECURITY_SERVER_POLICY_NS,
    //    Constants.SUN_SECURE_CLIENT_CONVERSATION_POLICY_NS,Constants.SUN_SECURE_SERVER_CONVERSATION_POLICY_NS
    //    ,Constants.SUN_TRUST_CLIENT_SECURITY_POLICY_NS,Constants.SUN_TRUST_SERVER_SECURITY_POLICY_NS};
    
        implementedAssertions.add(Constants.AlgorithmSuite);
        implementedAssertions.add(Constants.AsymmetricBinding);
        implementedAssertions.add(Constants.Address);
        implementedAssertions.add(Constants.EncryptedElements);
        implementedAssertions.add(Constants.EncryptedParts);
        implementedAssertions.add(Constants.EncryptionToken);
        implementedAssertions.add(Constants.EndorsingSupportingTokens);
        implementedAssertions.add(Constants.EndpointReference);
        
        implementedAssertions.add(Constants.HEADER);
        implementedAssertions.add(Constants.HttpsToken);
        implementedAssertions.add(Constants.IssuedToken);
        implementedAssertions.add(Constants.Issuer);
        implementedAssertions.add(Constants.InitiatorToken);
        
        implementedAssertions.add(Constants.KerberosToken);
        
        implementedAssertions.add(Constants.Lifetime);
        implementedAssertions.add(Constants.Layout);
        
        implementedAssertions.add(Constants.ProtectionToken);
        
        implementedAssertions.add(Constants.RecipientToken);
        implementedAssertions.add(Constants.RelToken);
        implementedAssertions.add(Constants.RequestSecurityTokenTemplate);
        implementedAssertions.add(Constants.RequiredElements);
        
        implementedAssertions.add(Constants.SamlToken);
        implementedAssertions.add(Constants.SecurityContextToken);
        implementedAssertions.add(Constants.SecureConversationToken);
        implementedAssertions.add(Constants.SignedElements);
        implementedAssertions.add(Constants.SignedSupportingTokens);
        implementedAssertions.add(Constants.SignedEndorsingSupportingTokens);
        implementedAssertions.add(Constants.SignedParts);
        implementedAssertions.add(Constants.SpnegoContextToken);
        implementedAssertions.add(Constants.SupportingTokens);
        implementedAssertions.add(Constants.SignatureToken);
        implementedAssertions.add(Constants.SymmetricBinding);
        
        implementedAssertions.add(Constants.TransportBinding);
        implementedAssertions.add(Constants.TransportToken);
        implementedAssertions.add(Constants.Trust10);
        
        implementedAssertions.add(Constants.UsernameToken);
        implementedAssertions.add(Constants.UseKey);
        
        implementedAssertions.add(Constants.Wss10);
        implementedAssertions.add(Constants.Wss11);
        implementedAssertions.add(Constants.X509Token);
        implementedAssertions.add(Constants.KeyStore);
        implementedAssertions.add(Constants.TrustStore);
        implementedAssertions.add(Constants.CallbackHandler);
        implementedAssertions.add(Constants.CallbackHandlerConfiguration);
        implementedAssertions.add(Constants.Validator);
        implementedAssertions.add(Constants.ValidatorConfiguration);
        implementedAssertions.add(Constants.CertStore);
    
        
    
Methods Summary
public com.sun.xml.ws.policy.PolicyAssertioncreateAssertion(com.sun.xml.ws.policy.sourcemodel.AssertionData assertionData, java.util.Collection nestedAssertions, com.sun.xml.ws.policy.AssertionSet nestedAlternative, com.sun.xml.ws.policy.spi.PolicyAssertionCreator policyAssertionCreator)

        String localName = assertionData.getName().getLocalPart();
        if(implementedAssertions.contains(localName)){
            Class cl=null;
            cl = getClass(assertionData);
            //            try {
            Constructor cons = null;
            try {
                
                cons = getConstructor(cl);
                
                //cl.getConstructor(javax.xml.stream.events.StartElement.class);
            } catch (NoSuchMethodException ex) {
                if(logger.isLoggable(Level.SEVERE)){
                    logger.log(Level.SEVERE,LogStringsMessages.SP_0111_ERROR_OBTAINING_CONSTRUCTOR(assertionData.getName()),ex);
                }
                throw new AssertionCreationException(assertionData,ex);
            }catch (SecurityException ex) {
                if(logger.isLoggable(Level.SEVERE)){
                    logger.log(Level.SEVERE,LogStringsMessages.SP_0111_ERROR_OBTAINING_CONSTRUCTOR(assertionData.getName()),ex);
                }
                
                
                throw new AssertionCreationException(assertionData,ex);
            }
            if(cons != null){
                try {
                    return (PolicyAssertion)cons.newInstance(assertionData,nestedAssertions,nestedAlternative);
                } catch (IllegalArgumentException ex) {
                    if(logger.isLoggable(Level.SEVERE)){
                        logger.log(Level.SEVERE,LogStringsMessages.SP_0112_ERROR_INSTANTIATING(assertionData.getName()));
                    }
                    
                    throw new AssertionCreationException(assertionData,ex);
                } catch (InvocationTargetException ex) {
                    if(logger.isLoggable(Level.SEVERE)){
                        logger.log(Level.SEVERE,LogStringsMessages.SP_0112_ERROR_INSTANTIATING(assertionData.getName()));
                    }
                    throw new AssertionCreationException(assertionData,ex);
                } catch (InstantiationException ex) {
                    if(logger.isLoggable(Level.SEVERE)){
                        logger.log(Level.SEVERE,LogStringsMessages.SP_0112_ERROR_INSTANTIATING(assertionData.getName()));
                    }
                    throw new AssertionCreationException(assertionData,ex);
                } catch (IllegalAccessException ex) {
                    if(logger.isLoggable(Level.SEVERE)){
                        logger.log(Level.SEVERE,LogStringsMessages.SP_0112_ERROR_INSTANTIATING(assertionData.getName()));
                    }
                    throw new AssertionCreationException(assertionData,ex);
                }
            }else{
                try{
                    return (PolicyAssertion)cl.newInstance();
                } catch (InstantiationException ex) {
                    if(logger.isLoggable(Level.SEVERE)){
                        logger.log(Level.SEVERE,LogStringsMessages.SP_0112_ERROR_INSTANTIATING(assertionData.getName()));
                    }
                    throw new AssertionCreationException(assertionData,ex);
                } catch (IllegalAccessException ex) {
                    if(logger.isLoggable(Level.SEVERE)){
                        logger.log(Level.SEVERE,LogStringsMessages.SP_0112_ERROR_INSTANTIATING(assertionData.getName()));
                    }
                    throw new AssertionCreationException(assertionData,ex);
                }
            }
            
            
        }
        return policyAssertionCreator.createAssertion(assertionData,nestedAssertions,nestedAlternative,policyAssertionCreator);
        
    
protected java.lang.ClassgetClass(com.sun.xml.ws.policy.sourcemodel.AssertionData assertionData)

        String className ="";
        try {
            className = assertionData.getName().getLocalPart();
            //made mistake here, we are now in SCF and cannot change the classname
            //will make a change for WSIT 1.1
            if (Constants.CertStore.equals(className)) {
                className = "CertStoreConfig";
            }
            return Class.forName("com.sun.xml.ws.security.impl.policy." + className);
        } catch (ClassNotFoundException ex) {
            if(logger.isLoggable(Level.SEVERE)){
                logger.log(Level.SEVERE,LogStringsMessages.SP_0110_ERROR_LOCATING_CLASS(SECURITY_POLICY_PACKAGE_DIR +className),ex);
            }
            throw new AssertionCreationException(assertionData,ex);
        }
    
private java.lang.reflect.ConstructorgetConstructor(java.lang.Class cl)

        Constructor [] cList = cl.getConstructors();
        return cl.getConstructor(com.sun.xml.ws.policy.sourcemodel.AssertionData.class,java.util.Collection.class,com.sun.xml.ws.policy.AssertionSet.class);
    
public java.lang.String[]getSupportedDomainNamespaceURIs()

        return nsSupportedList;