Author: jim.ma
Date: 2014-01-02 04:21:00 -0500 (Thu, 02 Jan 2014)
New Revision: 18217
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/ServerBeanCustomizer.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/module/UsernameTokenServerAuthModule.java
stack/cxf/branches/jaspi/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaspi/JaspiAuthenticationTestCase.java
Log:
Support secureResponse in ServerAuthModule
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 2013-12-20
01:32:43 UTC (rev 18216)
+++
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2014-01-02
09:21:00 UTC (rev 18217)
@@ -58,6 +58,7 @@
import org.jboss.wsf.stack.cxf.interceptor.EndpointAssociationInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.HandlerAuthInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.JaspiSeverInInterceptor;
+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.management.InstrumentationManagerExtImpl;
@@ -113,6 +114,7 @@
if (authenticator != null) {
bus.getInInterceptors().add(new JaspiSeverInInterceptor(authenticator));
+ bus.getOutInterceptors().add(new JaspiSeverOutInterceptor(authenticator));
}
setResourceResolver(bus, resolver);
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 2013-12-20
01:32:43 UTC (rev 18216)
+++
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/ServerBeanCustomizer.java 2014-01-02
09:21:00 UTC (rev 18217)
@@ -51,6 +51,7 @@
import org.jboss.wsf.stack.cxf.deployment.EndpointImpl;
import org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher;
import org.jboss.wsf.stack.cxf.interceptor.JaspiSeverInInterceptor;
+import org.jboss.wsf.stack.cxf.interceptor.JaspiSeverOutInterceptor;
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;
@@ -176,7 +177,7 @@
}
}
- if (endpoint.getProperties().get(JaspiServerAuthenticator.JASPI_SECURITY_DOMAIN)
!=null) {
+ if (endpoint.getProperties().get(JaspiServerAuthenticator.JASPI_SECURITY_DOMAIN)
!= null) {
String jaspiSecurityDomain =
(String)endpoint.getProperties().get(JaspiServerAuthenticator.JASPI_SECURITY_DOMAIN);
addJaspiInterceptor(endpoint, jaspiSecurityDomain);
}
@@ -245,6 +246,7 @@
ServerAuthContext sctx = serverConfig.getAuthContext(authContextID, null,
serverContextProperties);
serverAuthenticator = new JaspiServerAuthenticator(sctx);
endpoint.getInInterceptors().add(new
JaspiSeverInInterceptor(serverAuthenticator));
+ endpoint.getOutInterceptors().add(new
JaspiSeverOutInterceptor(serverAuthenticator));
}
catch (Exception e)
{
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 2013-12-20
01:32:43 UTC (rev 18216)
+++
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/JaspiSeverOutInterceptor.java 2014-01-02
09:21:00 UTC (rev 18217)
@@ -21,37 +21,79 @@
*/
package org.jboss.wsf.stack.cxf.interceptor;
+import java.util.ListIterator;
+
import javax.xml.soap.SOAPMessage;
import org.apache.cxf.binding.soap.SoapMessage;
import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
+import org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor;
import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.interceptor.StaxOutInterceptor;
+import org.apache.cxf.message.Message;
import org.apache.cxf.phase.Phase;
import org.jboss.wsf.stack.cxf.jaspi.JaspiServerAuthenticator;
+
/**
* @author <a href="ema(a)redhat.com">Jim Ma</a>
*/
public class JaspiSeverOutInterceptor extends AbstractSoapInterceptor
{
private JaspiServerAuthenticator authManager;
+ private static final SAAJOutInterceptor SAAJ_OUT = new SAAJOutInterceptor();
+
public JaspiSeverOutInterceptor(JaspiServerAuthenticator authManager)
{
- super(Phase.POST_PROTOCOL_ENDING);
- addAfter(SAAJOutInterceptor.SAAJOutEndingInterceptor.class.getName());
+ super(Phase.PRE_STREAM);
+ addAfter(StaxOutInterceptor.class.getName());
this.authManager = authManager;
}
@Override
public void handleMessage(SoapMessage message) throws Fault
{
+ if (!chainAlreadyContainsSAAJ(message))
+ {
+ SAAJ_OUT.handleMessage(message);
+ }
+ message.getInterceptorChain().add(new JaspiServerOutEndingInterceptor());
- if (message.getContent(SOAPMessage.class) == null)
+ }
+
+ private static boolean chainAlreadyContainsSAAJ(SoapMessage message)
+ {
+ ListIterator<Interceptor<? extends Message>> listIterator =
message.getInterceptorChain().getIterator();
+ while (listIterator.hasNext())
{
- SAAJOutInterceptor saajout = new SAAJOutInterceptor();
- saajout.handleMessage(message);
+ if (listIterator.next() instanceof SAAJOutInterceptor)
+ {
+ return true;
+ }
}
- authManager.secureResponse(message);
+ return false;
}
+ public class JaspiServerOutEndingInterceptor extends AbstractSoapInterceptor
+ {
+ public JaspiServerOutEndingInterceptor()
+ {
+ super(Phase.WRITE_ENDING);
+ addAfter(SoapOutInterceptor.SoapOutEndingInterceptor.class.getName());
+ }
+
+ @Override
+ public void handleMessage(SoapMessage message) throws Fault
+ {
+ if (message.getContent(SOAPMessage.class) == null)
+ {
+ return;
+ }
+ authManager.secureResponse(message);
+
+ }
+
+ }
+
}
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 2013-12-20
01:32:43 UTC (rev 18216)
+++
stack/cxf/branches/jaspi/modules/server/src/main/java/org/jboss/wsf/stack/cxf/jaspi/module/UsernameTokenServerAuthModule.java 2014-01-02
09:21:00 UTC (rev 18217)
@@ -89,9 +89,9 @@
return AuthStatus.SUCCESS;
}
- public AuthStatus secureResponse(MessageInfo arg0, Subject arg1) throws AuthException
+ public AuthStatus secureResponse(MessageInfo messageInfo, Subject arg1) throws
AuthException
{
- throw new UnsupportedOperationException();
+ return AuthStatus.SUCCESS;
}
protected String getSecurityDomainName()
Modified:
stack/cxf/branches/jaspi/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaspi/JaspiAuthenticationTestCase.java
===================================================================
---
stack/cxf/branches/jaspi/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaspi/JaspiAuthenticationTestCase.java 2013-12-20
01:32:43 UTC (rev 18216)
+++
stack/cxf/branches/jaspi/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaspi/JaspiAuthenticationTestCase.java 2014-01-02
09:21:00 UTC (rev 18217)
@@ -61,7 +61,6 @@
}
Map<String, String> authModuleOptions = new HashMap<String,
String>();
- //authModuleOptions.put("action", "UsernameToken
Timestamp");
JBossWSTestHelper.addJaspiSecurityDomain("jaspi",
"jaas-lm-stack", loginModuleOptions,
"org.jboss.wsf.stack.cxf.jaspi.module.UsernameTokenServerAuthModule",
authModuleOptions);
super.setUp();
@@ -106,7 +105,7 @@
}
private void setupWsse(ServiceIface proxy, String username)
- {
+ {
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.USERNAME,
username);
((BindingProvider)proxy).getRequestContext()
.put(SecurityConstants.CALLBACK_HANDLER,
"org.jboss.test.ws.jaxws.samples.wsse.policy.jaspi.UsernamePasswordCallback");