Repository: cxf Updated Branches: refs/heads/3.0.x-fixes 0ebebdf58 -> 0650df652
[CXF-6508] Checking the existing security context if allowNamedPrincipals is not disabled Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/0650df65 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/0650df65 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/0650df65 Branch: refs/heads/3.0.x-fixes Commit: 0650df652c10de80c958e959ba32b9e87fa15dad Parents: 0ebebdf Author: Sergey Beryozkin <[email protected]> Authored: Fri Jul 24 11:33:40 2015 +0300 Committer: Sergey Beryozkin <[email protected]> Committed: Fri Jul 24 11:51:40 2015 +0300 ---------------------------------------------------------------------- .../interceptor/security/JAASLoginInterceptor.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/0650df65/core/src/main/java/org/apache/cxf/interceptor/security/JAASLoginInterceptor.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/cxf/interceptor/security/JAASLoginInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/security/JAASLoginInterceptor.java index 24c7bf2..a17b096 100644 --- a/core/src/main/java/org/apache/cxf/interceptor/security/JAASLoginInterceptor.java +++ b/core/src/main/java/org/apache/cxf/interceptor/security/JAASLoginInterceptor.java @@ -51,7 +51,7 @@ public class JAASLoginInterceptor extends AbstractPhaseInterceptor<Message> { private String roleClassifierType = ROLE_CLASSIFIER_PREFIX; private boolean reportFault; private boolean useDoAs = true; - + private boolean allowNamedPrincipals = true; public JAASLoginInterceptor() { super(Phase.UNMARSHAL); @@ -103,7 +103,14 @@ public class JAASLoginInterceptor extends AbstractPhaseInterceptor<Message> { } public void handleMessage(final Message message) throws Fault { - + if (allowNamedPrincipals) { + SecurityContext sc = message.get(SecurityContext.class); + if (sc != null && sc.getUserPrincipal() != null + && sc.getUserPrincipal().getName() != null) { + return; + } + } + String name = null; String password = null; @@ -182,5 +189,8 @@ public class JAASLoginInterceptor extends AbstractPhaseInterceptor<Message> { this.loginConfig = loginConfig; } - + public void setAllowNamedPrincipals(boolean allowNamedPrincipals) { + this.allowNamedPrincipals = allowNamedPrincipals; + } + }
