FileDocCategorySizeDatePackage
AuthenticationListenerImpl.javaAPI DocGlassfish v2 API7883Fri May 04 22:24:40 BST 2007com.sun.enterprise.admin.wsmgmt.agent

AuthenticationListenerImpl

public class AuthenticationListenerImpl extends Object implements com.sun.enterprise.webservice.monitoring.AuthenticationListener
This interface allows to register interest in authentication events in the web service container.
author
Satish Viswanatham

Fields Summary
private static final Logger
_logger
PRIVATE VARIABLES
private static final com.sun.enterprise.util.i18n.StringManager
_stringMgr
Constructors Summary
public AuthenticationListenerImpl()

    
Methods Summary
public voidauthFailure(com.sun.enterprise.deployment.BundleDescriptor desc, com.sun.enterprise.webservice.monitoring.Endpoint ep, java.security.Principal principal)
notification that a user authentication attempt has failed.

param
endpointSelector the endpoint selector
param
principal Optional principal that failed

        if (ep == null) {
            _logger.fine("Endpoint is null for " + desc.getModuleID());
            return;
        }
        // get the endpoint's fully qualified name
        String fqn =WebServiceMgrBackEnd.getManager().getFullyQualifiedName(ep);
        if (fqn == null) {
            _logger.fine("Fully Qualified could not be computed for the selector " +
            ep.getEndpointSelector());
            return;
        }

        WebServiceEndpointStatsProviderImpl impl = (
             WebServiceEndpointStatsProviderImpl) StatsProviderManager.
             getInstance().getEndpointStatsProvider(fqn);
        
        // set auth failure time stamp
        if (impl != null) {
            impl.setAuthFailure(System.currentTimeMillis());
        }
        try {
            ConfigProvider cfgProv = ConfigFactory.getConfigFactory().getConfigProvider();
            if (cfgProv != null) {
                WebServiceConfig wsc = cfgProv.getWebServiceConfig(fqn);
                if ((wsc == null) || (wsc.getMonitoringLevel() == null) 
                    || (wsc.getMonitoringLevel().equals("OFF"))) {
                // in this case, there wont be any stats 
                    _logger.fine("Monitoring is OFF for webservice endpoint " +
                        fqn);
                    return;
                }
            }
        // get its corresponding stats provider
            if (impl == null) {
                if (cfgProv != null) {
                    String msg = _stringMgr.getString("Auth.StatsNotReg", fqn);
                    throw new RuntimeException(msg);
                }
                return;
            }
        } catch (Exception e) {
            _logger.fine("Config provider could not be initialized " +
                e.getMessage());
        }
        

        /** enable the following code, once bug# 6418025 is fixed.
         ** Need a way to HTTP headers and client host information.
         ** SOAPMessageContext needed to be passed to this method.
         **
        // create empty message trace for this element
        List l =
        FilterRegistry.getInstance().getFilters(Filter.POST_PROCESS_RESPONSE,
                        fqn); 
        Iterator itr = l.iterator();
        while (itr.hasNext()) {
            Object o = itr.next();
            if (o instanceof MessageFilter) {
                MessageTraceImpl m = new MessageTraceImpl(
                   new Integer(GlobalMessageListenerImpl.newSequenceNumber())
                   .toString());
                m.setRequestSize(0);
                m.setResponseSize(0);
                m.setRequestContent(null);
                m.setResponseContent(null);
                //m.setTransportType();
                //m.setHTTPRequestHeaders();
                //m.setHTTPResponseHeaders();
                //m.setClientHost();
                // Setting principal name to principal.getName() causing issues
                m.setPrincipalName(null);
                m.setResponseTime(0);
                m.setFaultCode("999");
                m.setFaultString(null);
                m.setFaultActor(null);
                m.setTimeStamp(System.currentTimeMillis());
                //m.setCallFlowEnabled(false);
                m.setEndpointName(fqn);
                m.setApplicationID(null);

                ((MessageFilter)o)._handler.addMessage(m);
                return;
            }
        }
        */
    
public voidauthSucess(com.sun.enterprise.deployment.BundleDescriptor desc, com.sun.enterprise.webservice.monitoring.Endpoint ep, java.security.Principal principal)
notification that a user properly authenticated while making a web service invocation.

        // all the data is collected by Message listener for the success case