Remove dependency to deprecated Java API.
authorMathieu Baudier <mbaudier@argeo.org>
Sun, 26 Jan 2020 08:11:32 +0000 (09:11 +0100)
committerMathieu Baudier <mbaudier@argeo.org>
Sun, 26 Jan 2020 08:11:32 +0000 (09:11 +0100)
org.argeo.cms/src/org/argeo/cms/auth/CurrentUser.java
org.argeo.cms/src/org/argeo/cms/internal/auth/ImpliedByPrincipal.java

index 34f4457ed446021369a5a51e340bdf9d715cada3..43bddaf8d002a727a9000e93cd056010b8994349 100644 (file)
@@ -20,7 +20,6 @@ import java.security.Principal;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
-import java.security.acl.Group;
 import java.util.HashSet;
 import java.util.Locale;
 import java.util.Set;
@@ -31,6 +30,7 @@ import javax.security.auth.x500.X500Principal;
 
 import org.argeo.cms.CmsException;
 import org.argeo.cms.internal.auth.CmsSessionImpl;
+import org.argeo.cms.internal.auth.ImpliedByPrincipal;
 import org.argeo.cms.internal.kernel.Activator;
 import org.argeo.node.NodeConstants;
 import org.osgi.service.useradmin.Authorization;
@@ -115,7 +115,7 @@ public final class CurrentUser {
        public final static Set<String> roles(Subject subject) {
                Set<String> roles = new HashSet<String>();
                roles.add(getUsername(subject));
-               for (Principal group : subject.getPrincipals(Group.class)) {
+               for (Principal group : subject.getPrincipals(ImpliedByPrincipal.class)) {
                        roles.add(group.getName());
                }
                return roles;
index 6f83a9a28171d4f8d7d8ae3a97f1ca3d03891e87..7386d5fe5fedbf6bb9bacd8377adfd11295a30d5 100644 (file)
@@ -1,7 +1,6 @@
 package org.argeo.cms.internal.auth;
 
 import java.security.Principal;
-import java.security.acl.Group;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashSet;
@@ -15,13 +14,13 @@ import org.osgi.service.useradmin.Authorization;
 
 /**
  * A {@link Principal} which has been implied by an {@link Authorization}. If it
- * is empty it meeans this is an additional identity, otherwise it lists the
+ * is empty it means this is an additional identity, otherwise it lists the
  * users (typically the logged in user but possibly empty
  * {@link ImpliedByPrincipal}s) which have implied it. When an additional
- * identityx is removed, the related {@link ImpliedByPrincipal}s can thus be
+ * identity is removed, the related {@link ImpliedByPrincipal}s can thus be
  * removed.
  */
-public final class ImpliedByPrincipal implements Group {
+public final class ImpliedByPrincipal implements Principal {
        private final LdapName name;
        private Set<Principal> causes = new HashSet<Principal>();
 
@@ -41,27 +40,22 @@ public final class ImpliedByPrincipal implements Group {
                        causes.add(userPrincipal);
        }
 
-       @Override
        public String getName() {
                return name.toString();
        }
 
-       @Override
        public boolean addMember(Principal user) {
                throw new UnsupportedOperationException();
        }
 
-       @Override
        public boolean removeMember(Principal user) {
                throw new UnsupportedOperationException();
        }
 
-       @Override
        public boolean isMember(Principal member) {
                return causes.contains(member);
        }
 
-       @Override
        public Enumeration<? extends Principal> members() {
                return Collections.enumeration(causes);
        }