Author: asoldano
Date: 2014-02-12 08:18:39 -0500 (Wed, 12 Feb 2014)
New Revision: 18340
Modified:
stack/cxf/branches/jaspi/modules/client/src/main/java/org/jboss/wsf/stack/cxf/Loggers.java
stack/cxf/branches/jaspi/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/jaspi/JaspiClientAuthenticator.java
stack/cxf/branches/jaspi/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/jaspi/JaspiClientInInterceptor.java
stack/cxf/branches/jaspi/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/jaspi/JaspiClientOutInterceptor.java
stack/cxf/branches/jaspi/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/jaspi/module/SOAPClientAuthModule.java
stack/cxf/branches/jaspi/modules/jaspi/src/main/java/org/jboss/wsf/stack/cxf/jaspi/config/JBossWSAuthConfigProvider.java
stack/cxf/branches/jaspi/modules/jaspi/src/main/java/org/jboss/wsf/stack/cxf/jaspi/config/JBossWSClientAuthConfig.java
stack/cxf/branches/jaspi/modules/jaspi/src/main/java/org/jboss/wsf/stack/cxf/jaspi/config/JBossWSClientAuthContext.java
stack/cxf/branches/jaspi/modules/jaspi/src/main/java/org/jboss/wsf/stack/cxf/jaspi/config/JBossWSServerAuthConfig.java
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/ServerBeanCustomizer.java
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/JaspiSeverInInterceptor.java
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/JaspiSeverOutInterceptor.java
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/jaspi/JaspiServerAuthenticator.java
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/jaspi/module/UsernameTokenServerAuthModule.java
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/JaspiSubjectCreatingInterceptor.java
stack/cxf/branches/jaspi/modules/server/src/test/java/org/jboss/wsf/stack/cxf/configuration/BusHolderTest.java
stack/cxf/branches/jaspi/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/BusHolderLifeCycleTestCase.java
Log:
Bunch of minor improvements (making final what should actually be and some refactoring)
Modified:
stack/cxf/branches/jaspi/modules/client/src/main/java/org/jboss/wsf/stack/cxf/Loggers.java
===================================================================
---
stack/cxf/branches/jaspi/modules/client/src/main/java/org/jboss/wsf/stack/cxf/Loggers.java 2014-02-12
10:18:01 UTC (rev 18339)
+++
stack/cxf/branches/jaspi/modules/client/src/main/java/org/jboss/wsf/stack/cxf/Loggers.java 2014-02-12
13:18:39 UTC (rev 18340)
@@ -235,5 +235,5 @@
@LogMessage(level = WARN)
@Message(id = 24104, value = "Can not create Jaspi ServerAuthContext for
security domain '%s'")
- void cannotCreateServerAuthContext(String securityDomain);
+ void cannotCreateServerAuthContext(String securityDomain, @Cause Throwable cause);
}
Modified:
stack/cxf/branches/jaspi/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/jaspi/JaspiClientAuthenticator.java
===================================================================
---
stack/cxf/branches/jaspi/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/jaspi/JaspiClientAuthenticator.java 2014-02-12
10:18:01 UTC (rev 18339)
+++
stack/cxf/branches/jaspi/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/jaspi/JaspiClientAuthenticator.java 2014-02-12
13:18:39 UTC (rev 18340)
@@ -24,9 +24,9 @@
public class JaspiClientAuthenticator
{
public static final String JASPI_SECURITY_DOMAIN = "jaspi.security.domain";
- private ClientAuthConfig clientConfig;
- private String securityDomain;
- private JASPIAuthenticationInfo jpi;
+ private final ClientAuthConfig clientConfig;
+ private final String securityDomain;
+ private final JASPIAuthenticationInfo jpi;
public JaspiClientAuthenticator(ClientAuthConfig clientConfig, String securityDomain,
JASPIAuthenticationInfo jpi)
{
@@ -46,6 +46,7 @@
serverContextProperties.put("security-domain", securityDomain);
serverContextProperties.put("jaspi-policy", jpi);
Subject clientSubject = new Subject();
+ @SuppressWarnings("unused")
AuthStatus authStatus = null;
try
{
@@ -79,6 +80,7 @@
serverContextProperties.put("security-domain", securityDomain);
serverContextProperties.put("jaspi-policy", jpi);
Subject clientSubject = new Subject();
+ @SuppressWarnings("unused")
AuthStatus authStatus = null;
try
{
Modified:
stack/cxf/branches/jaspi/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/jaspi/JaspiClientInInterceptor.java
===================================================================
---
stack/cxf/branches/jaspi/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/jaspi/JaspiClientInInterceptor.java 2014-02-12
10:18:01 UTC (rev 18339)
+++
stack/cxf/branches/jaspi/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/jaspi/JaspiClientInInterceptor.java 2014-02-12
13:18:39 UTC (rev 18340)
@@ -33,7 +33,8 @@
*/
public class JaspiClientInInterceptor extends AbstractSoapInterceptor
{
- private JaspiClientAuthenticator authManager;
+ private final JaspiClientAuthenticator authManager;
+
public JaspiClientInInterceptor(JaspiClientAuthenticator authManager)
{
super(Phase.POST_PROTOCOL_ENDING);
Modified:
stack/cxf/branches/jaspi/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/jaspi/JaspiClientOutInterceptor.java
===================================================================
---
stack/cxf/branches/jaspi/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/jaspi/JaspiClientOutInterceptor.java 2014-02-12
10:18:01 UTC (rev 18339)
+++
stack/cxf/branches/jaspi/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/jaspi/JaspiClientOutInterceptor.java 2014-02-12
13:18:39 UTC (rev 18340)
@@ -40,7 +40,8 @@
*/
public class JaspiClientOutInterceptor extends AbstractSoapInterceptor
{
- private JaspiClientAuthenticator authManager;
+ private final JaspiClientAuthenticator authManager;
+
public JaspiClientOutInterceptor(JaspiClientAuthenticator authManager)
{
super(Phase.PRE_PROTOCOL);
Modified:
stack/cxf/branches/jaspi/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/jaspi/module/SOAPClientAuthModule.java
===================================================================
---
stack/cxf/branches/jaspi/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/jaspi/module/SOAPClientAuthModule.java 2014-02-12
10:18:01 UTC (rev 18339)
+++
stack/cxf/branches/jaspi/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/jaspi/module/SOAPClientAuthModule.java 2014-02-12
13:18:39 UTC (rev 18340)
@@ -32,16 +32,8 @@
import javax.security.auth.message.MessageInfo;
import javax.security.auth.message.MessagePolicy;
import javax.security.auth.message.module.ClientAuthModule;
-import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
-import org.apache.cxf.binding.soap.SoapMessage;
-import org.apache.cxf.binding.soap.SoapVersion;
-import org.apache.cxf.binding.soap.SoapVersionFactory;
-import org.apache.cxf.message.Exchange;
-import org.apache.cxf.message.ExchangeImpl;
-import org.apache.cxf.message.MessageImpl;
-import org.apache.ws.security.WSSConfig;
import org.jboss.security.SimplePrincipal;
/**
Modified:
stack/cxf/branches/jaspi/modules/jaspi/src/main/java/org/jboss/wsf/stack/cxf/jaspi/config/JBossWSAuthConfigProvider.java
===================================================================
---
stack/cxf/branches/jaspi/modules/jaspi/src/main/java/org/jboss/wsf/stack/cxf/jaspi/config/JBossWSAuthConfigProvider.java 2014-02-12
10:18:01 UTC (rev 18339)
+++
stack/cxf/branches/jaspi/modules/jaspi/src/main/java/org/jboss/wsf/stack/cxf/jaspi/config/JBossWSAuthConfigProvider.java 2014-02-12
13:18:39 UTC (rev 18340)
@@ -35,7 +35,7 @@
*/
public class JBossWSAuthConfigProvider implements AuthConfigProvider
{
- private Properties contextProperties;
+ private final Properties contextProperties;
public JBossWSAuthConfigProvider(Properties props, AuthConfigFactory factory)
{
Modified:
stack/cxf/branches/jaspi/modules/jaspi/src/main/java/org/jboss/wsf/stack/cxf/jaspi/config/JBossWSClientAuthConfig.java
===================================================================
---
stack/cxf/branches/jaspi/modules/jaspi/src/main/java/org/jboss/wsf/stack/cxf/jaspi/config/JBossWSClientAuthConfig.java 2014-02-12
10:18:01 UTC (rev 18339)
+++
stack/cxf/branches/jaspi/modules/jaspi/src/main/java/org/jboss/wsf/stack/cxf/jaspi/config/JBossWSClientAuthConfig.java 2014-02-12
13:18:39 UTC (rev 18340)
@@ -58,7 +58,7 @@
{
@SuppressWarnings("rawtypes")
- private List modules = new ArrayList();
+ private final List modules = new ArrayList();
private CallbackHandler callbackHandler;
@SuppressWarnings("rawtypes")
Modified:
stack/cxf/branches/jaspi/modules/jaspi/src/main/java/org/jboss/wsf/stack/cxf/jaspi/config/JBossWSClientAuthContext.java
===================================================================
---
stack/cxf/branches/jaspi/modules/jaspi/src/main/java/org/jboss/wsf/stack/cxf/jaspi/config/JBossWSClientAuthContext.java 2014-02-12
10:18:01 UTC (rev 18339)
+++
stack/cxf/branches/jaspi/modules/jaspi/src/main/java/org/jboss/wsf/stack/cxf/jaspi/config/JBossWSClientAuthContext.java 2014-02-12
13:18:39 UTC (rev 18340)
@@ -21,9 +21,7 @@
*/
package org.jboss.wsf.stack.cxf.jaspi.config;
-
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -41,9 +39,9 @@
* @author <a href="ema(a)redhat.com">Jim Ma</a>
*/
public class JBossWSClientAuthContext implements ClientAuthContext {
- private List<ClientAuthModule> modules = new
ArrayList<ClientAuthModule>();
+ private final List<ClientAuthModule> modules;
@SuppressWarnings("rawtypes")
- private Map<String, Map> moduleOptionsByName = new HashMap<String,
Map>();
+ private final Map<String, Map> moduleOptionsByName;
protected List<ControlFlag> controlFlags = new ArrayList<ControlFlag>();
@SuppressWarnings("rawtypes")
Modified:
stack/cxf/branches/jaspi/modules/jaspi/src/main/java/org/jboss/wsf/stack/cxf/jaspi/config/JBossWSServerAuthConfig.java
===================================================================
---
stack/cxf/branches/jaspi/modules/jaspi/src/main/java/org/jboss/wsf/stack/cxf/jaspi/config/JBossWSServerAuthConfig.java 2014-02-12
10:18:01 UTC (rev 18339)
+++
stack/cxf/branches/jaspi/modules/jaspi/src/main/java/org/jboss/wsf/stack/cxf/jaspi/config/JBossWSServerAuthConfig.java 2014-02-12
13:18:39 UTC (rev 18340)
@@ -56,9 +56,9 @@
* @author <a href="ema(a)redhat.com">Jim Ma</a>
*/
public class JBossWSServerAuthConfig extends JBossServerAuthConfig {
- private CallbackHandler callbackHandler = new JBossCallbackHandler();
+ private final CallbackHandler callbackHandler = new JBossCallbackHandler();
@SuppressWarnings("rawtypes")
- private List modules = new ArrayList();
+ private final List modules = new ArrayList();
@SuppressWarnings("rawtypes")
public JBossWSServerAuthConfig(String layer, String appContext,
Modified:
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
===================================================================
---
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2014-02-12
10:18:01 UTC (rev 18339)
+++
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2014-02-12
13:18:39 UTC (rev 18340)
@@ -24,8 +24,14 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.Map.Entry;
+import javax.security.auth.message.config.AuthConfigFactory;
+import javax.security.auth.message.config.AuthConfigProvider;
+import javax.security.auth.message.config.ServerAuthConfig;
+import javax.security.auth.message.config.ServerAuthContext;
+
import org.apache.cxf.Bus;
import org.apache.cxf.buslifecycle.BusLifeCycleListener;
import org.apache.cxf.buslifecycle.BusLifeCycleManager;
@@ -48,6 +54,12 @@
import org.apache.cxf.ws.policy.AlternativeSelector;
import org.apache.cxf.ws.policy.PolicyEngine;
import org.apache.cxf.ws.policy.selector.MaximalAlternativeSelector;
+import org.jboss.security.auth.callback.JBossCallbackHandler;
+import org.jboss.security.auth.login.AuthenticationInfo;
+import org.jboss.security.auth.login.BaseAuthenticationInfo;
+import org.jboss.security.auth.login.JASPIAuthenticationInfo;
+import org.jboss.security.config.ApplicationPolicy;
+import org.jboss.security.config.SecurityConfiguration;
import org.jboss.ws.api.annotation.PolicySets;
import org.jboss.ws.api.binding.BindingCustomization;
import org.jboss.wsf.spi.deployment.AnnotationsInfo;
@@ -55,6 +67,7 @@
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
import org.jboss.wsf.spi.metadata.webservices.JBossWebservicesMetaData;
+import org.jboss.wsf.stack.cxf.Loggers;
import org.jboss.wsf.stack.cxf.client.Constants;
import org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher;
import org.jboss.wsf.stack.cxf.extensions.policy.PolicySetsAnnotationListener;
@@ -65,6 +78,8 @@
import org.jboss.wsf.stack.cxf.interceptor.JaspiSeverOutInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.NsCtxSelectorStoreInterceptor;
import org.jboss.wsf.stack.cxf.jaspi.JaspiServerAuthenticator;
+import org.jboss.wsf.stack.cxf.jaspi.config.JBossWSAuthConfigProvider;
+import org.jboss.wsf.stack.cxf.jaspi.config.JBossWSAuthConstants;
import org.jboss.wsf.stack.cxf.management.InstrumentationManagerExtImpl;
import org.jboss.wsf.stack.cxf.transport.JBossWSDestinationRegistryImpl;
@@ -103,8 +118,7 @@
* @param wsmd The current JBossWebservicesMetaData, if any
* @param dep The current deployment
*/
- public void configure(ResourceResolver resolver, Configurer configurer,
JBossWebservicesMetaData wsmd, Deployment dep, JaspiServerAuthenticator authenticator)
-
+ public void configure(ResourceResolver resolver, Configurer configurer,
JBossWebservicesMetaData wsmd, Deployment dep)
{
bus.setProperty(org.jboss.wsf.stack.cxf.client.Constants.DEPLOYMENT_BUS, true);
busHolderListener = new BusHolderLifeCycleListener();
@@ -118,6 +132,7 @@
setInterceptors(bus, props);
+ final JaspiServerAuthenticator authenticator = getJaspiAuthenticator(dep, wsmd);
if (authenticator != null) {
bus.getInInterceptors().add(new JaspiSeverInInterceptor(authenticator));
bus.getOutInterceptors().add(new JaspiSeverOutInterceptor(authenticator));
@@ -291,6 +306,52 @@
return selector;
}
+ private JaspiServerAuthenticator getJaspiAuthenticator(Deployment dep,
JBossWebservicesMetaData wsmd) {
+ String securityDomain = null;
+ if (wsmd != null) {
+ securityDomain =
wsmd.getProperty(JaspiServerAuthenticator.JASPI_SECURITY_DOMAIN);
+ }
+ if (securityDomain == null) {
+ return null;
+ }
+ ApplicationPolicy appPolicy =
SecurityConfiguration.getApplicationPolicy(securityDomain);
+ if (appPolicy == null) {
+ Loggers.ROOT_LOGGER.noApplicationPolicy(securityDomain);
+ return null;
+ }
+ BaseAuthenticationInfo bai = appPolicy.getAuthenticationInfo();
+ if (bai == null || bai instanceof AuthenticationInfo) {
+ Loggers.ROOT_LOGGER.noJaspiApplicationPolicy(securityDomain);
+ return null;
+ }
+ JASPIAuthenticationInfo jai = (JASPIAuthenticationInfo) bai;
+
+ String contextRoot = dep.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();
+ 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(Bus.class, bus);
+ String authContextID = dep.getSimpleName();
+ ServerAuthContext sctx = serverConfig.getAuthContext(authContextID, null,
serverContextProperties);
+ return new JaspiServerAuthenticator(sctx);
+ }
+ catch (Exception e)
+ {
+ Loggers.DEPLOYMENT_LOGGER.cannotCreateServerAuthContext(securityDomain, e);
+ }
+ return null;
+ }
+
private static AutomaticWorkQueue createWorkQueue(String name, Map<String,
String> props) {
int mqs = parseInt(props.get(Constants.CXF_QUEUE_MAX_QUEUE_SIZE_PROP), 256);
int initialThreads = parseInt(props.get(Constants.CXF_QUEUE_INITIAL_THREADS_PROP),
0);
Modified:
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java
===================================================================
---
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java 2014-02-12
10:18:01 UTC (rev 18339)
+++
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java 2014-02-12
13:18:39 UTC (rev 18340)
@@ -46,7 +46,6 @@
import org.jboss.wsf.stack.cxf.client.configuration.JBossWSNonSpringConfigurer;
import org.jboss.wsf.stack.cxf.deployment.EndpointImpl;
import org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher;
-import org.jboss.wsf.stack.cxf.jaspi.JaspiServerAuthenticator;
import org.jboss.wsf.stack.cxf.metadata.services.DDBeans;
import org.jboss.wsf.stack.cxf.metadata.services.DDEndpoint;
@@ -85,13 +84,13 @@
*/
@Override
- public void configure(ResourceResolver resolver, Configurer configurer,
JBossWebservicesMetaData wsmd, Deployment dep, JaspiServerAuthenticator authenticator)
+ public void configure(ResourceResolver resolver, Configurer configurer,
JBossWebservicesMetaData wsmd, Deployment dep)
{
if (configured)
{
throw Messages.MESSAGES.busAlreadyConfigured(bus);
}
- super.configure(resolver, configurer, wsmd, dep, authenticator);
+ super.configure(resolver, configurer, wsmd, dep);
for (DDEndpoint dde : metadata.getEndpoints())
Modified:
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/ServerBeanCustomizer.java
===================================================================
---
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/ServerBeanCustomizer.java 2014-02-12
10:18:01 UTC (rev 18339)
+++
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/ServerBeanCustomizer.java 2014-02-12
13:18:39 UTC (rev 18340)
@@ -176,11 +176,7 @@
}
}
- if (endpoint.getProperties().get(JaspiServerAuthenticator.JASPI_SECURITY_DOMAIN)
!= null) {
- String jaspiSecurityDomain =
(String)endpoint.getProperties().get(JaspiServerAuthenticator.JASPI_SECURITY_DOMAIN);
- addJaspiInterceptor(endpoint, jaspiSecurityDomain);
- }
-
+ addJaspiInterceptors(endpoint);
}
}
@@ -216,8 +212,8 @@
this.epConfigFile = epConfigFile;
}
-
- private void addJaspiInterceptor(EndpointImpl endpoint, String securityDomain) {
+ private void addJaspiInterceptors(EndpointImpl endpoint) {
+ String securityDomain =
(String)endpoint.getProperties().get(JaspiServerAuthenticator.JASPI_SECURITY_DOMAIN);
if (securityDomain == null) {
return;
}
@@ -256,7 +252,7 @@
}
catch (Exception e)
{
- Loggers.DEPLOYMENT_LOGGER.cannotCreateServerAuthContext(securityDomain);
+ Loggers.DEPLOYMENT_LOGGER.cannotCreateServerAuthContext(securityDomain, e);
}
}
Modified:
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java
===================================================================
---
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java 2014-02-12
10:18:01 UTC (rev 18339)
+++
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java 2014-02-12
13:18:39 UTC (rev 18340)
@@ -46,7 +46,6 @@
import org.jboss.wsf.stack.cxf.client.configuration.JBossWSSpringBusFactory;
import org.jboss.wsf.stack.cxf.client.configuration.JBossWSSpringConfigurer;
import org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher;
-import org.jboss.wsf.stack.cxf.jaspi.JaspiServerAuthenticator;
import org.jboss.wsf.stack.cxf.spring.handler.NamespaceHandlerResolver;
import
org.jboss.wsf.stack.cxf.spring.parser.JaxwsEndpointDefinitionParser.JBossWSSpringEndpointImpl;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
@@ -126,15 +125,14 @@
* @param dep The current deployment
*/
@Override
- public void configure(ResourceResolver resolver, Configurer configurer,
JBossWebservicesMetaData wsmd, Deployment dep, JaspiServerAuthenticator authenticator)
-
+ public void configure(ResourceResolver resolver, Configurer configurer,
JBossWebservicesMetaData wsmd, Deployment dep)
{
if (configured)
{
throw MESSAGES.busAlreadyConfigured(ctx);
}
- super.configure(resolver, configurer, wsmd, dep, authenticator);
+ super.configure(resolver, configurer, wsmd, dep);
GenericApplicationContext jbosswsCxfContext = null;
//load stuff from provided jbossws-cxf.xml DD
Modified:
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java
===================================================================
---
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java 2014-02-12
10:18:01 UTC (rev 18339)
+++
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java 2014-02-12
13:18:39 UTC (rev 18340)
@@ -24,23 +24,11 @@
import java.io.IOException;
import java.net.URL;
import java.util.Map;
-import java.util.Properties;
-import javax.security.auth.message.config.AuthConfigFactory;
-import javax.security.auth.message.config.AuthConfigProvider;
-import javax.security.auth.message.config.ServerAuthConfig;
-import javax.security.auth.message.config.ServerAuthContext;
import javax.xml.ws.spi.Provider;
-import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.configuration.Configurer;
-import org.jboss.security.auth.callback.JBossCallbackHandler;
-import org.jboss.security.auth.login.AuthenticationInfo;
-import org.jboss.security.auth.login.BaseAuthenticationInfo;
-import org.jboss.security.auth.login.JASPIAuthenticationInfo;
-import org.jboss.security.config.ApplicationPolicy;
-import org.jboss.security.config.SecurityConfiguration;
import org.jboss.ws.api.binding.BindingCustomization;
import org.jboss.ws.common.integration.AbstractDeploymentAspect;
import org.jboss.ws.common.integration.WSConstants;
@@ -51,15 +39,11 @@
import org.jboss.wsf.spi.deployment.ResourceResolver;
import org.jboss.wsf.spi.metadata.j2ee.JSEArchiveMetaData;
import org.jboss.wsf.spi.metadata.webservices.JBossWebservicesMetaData;
-import org.jboss.wsf.stack.cxf.Loggers;
import org.jboss.wsf.stack.cxf.client.configuration.JBossWSBusFactory;
import org.jboss.wsf.stack.cxf.configuration.BusHolder;
import org.jboss.wsf.stack.cxf.configuration.NonSpringBusHolder;
import org.jboss.wsf.stack.cxf.configuration.SpringBusHolder;
import org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher;
-import org.jboss.wsf.stack.cxf.jaspi.JaspiServerAuthenticator;
-import org.jboss.wsf.stack.cxf.jaspi.config.JBossWSAuthConfigProvider;
-import org.jboss.wsf.stack.cxf.jaspi.config.JBossWSAuthConstants;
import org.jboss.wsf.stack.cxf.metadata.services.DDBeans;
import org.jboss.wsf.stack.cxf.resolver.JBossWSResourceResolver;
@@ -147,11 +131,9 @@
epConfigFile = wsmd.getConfigFile();
}
- JaspiServerAuthenticator jaspiAuthenticator = getJaspiAuthenticator(dep, wsmd,
holder.getBus());
-
Configurer configurer =
holder.createServerConfigurer(dep.getAttachment(BindingCustomization.class),
new WSDLFilePublisher(aDep), dep.getService().getEndpoints(),
aDep.getRootFile(), epConfigName, epConfigFile);
- holder.configure(resolver, configurer, wsmd, dep, jaspiAuthenticator);
+ holder.configure(resolver, configurer, wsmd, dep);
dep.addAttachment(BusHolder.class, holder);
if (holder instanceof SpringBusHolder)
@@ -168,56 +150,7 @@
SecurityActions.setContextClassLoader(origClassLoader);
}
}
-
- private JaspiServerAuthenticator getJaspiAuthenticator(Deployment dep,
JBossWebservicesMetaData wsmd, Bus bus) {
- String securityDomain = null;
- if (wsmd != null) {
- securityDomain =
wsmd.getProperty(JaspiServerAuthenticator.JASPI_SECURITY_DOMAIN);
- }
- if (securityDomain == null) {
- return null;
- }
- ApplicationPolicy appPolicy =
SecurityConfiguration.getApplicationPolicy(securityDomain);
- if (appPolicy == null) {
- Loggers.ROOT_LOGGER.noApplicationPolicy(securityDomain);
- return null;
- }
- BaseAuthenticationInfo bai = appPolicy.getAuthenticationInfo();
- if (bai == null || bai instanceof AuthenticationInfo) {
- Loggers.ROOT_LOGGER.noJaspiApplicationPolicy(securityDomain);
- return null;
- }
- JASPIAuthenticationInfo jai = (JASPIAuthenticationInfo) bai;
-
- String contextRoot = dep.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();
- 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(Bus.class, bus);
- String authContextID = dep.getSimpleName();
- ServerAuthContext sctx = serverConfig.getAuthContext(authContextID, null,
serverContextProperties);
- return new JaspiServerAuthenticator(sctx);
- }
- catch (Exception e)
- {
- Loggers.DEPLOYMENT_LOGGER.cannotCreateServerAuthContext(securityDomain);
- }
-
- return null;
-
- }
-
private static URL getResourceUrl(final ResourceResolver resolver, final String
resourcePath)
{
try
Modified:
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/JaspiSeverInInterceptor.java
===================================================================
---
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/JaspiSeverInInterceptor.java 2014-02-12
10:18:01 UTC (rev 18339)
+++
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/JaspiSeverInInterceptor.java 2014-02-12
13:18:39 UTC (rev 18340)
@@ -41,7 +41,8 @@
*/
public class JaspiSeverInInterceptor extends AbstractSoapInterceptor
{
- private JaspiServerAuthenticator authManager;
+ private final JaspiServerAuthenticator authManager;
+
public JaspiSeverInInterceptor(JaspiServerAuthenticator authManager)
{
super(Phase.PRE_PROTOCOL);
Modified:
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/JaspiSeverOutInterceptor.java
===================================================================
---
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/JaspiSeverOutInterceptor.java 2014-02-12
10:18:01 UTC (rev 18339)
+++
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/JaspiSeverOutInterceptor.java 2014-02-12
13:18:39 UTC (rev 18340)
@@ -41,7 +41,7 @@
*/
public class JaspiSeverOutInterceptor extends AbstractSoapInterceptor
{
- private JaspiServerAuthenticator authManager;
+ private final JaspiServerAuthenticator authManager;
private static final SAAJOutInterceptor SAAJ_OUT = new SAAJOutInterceptor();
public JaspiSeverOutInterceptor(JaspiServerAuthenticator authManager)
@@ -91,9 +91,7 @@
return;
}
authManager.secureResponse(message);
-
}
-
}
}
Modified:
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/jaspi/JaspiServerAuthenticator.java
===================================================================
---
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/jaspi/JaspiServerAuthenticator.java 2014-02-12
10:18:01 UTC (rev 18339)
+++
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/jaspi/JaspiServerAuthenticator.java 2014-02-12
13:18:39 UTC (rev 18340)
@@ -45,7 +45,7 @@
*/
public class JaspiServerAuthenticator {
public static final String JASPI_SECURITY_DOMAIN = "jaspi.security.domain";
- private ServerAuthContext sctx;
+ private final ServerAuthContext sctx;
public JaspiServerAuthenticator(ServerAuthContext sctx) {
this.sctx = sctx;
Modified:
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/jaspi/module/UsernameTokenServerAuthModule.java
===================================================================
---
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/jaspi/module/UsernameTokenServerAuthModule.java 2014-02-12
10:18:01 UTC (rev 18339)
+++
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/jaspi/module/UsernameTokenServerAuthModule.java 2014-02-12
13:18:39 UTC (rev 18340)
@@ -42,19 +42,17 @@
*/
public class UsernameTokenServerAuthModule extends AbstractServerAuthModule
{
- private String securityDomainName = null;
- private javax.xml.ws.Endpoint endpoint = null;
- private Bus bus = null;
- private InterceptorProvider ip = null;
+ private final String securityDomainName;
@SuppressWarnings("rawtypes")
public void initialize(MessagePolicy requestPolicy, MessagePolicy responsePolicy,
CallbackHandler handler, Map options) throws AuthException
{
super.initialize(requestPolicy, responsePolicy, handler, options);
- endpoint = (javax.xml.ws.Endpoint)options.get(javax.xml.ws.Endpoint.class);
+ final javax.xml.ws.Endpoint endpoint =
(javax.xml.ws.Endpoint)options.get(javax.xml.ws.Endpoint.class);
+ InterceptorProvider ip = null;
if (endpoint == null && options.get(Bus.class) != null)
{
- bus = (Bus)options.get(Bus.class);
+ final Bus bus = (Bus)options.get(Bus.class);
bus.setProperty(SecurityConstants.VALIDATE_TOKEN, false);
ip = (InterceptorProvider)bus;
}
@@ -74,6 +72,7 @@
{
supportedTypes.add(Object.class);
supportedTypes.add(SOAPMessage.class);
+ securityDomainName = null;
}
public UsernameTokenServerAuthModule(String lmshName)
Modified:
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/JaspiSubjectCreatingInterceptor.java
===================================================================
---
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/JaspiSubjectCreatingInterceptor.java 2014-02-12
10:18:01 UTC (rev 18339)
+++
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/JaspiSubjectCreatingInterceptor.java 2014-02-12
13:18:39 UTC (rev 18340)
@@ -13,14 +13,12 @@
import org.apache.ws.security.WSUsernameTokenPrincipal;
import org.jboss.security.auth.callback.JBossCallbackHandler;
import org.jboss.security.plugins.JBossAuthenticationManager;
-import org.jboss.wsf.spi.deployment.Endpoint;
-import org.jboss.wsf.spi.security.SecurityDomainContext;
import org.jboss.wsf.stack.cxf.Loggers;
import org.jboss.wsf.stack.cxf.Messages;
public class JaspiSubjectCreatingInterceptor extends SubjectCreatingPolicyInterceptor
{
- private JBossAuthenticationManager authenticationManger;
+ private final JBossAuthenticationManager authenticationManger;
public JaspiSubjectCreatingInterceptor(String securityDomain) {
super();
@@ -31,8 +29,6 @@
@Override
public void handleMessage(Message message) throws Fault
{
- Endpoint ep = message.getExchange().get(Endpoint.class);
- SecurityDomainContext sdc = ep.getSecurityDomainContext();
SecurityContext context = message.get(SecurityContext.class);
if (context == null || context.getUserPrincipal() == null)
{
@@ -50,7 +46,7 @@
throw Messages.MESSAGES.unsupportedTokenType(token.getTokenType());
}
UsernameToken ut = (UsernameToken) token;
- subject = helper.createSubject(authenticationManger,ut.getName(),
ut.getPassword(), ut.isHashed(), ut.getNonce(), ut.getCreatedTime());
+ subject = helper.createSubject(authenticationManger, ut.getName(),
ut.getPassword(), ut.isHashed(), ut.getNonce(), ut.getCreatedTime());
}
else
@@ -61,7 +57,7 @@
throw Messages.MESSAGES.couldNotGetSubjectInfo();
}
WSUsernameTokenPrincipal up = (WSUsernameTokenPrincipal) p;
- subject = createSubject(sdc, up.getName(), up.getPassword(),
up.isPasswordDigest(), up.getNonce(), up.getCreatedTime());
+ subject = helper.createSubject(authenticationManger, up.getName(),
up.getPassword(), up.isPasswordDigest(), up.getNonce(), up.getCreatedTime());
}
Principal principal = getPrincipal(context.getUserPrincipal(), subject);
Modified:
stack/cxf/branches/jaspi/modules/server/src/test/java/org/jboss/wsf/stack/cxf/configuration/BusHolderTest.java
===================================================================
---
stack/cxf/branches/jaspi/modules/server/src/test/java/org/jboss/wsf/stack/cxf/configuration/BusHolderTest.java 2014-02-12
10:18:01 UTC (rev 18339)
+++
stack/cxf/branches/jaspi/modules/server/src/test/java/org/jboss/wsf/stack/cxf/configuration/BusHolderTest.java 2014-02-12
13:18:39 UTC (rev 18340)
@@ -69,7 +69,7 @@
}
BusHolder holder = new NonSpringBusHolder(new DDBeans());
try {
- holder.configure(null, null, wsmd, new
DefaultDeploymentModelFactory().newDeployment("testDeployment", null), null);
+ holder.configure(null, null, wsmd, new
DefaultDeploymentModelFactory().newDeployment("testDeployment", null));
return
holder.getBus().getExtension(PolicyEngine.class).getAlternativeSelector().getClass().getName();
} finally {
holder.close();
Modified:
stack/cxf/branches/jaspi/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/BusHolderLifeCycleTestCase.java
===================================================================
---
stack/cxf/branches/jaspi/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/BusHolderLifeCycleTestCase.java 2014-02-12
10:18:01 UTC (rev 18339)
+++
stack/cxf/branches/jaspi/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/BusHolderLifeCycleTestCase.java 2014-02-12
13:18:39 UTC (rev 18340)
@@ -64,7 +64,7 @@
Bus bus = holder.getBus();
TestLifeCycleListener listener = new TestLifeCycleListener();
bus.getExtension(BusLifeCycleManager.class).registerLifeCycleListener(listener);
- holder.configure(null, null, null, new
DefaultDeploymentModelFactory().newDeployment("testDeployment", null), null);
+ holder.configure(null, null, null, new
DefaultDeploymentModelFactory().newDeployment("testDeployment", null));
holder.close();
assertEquals("preShutdown method on listener should be called exactly once;
number of actual calls: "
+ listener.getCount(), 1, listener.getCount());
@@ -75,7 +75,7 @@
Bus bus = holder.getBus();
TestLifeCycleListener listener = new TestLifeCycleListener();
bus.getExtension(BusLifeCycleManager.class).registerLifeCycleListener(listener);
- holder.configure(null, null, null, new
DefaultDeploymentModelFactory().newDeployment("testDeployment", null), null);
+ holder.configure(null, null, null, new
DefaultDeploymentModelFactory().newDeployment("testDeployment", null));
bus.shutdown(true);
holder.close();
assertEquals("preShutdown method on listener should be called exactly once;
number of actual calls: "
@@ -87,7 +87,7 @@
Bus bus = holder.getBus();
TestLifeCycleListener listener = new TestLifeCycleListener();
bus.getExtension(BusLifeCycleManager.class).registerLifeCycleListener(listener);
- holder.configure(null, null, null, new
DefaultDeploymentModelFactory().newDeployment("testDeployment", null), null);
+ holder.configure(null, null, null, new
DefaultDeploymentModelFactory().newDeployment("testDeployment", null));
assertEquals("preShutdown method on listener shouldn't be called before
holder is closed: number of actual calls: "
+ listener.getCount(), 0, listener.getCount());
holder.close();