FileDocCategorySizeDatePackage
WSTrustFactory.javaAPI DocExample8655Tue May 29 16:56:54 BST 2007com.sun.xml.ws.security.trust

WSTrustFactory

public class WSTrustFactory extends Object
A Factory for creating concrete WS-Trust contract instances

Fields Summary
private static final Logger
log
Constructors Summary
private WSTrustFactory()

        //private constructor
    
Methods Summary
public static WSTrustClientContractcreateWSTrustClientContract(Configuration config)
return a concrete implementor for WS-Trust Client Contract

        return new WSTrustClientContractImpl(config);
    
public static com.sun.xml.ws.api.security.trust.config.STSConfigurationgetRuntimeSTSConfiguration()

        STSConfigurationProvider configProvider = null;
        final ServiceFinder<STSConfigurationProvider> finder = 
                ServiceFinder.find(STSConfigurationProvider.class);
        if (finder != null && finder.toArray().length > 0) {
            configProvider = finder.toArray()[0];
        } 
        
        if (configProvider != null){
            return configProvider.getSTSConfiguration();
        }
        
        return null;
    
public static com.sun.xml.ws.api.security.trust.STSAttributeProvidergetSTSAttributeProvider()
Returns the single instance of STSAttributeProvider Use the usual services mechanism to find implementing class. If not found, use com.sun.xml.ws.security.trust.impl.DefaultSTSAttributeProvider by default.

        
        STSAttributeProvider attrProvider = null;
        final ServiceFinder<STSAttributeProvider> finder = 
                ServiceFinder.find(STSAttributeProvider.class);
        if (finder != null && finder.toArray().length > 0) {
            attrProvider = finder.toArray()[0];
        } else {
            attrProvider = new DefaultSTSAttributeProvider();
        }
        return attrProvider;
    
public static com.sun.xml.ws.api.security.trust.STSAuthorizationProvidergetSTSAuthorizationProvider()
Returns the single instance of STSAuthorizationProvider Use the usual services mechanism to find implementing class. If not found, use com.sun.xml.ws.security.trust.impl.DefaultSTSAuthorizationProvider by default.

        
        STSAuthorizationProvider authzProvider = null;
        final ServiceFinder<STSAuthorizationProvider> finder = 
                         ServiceFinder.find(STSAuthorizationProvider.class);
        if (finder != null && finder.toArray().length > 0) {
            authzProvider = finder.toArray()[0];
        } else {
            authzProvider = new DefaultSTSAuthorizationProvider();
        }
        return authzProvider;
     
public static TrustPluginnewTrustPlugin(Configuration config)
return a concrete implementation for the TrustPlugin.

    
                
          
        return new TrustPluginImpl(config);
    
public static com.sun.xml.ws.api.security.trust.WSTrustContractnewWSTrustContract(com.sun.xml.ws.api.security.trust.config.STSConfiguration config, java.lang.String appliesTo)
Return a concrete implementor of WSTrustContract.

Note: This contract is based on JAXB Beans generated for ws-trust.xsd schema elements

Exception
UnsupportedOperationException if this factory does not support this contract

        //final STSConfiguration stsConfig = (STSConfiguration)config;
        //TrustSPMetadata spMetadata = stsConfig.getTrustSPMetadata(appliesTo);
       // if(spMetadata == null){
           // spMetadata = stsConfig.getTrustSPMetadata(WSTrustConstants.DEFAULT_APPLIESTO);
       // }
        //if (config. == null){
           // log.log(Level.SEVERE,
              //      LogStringsMessages.WST_0004_UNKNOWN_SERVICEPROVIDER(appliesTo));
           // throw new WSTrustException(LogStringsMessages.WST_0004_UNKNOWN_SERVICEPROVIDER(appliesTo));
       // }
        String type = config.getType();
        if(log.isLoggable(Level.FINE)) {
            log.log(Level.FINE,
                    LogStringsMessages.WST_1002_PROVIDER_TYPE(type));
        }
        WSTrustContract<RequestSecurityToken, RequestSecurityTokenResponse> contract = null;
        try {
            Class clazz = null;
            final ClassLoader loader = Thread.currentThread().getContextClassLoader();
            
            if (loader == null) {
                clazz = Class.forName(type);
            } else {
                clazz = loader.loadClass(type);
            }
            
            if (clazz != null) {
                contract = (WSTrustContract<RequestSecurityToken, RequestSecurityTokenResponse>) clazz.newInstance();
                contract.init(config);
            }
        } catch (ClassNotFoundException ex) {
            contract = null;
            log.log(Level.SEVERE,
                    LogStringsMessages.WST_0005_CLASSNOTFOUND_NULL_CONTRACT(type), ex);
            throw new WSTrustException(LogStringsMessages.WST_0005_CLASSNOTFOUND_NULL_CONTRACT(type), ex);
        } catch (Exception ex) {
            log.log(Level.SEVERE,
                    LogStringsMessages.WST_0038_INIT_CONTRACT_FAIL(), ex);
            throw new WSTrustException(LogStringsMessages.WST_0038_INIT_CONTRACT_FAIL(), ex);
        }
        
        return contract;