]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.security.core/src/org/argeo/osgi/useradmin/LdifUser.java
Add Authorization, with chained groups
[lgpl/argeo-commons.git] / org.argeo.security.core / src / org / argeo / osgi / useradmin / LdifUser.java
1 package org.argeo.osgi.useradmin;
2
3 import java.util.ArrayList;
4 import java.util.Dictionary;
5 import java.util.List;
6
7 import javax.naming.directory.Attributes;
8 import javax.naming.ldap.LdapName;
9
10 import org.osgi.service.useradmin.User;
11
12 class LdifUser implements User {
13 // optimisation
14 List<LdifGroup> directMemberOf = new ArrayList<LdifGroup>();
15
16 private final LdapName dn;
17 private Attributes attributes;
18
19 LdifUser(LdapName dn, Attributes attributes) {
20 this.dn = dn;
21 this.attributes = attributes;
22 }
23
24 @Override
25 public String getName() {
26 return dn.toString();
27 }
28
29 @Override
30 public int getType() {
31 return USER;
32 }
33
34 @Override
35 public Dictionary<String, Object> getProperties() {
36 if (attributes == null)
37 throw new ArgeoUserAdminException(
38 "Must be loaded from user admin service");
39 return new AttributeDictionary(attributes);
40 }
41
42 @Override
43 public Dictionary<String, Object> getCredentials() {
44 // TODO Auto-generated method stub
45 return null;
46 }
47
48 @Override
49 public boolean hasCredential(String key, Object value) {
50 // TODO Auto-generated method stub
51 return false;
52 }
53
54 protected LdapName getDn() {
55 return dn;
56 }
57
58 protected Attributes getAttributes() {
59 return attributes;
60 }
61
62 @Override
63 public int hashCode() {
64 return dn.hashCode();
65 }
66
67 @Override
68 public boolean equals(Object obj) {
69 if (this == obj)
70 return true;
71 if (obj instanceof LdifUser) {
72 LdifUser that = (LdifUser) obj;
73 return this.dn.equals(that.dn);
74 }
75 return false;
76 }
77
78 @Override
79 public String toString() {
80 return dn.toString();
81 }
82
83 }