Search in sources :

Example 66 with EndpointImpl

use of org.apache.cxf.jaxws.EndpointImpl in project jbossws-cxf by jbossws.

the class DefaultJASPIAuthenticationProvider method enableServerAuthentication.

public boolean enableServerAuthentication(Object target, Endpoint endpoint) {
    if (!(target instanceof EndpointImpl)) {
        Loggers.ROOT_LOGGER.cannotEnableJASPIAuthentication(target.getClass().getSimpleName());
        return false;
    }
    EndpointImpl endpointImpl = (EndpointImpl) target;
    String securityDomain = (String) endpointImpl.getProperties().get(JaspiServerAuthenticator.JASPI_SECURITY_DOMAIN);
    if (securityDomain == null) {
        return false;
    }
    ApplicationPolicy appPolicy = SecurityConfiguration.getApplicationPolicy(securityDomain);
    if (appPolicy == null) {
        Loggers.ROOT_LOGGER.noApplicationPolicy(securityDomain);
        return false;
    }
    BaseAuthenticationInfo bai = appPolicy.getAuthenticationInfo();
    if (bai == null || bai instanceof AuthenticationInfo) {
        Loggers.ROOT_LOGGER.noJaspiApplicationPolicy(securityDomain);
        return false;
    }
    JASPIAuthenticationInfo jai = (JASPIAuthenticationInfo) bai;
    String contextRoot = endpoint.getService().getContextRoot();
    String appId = "localhost " + contextRoot;
    AuthConfigFactory factory = AuthConfigFactory.getFactory();
    Properties properties = new Properties();
    AuthConfigProvider provider = new JBossWSAuthConfigProvider(properties, factory);
    provider = factory.getConfigProvider(JBossWSAuthConstants.SOAP_LAYER, appId, null);
    JBossCallbackHandler callbackHandler = new JBossCallbackHandler();
    JaspiServerAuthenticator serverAuthenticator = null;
    try {
        ServerAuthConfig serverConfig = provider.getServerAuthConfig(JBossWSAuthConstants.SOAP_LAYER, appId, callbackHandler);
        Properties serverContextProperties = new Properties();
        serverContextProperties.put("security-domain", securityDomain);
        serverContextProperties.put("jaspi-policy", jai);
        serverContextProperties.put(javax.xml.ws.Endpoint.class, endpointImpl);
        String authContextID = endpointImpl.getBeanName();
        ServerAuthContext sctx = serverConfig.getAuthContext(authContextID, null, serverContextProperties);
        serverAuthenticator = new JaspiServerAuthenticator(sctx);
        endpointImpl.getInInterceptors().add(new JaspiSeverInInterceptor(serverAuthenticator));
        endpointImpl.getOutInterceptors().add(new JaspiSeverOutInterceptor(serverAuthenticator));
        return true;
    } catch (Exception e) {
        Loggers.DEPLOYMENT_LOGGER.cannotCreateServerAuthContext(securityDomain, e);
    }
    return false;
}
Also used : JBossWSAuthConfigProvider(org.jboss.wsf.stack.cxf.jaspi.config.JBossWSAuthConfigProvider) AuthConfigProvider(javax.security.auth.message.config.AuthConfigProvider) EndpointImpl(org.apache.cxf.jaxws.EndpointImpl) JASPIAuthenticationInfo(org.jboss.security.auth.login.JASPIAuthenticationInfo) JBossWSAuthConfigProvider(org.jboss.wsf.stack.cxf.jaspi.config.JBossWSAuthConfigProvider) Properties(java.util.Properties) BaseAuthenticationInfo(org.jboss.security.auth.login.BaseAuthenticationInfo) JASPIAuthenticationInfo(org.jboss.security.auth.login.JASPIAuthenticationInfo) AuthenticationInfo(org.jboss.security.auth.login.AuthenticationInfo) ServerAuthContext(javax.security.auth.message.config.ServerAuthContext) JaspiSeverInInterceptor(org.jboss.wsf.stack.cxf.jaspi.interceptor.JaspiSeverInInterceptor) JaspiSeverOutInterceptor(org.jboss.wsf.stack.cxf.jaspi.interceptor.JaspiSeverOutInterceptor) BaseAuthenticationInfo(org.jboss.security.auth.login.BaseAuthenticationInfo) ApplicationPolicy(org.jboss.security.config.ApplicationPolicy) AuthConfigFactory(javax.security.auth.message.config.AuthConfigFactory) JBossCallbackHandler(org.jboss.security.auth.callback.JBossCallbackHandler) ServerAuthConfig(javax.security.auth.message.config.ServerAuthConfig)

Aggregations

EndpointImpl (org.apache.cxf.jaxws.EndpointImpl)66 QName (javax.xml.namespace.QName)14 Bean (org.springframework.context.annotation.Bean)10 Bus (org.apache.cxf.Bus)9 Test (org.junit.Test)9 BeforeClass (org.junit.BeforeClass)7 Endpoint (javax.xml.ws.Endpoint)5 URL (java.net.URL)4 HashMap (java.util.HashMap)4 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)4 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)4 Feature (org.apache.cxf.feature.Feature)4 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)4 SOAPBinding (javax.xml.ws.soap.SOAPBinding)3 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)3 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 JAXBException (javax.xml.bind.JAXBException)2 XMLStreamException (javax.xml.stream.XMLStreamException)2