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

WSITClientAuthConfig

public class WSITClientAuthConfig extends Object implements javax.security.auth.message.config.ClientAuthConfig
author
kumar jayanti

Fields Summary
private static final Logger
log
private String
layer
private String
appContext
private WSITClientAuthContext
clientAuthContext
private com.sun.xml.ws.policy.PolicyMap
policyMap
private ReentrantReadWriteLock
rwLock
private ReentrantReadWriteLock$ReadLock
rLock
private ReentrantReadWriteLock$WriteLock
wLock
private String
secDisabled
private static final String
TRUE
private static final String
FALSE
Constructors Summary
public WSITClientAuthConfig(String layer, String appContext, CallbackHandler callbackHandler)
Creates a new instance of WSITClientAuthConfig

    
           
           
        this.layer = layer;
        this.appContext = appContext;
        //this.cbh = callbackHandler;
        this.rwLock = new ReentrantReadWriteLock(true);
        this.rLock = rwLock.readLock();
        this.wLock = rwLock.writeLock(); 
    
Methods Summary
public java.lang.StringgetAppContext()

        return appContext;
    
public javax.security.auth.message.config.ClientAuthContextgetAuthContext(java.lang.String operation, javax.security.auth.Subject subject, java.util.Map map)

        PolicyMap  pMap = (PolicyMap)map.get("POLICY");
        WSDLPort port =(WSDLPort)map.get("WSDL_MODEL");
        if (pMap == null || pMap.isEmpty()) {
            return null;
        }
        
        //now check if security is enabled
        //if the policy has changed due to redeploy recheck if security is enabled
        if (this.secDisabled == null || (policyMap != pMap)) {
            try {
                this.wLock.lock();
                if (this.secDisabled == null || (policyMap != pMap)) {
                    if (!WSITAuthConfigProvider.isSecurityEnabled(pMap,port)) {
                        this.secDisabled = TRUE;
                        return null;
                    } else {
                        this.secDisabled = FALSE;
                    }
                }
            } finally {
                this.wLock.unlock();
            }
        }
        
         if (this.secDisabled == TRUE) {
             return null;
         }

        
        boolean authContextInitialized = false;
        
        try {
            this.rLock.lock();
            if (clientAuthContext != null) {
               //probably the app was redeployed
               //if so reacquire the AuthContext
                if (pMap == policyMap) {
                    authContextInitialized = true;
                }
            }
        } finally {
            this.rLock.unlock();
        }
        
        if (!authContextInitialized) {
            try {
                this.wLock.lock();
                // recheck the precondition, since the rlock was released.
                if (clientAuthContext == null || (policyMap != pMap)) {
                    clientAuthContext = new WSITClientAuthContext(operation, subject, map);
                    policyMap = pMap;
                }
            } finally {
                this.wLock.unlock();
            }
        }
       
        this.startSecureConversation(map);
        return clientAuthContext;
    
public java.lang.StringgetAuthContextID(javax.security.auth.message.MessageInfo messageInfo)

        return null;
    
public java.lang.StringgetMessageLayer()

        return layer;
    
public java.lang.StringgetOperation(javax.security.auth.message.MessageInfo messageInfo)

        return null;
    
public booleanisProtected()

        return true;
    
public voidrefresh()

    
public javax.xml.bind.JAXBElementstartSecureConversation(java.util.Map map)

        //check if we need to start secure conversation
        JAXBElement ret = null;
        try {
            MessageInfo info = (MessageInfo)map.get("SECURITY_TOKEN");
            if (info != null) {
                Packet packet = (Packet)info.getMap().get(WSITAuthContextBase.REQ_PACKET);
                if (packet != null) {
                    if (clientAuthContext != null) {
                        ret =  ((WSITClientAuthContext)clientAuthContext).startSecureConversation(packet);
                        //map.put("SECURITY_TOKEN", ret);
                        info.getMap().put("SECURITY_TOKEN", ret);
                    } else {
                        log.log(Level.SEVERE, 
                                LogStringsMessages.WSITPVD_0024_NULL_CLIENT_AUTH_CONTEXT());                                
                        throw new WSSecureConversationException(
                                LogStringsMessages.WSITPVD_0024_NULL_CLIENT_AUTH_CONTEXT());
                    }
                } else {
                    log.log(Level.SEVERE, LogStringsMessages.WSITPVD_0025_NULL_PACKET());
                    throw new RuntimeException(LogStringsMessages.WSITPVD_0025_NULL_PACKET());                            
                }
            }
        } catch (WSSecureConversationException ex) {
            log.log(Level.SEVERE, LogStringsMessages.WSITPVD_0026_ERROR_STARTING_SC(), ex);            
            throw new RuntimeException(LogStringsMessages.WSITPVD_0026_ERROR_STARTING_SC(), ex);
        }
        return ret;