Repository: camel Updated Branches: refs/heads/master 91a8b64a6 -> 312c229a8
CAMEL-10830: Race condition when reading principal for one-way web services Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/312c229a Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/312c229a Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/312c229a Branch: refs/heads/master Commit: 312c229a8e251e07c9fb3e023a63e20af71ef98f Parents: 91a8b64 Author: Stephan Siano <stephan.si...@sap.com> Authored: Wed Feb 15 08:51:26 2017 +0100 Committer: Stephan Siano <stephan.si...@sap.com> Committed: Wed Feb 15 08:51:26 2017 +0100 ---------------------------------------------------------------------- .../apache/camel/component/cxf/DefaultCxfBinding.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/312c229a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java index 7f04fe1..4342e28c 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java @@ -21,6 +21,7 @@ import java.io.Reader; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.nio.charset.Charset; +import java.security.Principal; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -269,10 +270,13 @@ public class DefaultCxfBinding implements CxfBinding, HeaderFilterStrategyAware && ((LoginSecurityContext)securityContext).getSubject() != null) { camelExchange.getIn().getHeaders().put(Exchange.AUTHENTICATION, ((LoginSecurityContext)securityContext).getSubject()); - } else if (securityContext != null && securityContext.getUserPrincipal() != null) { - Subject subject = new Subject(); - subject.getPrincipals().add(securityContext.getUserPrincipal()); - camelExchange.getIn().getHeaders().put(Exchange.AUTHENTICATION, subject); + } else if (securityContext != null) { + Principal user = securityContext.getUserPrincipal(); + if (user != null) { + Subject subject = new Subject(); + subject.getPrincipals().add(user); + camelExchange.getIn().getHeaders().put(Exchange.AUTHENTICATION, subject); + } } // Propagating properties from CXF Exchange to Camel Exchange has an