1 package org
.argeo
.osgi
.useradmin
;
3 import java
.util
.ArrayList
;
4 import java
.util
.Arrays
;
5 import java
.util
.Dictionary
;
8 import javax
.naming
.directory
.Attributes
;
9 import javax
.naming
.ldap
.LdapName
;
11 import org
.osgi
.service
.useradmin
.User
;
13 class LdifUser
implements User
{
15 List
<LdifGroup
> directMemberOf
= new ArrayList
<LdifGroup
>();
17 private final LdapName dn
;
18 private Attributes attributes
;
20 private final AttributeDictionary properties
;
21 private final AttributeDictionary credentials
;
23 private List
<String
> credentialAttributes
= Arrays
24 .asList(new String
[] { "userpassword" });
26 LdifUser(LdapName dn
, Attributes attributes
) {
28 this.attributes
= attributes
;
29 properties
= new AttributeDictionary(attributes
, credentialAttributes
,
31 credentials
= new AttributeDictionary(attributes
, credentialAttributes
,
36 public String
getName() {
41 public int getType() {
46 public Dictionary
<String
, Object
> getProperties() {
51 public Dictionary
<String
, Object
> getCredentials() {
56 public boolean hasCredential(String key
, Object value
) {
57 Object storedValue
= getCredentials().get(key
);
58 if (storedValue
== null || value
== null)
60 if (!(value
instanceof String
|| value
instanceof byte[]))
62 if (storedValue
instanceof String
&& value
instanceof String
)
63 return storedValue
.equals(value
);
64 if (storedValue
instanceof byte[] && value
instanceof byte[])
65 return Arrays
.equals((byte[]) storedValue
, (byte[]) value
);
69 protected LdapName
getDn() {
73 protected Attributes
getAttributes() {
78 public int hashCode() {
83 public boolean equals(Object obj
) {
86 if (obj
instanceof LdifUser
) {
87 LdifUser that
= (LdifUser
) obj
;
88 return this.dn
.equals(that
.dn
);
94 public String
toString() {