X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Finternal%2Fauth%2FImpliedByPrincipal.java;h=9e0ebce97d230ec24828ccbbb548786855013ae6;hb=e018ad9078249a806f2e2ef86a6adcbd8cca3188;hp=73f474637750a2f61aa825cddbdc0d12861df99e;hpb=eb4324be6ac9cdff15828a21ee7d3f6ca2f19fb9;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/internal/auth/ImpliedByPrincipal.java b/org.argeo.cms/src/org/argeo/cms/internal/auth/ImpliedByPrincipal.java index 73f474637..9e0ebce97 100644 --- a/org.argeo.cms/src/org/argeo/cms/internal/auth/ImpliedByPrincipal.java +++ b/org.argeo.cms/src/org/argeo/cms/internal/auth/ImpliedByPrincipal.java @@ -1,16 +1,12 @@ package org.argeo.cms.internal.auth; -import static org.argeo.api.acr.RuntimeNamespaceContext.getNamespaceContext; - import java.security.Principal; import java.util.HashSet; import java.util.Set; import javax.xml.namespace.QName; -import org.argeo.api.acr.CrName; -import org.argeo.api.acr.NamespaceUtils; -import org.argeo.cms.auth.RoleNameUtils; +import org.argeo.cms.RoleNameUtils; import org.osgi.service.useradmin.Authorization; /** @@ -23,71 +19,25 @@ import org.osgi.service.useradmin.Authorization; */ public final class ImpliedByPrincipal implements Principal { private final String name; - private Set causes = new HashSet(); - - private QName roleName; -// private int type = Role.ROLE; + private final QName roleName; + private final boolean systemRole; + private final String context; - private boolean systemRole = false; - private String context; + private Set causes = new HashSet(); public ImpliedByPrincipal(String name, Principal userPrincipal) { this.name = name; - String cn = RoleNameUtils.getLastRdnValue(name); - roleName = NamespaceUtils.parsePrefixedName(getNamespaceContext(), cn); - if (roleName.getNamespaceURI().equals(CrName.ROLE_NAMESPACE_URI)) { - systemRole = true; - } + roleName = RoleNameUtils.getLastRdnAsName(name); + systemRole = RoleNameUtils.isSystemRole(roleName); context = RoleNameUtils.getContext(name); -// try { -// this.name = new LdapName(name); -// } catch (InvalidNameException e) { -// throw new IllegalArgumentException("Badly formatted role name", e); -// } if (userPrincipal != null) causes.add(userPrincipal); } -// public ImpliedByPrincipal(LdapName name, Principal userPrincipal) { -// this.name = name; -// if (userPrincipal != null) -// causes.add(userPrincipal); -// } - public String getName() { return name; } - /* - * USER ADMIN - */ -// public boolean addMember(Principal user) { -// throw new UnsupportedOperationException(); -// } -// -// public boolean removeMember(Principal user) { -// throw new UnsupportedOperationException(); -// } -// -// public boolean isMember(Principal member) { -// return causes.contains(member); -// } -// -// public Enumeration members() { -// return Collections.enumeration(causes); -// } -// -// -// /** Type of {@link Role}, if known. */ -// public int getType() { -// return type; -// } -// -// /** Not supported for the time being. */ -// public Dictionary getProperties() { -// throw new UnsupportedOperationException(); -// } - /* * OBJECT */ @@ -111,8 +61,6 @@ public final class ImpliedByPrincipal implements Principal { @Override public boolean equals(Object obj) { - // if (this == obj) - // return true; if (obj instanceof ImpliedByPrincipal) { ImpliedByPrincipal that = (ImpliedByPrincipal) obj; // TODO check members too? @@ -123,7 +71,6 @@ public final class ImpliedByPrincipal implements Principal { @Override public String toString() { - // return name.toString() + " implied by " + causes; return name.toString(); } }