]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.cms/src/org/argeo/cms/internal/auth/ImpliedByPrincipal.java
1 package org
.argeo
.cms
.internal
.auth
;
3 import java
.security
.Principal
;
4 import java
.util
.HashSet
;
7 import javax
.xml
.namespace
.QName
;
9 import org
.argeo
.cms
.auth
.RoleNameUtils
;
10 import org
.osgi
.service
.useradmin
.Authorization
;
13 * A {@link Principal} which has been implied by an {@link Authorization}. If it
14 * is empty it means this is an additional identity, otherwise it lists the
15 * users (typically the logged in user but possibly empty
16 * {@link ImpliedByPrincipal}s) which have implied it. When an additional
17 * identity is removed, the related {@link ImpliedByPrincipal}s can thus be
20 public final class ImpliedByPrincipal
implements Principal
{
21 private final String name
;
22 private final QName roleName
;
23 private final boolean systemRole
;
24 private final String context
;
26 private Set
<Principal
> causes
= new HashSet
<Principal
>();
28 public ImpliedByPrincipal(String name
, Principal userPrincipal
) {
30 roleName
= RoleNameUtils
.getLastRdnAsName(name
);
31 systemRole
= RoleNameUtils
.isSystemRole(roleName
);
32 context
= RoleNameUtils
.getContext(name
);
33 if (userPrincipal
!= null)
34 causes
.add(userPrincipal
);
37 public String
getName() {
45 public QName
getRoleName() {
49 public String
getContext() {
53 public boolean isSystemRole() {
58 public int hashCode() {
59 return name
.hashCode();
63 public boolean equals(Object obj
) {
64 if (obj
instanceof ImpliedByPrincipal
) {
65 ImpliedByPrincipal that
= (ImpliedByPrincipal
) obj
;
66 // TODO check members too?
67 return name
.equals(that
.name
);
73 public String
toString() {
74 return name
.toString();