You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2015/07/20 23:21:23 UTC

[3/4] cxf git commit: Fixing backmerge

Fixing backmerge


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/08611f8a
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/08611f8a
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/08611f8a

Branch: refs/heads/2.7.x-fixes
Commit: 08611f8a12985d5a82ff6827f62212f32a840601
Parents: 8e5a728
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Mon Jul 20 21:53:23 2015 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Mon Jul 20 21:53:23 2015 +0100

----------------------------------------------------------------------
 .../security/SAMLSecurityContext.java           |  15 ++-
 .../rt/security/saml/SAMLSecurityContext.java   | 113 -------------------
 2 files changed, 12 insertions(+), 116 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/08611f8a/rt/core/src/main/java/org/apache/cxf/interceptor/security/SAMLSecurityContext.java
----------------------------------------------------------------------
diff --git a/rt/core/src/main/java/org/apache/cxf/interceptor/security/SAMLSecurityContext.java b/rt/core/src/main/java/org/apache/cxf/interceptor/security/SAMLSecurityContext.java
index a8e0709..2560fed 100644
--- a/rt/core/src/main/java/org/apache/cxf/interceptor/security/SAMLSecurityContext.java
+++ b/rt/core/src/main/java/org/apache/cxf/interceptor/security/SAMLSecurityContext.java
@@ -19,6 +19,8 @@
 package org.apache.cxf.interceptor.security;
 
 import java.security.Principal;
+import java.util.Collections;
+import java.util.HashSet;
 import java.util.Set;
 
 import org.w3c.dom.Element;
@@ -33,7 +35,7 @@ public class SAMLSecurityContext implements LoginSecurityContext {
     private String issuer;
     
     public SAMLSecurityContext(Principal principal) {
-        this.principal = principal;
+        this(principal, null);
     }
     
     public SAMLSecurityContext(
@@ -53,7 +55,7 @@ public class SAMLSecurityContext implements LoginSecurityContext {
             return false;
         }
         for (Principal principalRole : roles) {
-            if (principalRole.getName().equals(role)) {
+            if (principalRole != principal && principalRole.getName().equals(role)) {
                 return true;
             }
         }
@@ -69,7 +71,14 @@ public class SAMLSecurityContext implements LoginSecurityContext {
     }
     
     public Set<Principal> getUserRoles() {
-        return roles;
+        if (roles == null) {
+            return Collections.emptySet();
+        }
+        Set<Principal> retRoles = new HashSet<Principal>(roles);
+        if (principal != null && retRoles.contains(principal)) {
+            retRoles.remove(principal);
+        }
+        return retRoles;
     }
     
     public void setAssertionElement(Element assertionElement) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/08611f8a/rt/security/src/main/java/org/apache/cxf/rt/security/saml/SAMLSecurityContext.java
----------------------------------------------------------------------
diff --git a/rt/security/src/main/java/org/apache/cxf/rt/security/saml/SAMLSecurityContext.java b/rt/security/src/main/java/org/apache/cxf/rt/security/saml/SAMLSecurityContext.java
deleted file mode 100644
index 2784a18..0000000
--- a/rt/security/src/main/java/org/apache/cxf/rt/security/saml/SAMLSecurityContext.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.rt.security.saml;
-
-import java.security.Principal;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.w3c.dom.Element;
-import org.apache.cxf.rt.security.claims.ClaimCollection;
-import org.apache.cxf.rt.security.claims.ClaimsSecurityContext;
-
-public class SAMLSecurityContext implements ClaimsSecurityContext {
-    
-    private final Principal principal;
-    private Set<Principal> roles;
-    private Element assertionElement;
-    private String issuer;
-    private ClaimCollection claims;
-    
-    public SAMLSecurityContext(Principal principal) {
-        this(principal, null);
-    }
-    
-    public SAMLSecurityContext(
-        Principal principal, 
-        Set<Principal> roles
-    ) {
-        this(principal, roles, null);
-    }
-    
-    public SAMLSecurityContext(
-        Principal principal, 
-        Set<Principal> roles,
-        ClaimCollection claims
-    ) {
-        this.principal = principal;
-        this.roles = roles;
-        this.claims = claims;
-    }
-    
-    public ClaimCollection getClaims() {
-        return claims;
-    }
-    
-    public Principal getUserPrincipal() {
-        return principal;
-    }
-
-    public boolean isUserInRole(String role) {
-        if (roles == null) {
-            return false;
-        }
-        for (Principal principalRole : roles) {
-            if (principalRole != principal && principalRole.getName().equals(role)) {
-                return true;
-            }
-        }
-        return false;
-    }
-    
-    public javax.security.auth.Subject getSubject() {
-        return null;
-    }
-
-    public void setUserRoles(Set<Principal> userRoles) {
-        this.roles = userRoles;
-    }
-    
-    public Set<Principal> getUserRoles() {
-        if (roles == null) {
-            return Collections.emptySet();
-        }
-        Set<Principal> retRoles = new HashSet<Principal>(roles);
-        if (principal != null && retRoles.contains(principal)) {
-            retRoles.remove(principal);
-        }
-        return retRoles;
-    }
-    
-    public void setAssertionElement(Element assertionElement) {
-        this.assertionElement = assertionElement;
-    }
-    
-    public Element getAssertionElement() {
-        return assertionElement;
-    }
-    
-    public void setIssuer(String issuer) {
-        this.issuer = issuer;
-    }
-    
-    public String getIssuer() {
-        return issuer;
-    }
-}