Skip to content

Commit

Permalink
[JBWS-4430]:Rename HandlerAuthInterceptor to HandlerConfigInterceptor…
Browse files Browse the repository at this point in the history
…;Improve comment and test
  • Loading branch information
jimma committed Nov 1, 2024
1 parent 68f1334 commit 5996d34
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
import org.jboss.wsf.stack.cxf.i18n.Messages;
import org.jboss.wsf.stack.cxf.interceptor.EndpointAssociationInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.GracefulShutdownInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.HandlerAuthInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.HandlerConfigInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.NsCtxSelectorStoreInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.WSDLSoapAddressRewriteInterceptor;
import org.jboss.wsf.stack.cxf.management.InstrumentationManagerExtImpl;
Expand Down Expand Up @@ -366,9 +366,9 @@ protected void setInterceptors(Bus bus, Deployment dep, Map<String, String> prop

final String p = (props != null) ? props.get(Constants.JBWS_CXF_DISABLE_HANDLER_AUTH_CHECKS) : null;
if ((p == null || (!"true".equalsIgnoreCase(p) && !"1".equalsIgnoreCase(p))) && !Boolean.getBoolean(Constants.JBWS_CXF_DISABLE_HANDLER_AUTH_CHECKS)) {
bus.getInInterceptors().add(new HandlerAuthInterceptor());
bus.getInInterceptors().add(new HandlerConfigInterceptor());
} else {
bus.getInInterceptors().add(new HandlerAuthInterceptor(true));
bus.getInInterceptors().add(new HandlerConfigInterceptor(true));
}

final SOAPAddressRewriteMetadata sarm = dep.getAttachment(SOAPAddressRewriteMetadata.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,38 +47,39 @@
import org.jboss.wsf.stack.cxf.JAXPDelegateClassLoader;

/**
* Interceptor which checks the current principal is authorized to
* call a given handler
*
* Interceptor that configures a jbossws handler chain and can skip authentication.
* It set {@code JBossWSHandlerChainInvoker} to use correct Thread Context Class Loader
* and perform security checks before invoking the handlers.
* @author [email protected]
* @author [email protected]
* @since 23-Sep-2013
*/
public class HandlerAuthInterceptor extends AbstractPhaseInterceptor<Message>
public class HandlerConfigInterceptor extends AbstractPhaseInterceptor<Message>
{
private static final String KEY = HandlerAuthInterceptor.class.getName() + ".SECURITY_EXCEPTION";
private static final String KEY = HandlerConfigInterceptor.class.getName() + ".SECURITY_EXCEPTION";

private final boolean skip;
public HandlerAuthInterceptor()
private final boolean skipAuth;
public HandlerConfigInterceptor()
{
super(Phase.PRE_PROTOCOL_FRONTEND);
addBefore(SOAPHandlerInterceptor.class.getName());
addBefore(LogicalHandlerInInterceptor.class.getName());
skip = false;
skipAuth = false;
}
/**
* Create a {@code HandlerAuthInterceptor} that can optionally skip authentication.
* Create a {@code HandlerConfigInterceptor} that can optionally skip authentication.
* When the authentication is skipped, it added a customized {@code JBossWSHandlerChainInvoker}
* which set the correct TCCL to allow the handler to access CDI
* Please see
* Please see https://issues.redhat.com/browse/JBWS-4430
* This interceptor will be added to CXF interceptor chain
* @param skipAuth a boolean flag indicating whether to skip authentication.
**/
public HandlerAuthInterceptor(boolean skipAuth)
public HandlerConfigInterceptor(boolean skipAuth)
{
super(Phase.PRE_PROTOCOL_FRONTEND);
addBefore(SOAPHandlerInterceptor.class.getName());
addBefore(LogicalHandlerInInterceptor.class.getName());
skip = skipAuth;
this.skipAuth = skipAuth;
}

@Override
Expand All @@ -94,7 +95,7 @@ public void handleMessage(Message message) throws Fault
@SuppressWarnings("rawtypes")
final List<Handler> handlerChain = ep.getJaxwsBinding().getHandlerChain();
if (handlerChain != null && !handlerChain.isEmpty()) { //save
invoker = new JBossWSHandlerChainInvoker(handlerChain, isOutbound(message, ex), skip);
invoker = new JBossWSHandlerChainInvoker(handlerChain, isOutbound(message, ex), skipAuth);
ex.put(HandlerChainInvoker.class, invoker);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.Message;
import org.apache.cxf.message.MessageUtils;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
import org.jboss.wsf.stack.cxf.interceptor.AbstractTCCLPhaseInterceptor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class JBWS4430TestCase extends JBossWSTest {
public static WebArchive createDeployment() {
WebArchive archive = ShrinkWrap.create(WebArchive.class, DEP + ".war");
archive.setManifest(new StringAsset("Manifest-Version: 1.0\n"
+ "Dependencies: org.jboss.ws.cxf.jbossws-cxf-server\n"))
+ "Dependencies: org.apache.cxf,org.jboss.ws.cxf.jbossws-cxf-server\n"))
.addClasses(HelloBean.class, DelegateBean.class, EmptyBean.class, CDIOutInterceptor.class, LoggingHandler.class)
.addAsWebInfResource(new File(JBossWSTestHelper.getTestResourcesDir() + "/jaxws/cxf/jbws4430/WEB-INF/wsdl/HelloWorld.wsdl"), "wsdl/HelloWorld.wsdl")
.add(new FileAsset(new File(JBossWSTestHelper.getTestResourcesDir() + "/jaxws/cxf/jbws4430/handlers.xml")), "WEB-INF/classes/handlers.xml")
Expand Down

0 comments on commit 5996d34

Please sign in to comment.