FileDocCategorySizeDatePackage
WSITAuthConfigProvider.javaAPI DocExample8754Tue May 29 16:57:22 BST 2007com.sun.xml.wss.provider.wsit

WSITAuthConfigProvider

public class WSITAuthConfigProvider extends Object implements javax.security.auth.message.config.AuthConfigProvider
author
kumar.jayanti

Fields Summary
private static final String
SECURITY_POLICY_NAMESPACE_URI
String
id
String
description
WeakHashMap
clientConfigMap
WeakHashMap
serverConfigMap
private ReentrantReadWriteLock
rwLock
private ReentrantReadWriteLock$ReadLock
rLock
private ReentrantReadWriteLock$WriteLock
wLock
Constructors Summary
public WSITAuthConfigProvider(Map props, javax.security.auth.message.config.AuthConfigFactory factory)
Creates a new instance of WSITAuthConfigProvider


    

           

         

        //properties = props;

        //this.factory = factory;

        if (factory != null) {

            factory.registerConfigProvider(this, "SOAP", null,description);

        }

        this.rwLock = new ReentrantReadWriteLock(true);

        this.rLock = rwLock.readLock();

        this.wLock = rwLock.writeLock(); 

    
Methods Summary
public javax.security.auth.message.config.ClientAuthConfiggetClientAuthConfig(java.lang.String layer, java.lang.String appContext, javax.security.auth.callback.CallbackHandler callbackHandler)


        

        ClientAuthConfig clientConfig = null;

        try {

            this.rLock.lock();

            clientConfig = (ClientAuthConfig)this.clientConfigMap.get(appContext);

            if (clientConfig != null) {

                    return clientConfig;

            }

        } finally {

            this.rLock.unlock();

        }

        // make sure you don't hold the rlock when you request the wlock

        // or you will encounter dealock

        

        try {

            this.wLock.lock();

            // recheck the precondition, since the rlock was released.

            if (clientConfig == null) {

                clientConfig = new WSITClientAuthConfig(layer, appContext, callbackHandler);

                this.clientConfigMap.put(appContext, clientConfig);

            }

            return clientConfig;

        } finally {

            this.wLock.unlock();

        }

    
public javax.security.auth.message.config.ServerAuthConfiggetServerAuthConfig(java.lang.String layer, java.lang.String appContext, javax.security.auth.callback.CallbackHandler callbackHandler)


        ServerAuthConfig serverConfig = null;

         try {

             this.rLock.lock();

             serverConfig = (ServerAuthConfig)this.serverConfigMap.get(appContext);

             if (serverConfig != null) {

                 return serverConfig;

             }

         } finally {

             this.rLock.unlock();

         }

        // make sure you don't hold the rlock when you request the wlock

        // or you will encounter dealock

         

         try {

             this.wLock.lock();

             // recheck the precondition, since the rlock was released.

             if (serverConfig == null) {

                 serverConfig = new WSITServerAuthConfig(layer, appContext, callbackHandler);

                 this.serverConfigMap.put(appContext,serverConfig);

             }

             return serverConfig;

         } finally {

             this.wLock.unlock();

         }

    
public static booleanisSecurityEnabled(com.sun.xml.ws.policy.PolicyMap policyMap, com.sun.xml.ws.api.model.wsdl.WSDLPort wsdlPort)
Checks to see whether WS-Security is enabled or not.

param
policyMap policy map for {@link this} assembler
param
wsdlPort wsdl:port
return
true if Security is enabled, false otherwise


        if (policyMap == null || wsdlPort == null)

            return false;

        

        try {

            PolicyMapKey endpointKey = policyMap.createWsdlEndpointScopeKey(wsdlPort.getOwner().getName(),

                    wsdlPort.getName());

            Policy policy = policyMap.getEndpointEffectivePolicy(endpointKey);

            

            if ((policy != null) && policy.contains(SECURITY_POLICY_NAMESPACE_URI)) {

                return true;

            }

            

            for (WSDLBoundOperation wbo : wsdlPort.getBinding().getBindingOperations()) {

                PolicyMapKey operationKey = policyMap.createWsdlOperationScopeKey(wsdlPort.getOwner().getName(),

                        wsdlPort.getName(),

                        wbo.getName());

                policy = policyMap.getOperationEffectivePolicy(operationKey);

                if ((policy != null) && policy.contains(SECURITY_POLICY_NAMESPACE_URI))

                    return true;

                

                policy = policyMap.getInputMessageEffectivePolicy(operationKey);

                if ((policy != null) && policy.contains(SECURITY_POLICY_NAMESPACE_URI))

                    return true;

                

                policy = policyMap.getOutputMessageEffectivePolicy(operationKey);

                if ((policy != null) && policy.contains(SECURITY_POLICY_NAMESPACE_URI))

                    return true;

                

                policy = policyMap.getFaultMessageEffectivePolicy(operationKey);

                if ((policy != null) && policy.contains(SECURITY_POLICY_NAMESPACE_URI))

                    return true;

            }

        } catch (PolicyException e) {

            throw new WebServiceException(e);

        }

        

        return false;

    
public voidrefresh()