]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.cms/src/org/argeo/cms/osgi/useradmin/AuthenticatingUser.java
1 package org
.argeo
.cms
.osgi
.useradmin
;
3 import java
.util
.Dictionary
;
4 import java
.util
.Hashtable
;
6 import javax
.naming
.ldap
.LdapName
;
8 import org
.argeo
.api
.cms
.directory
.DirectoryDigestUtils
;
9 import org
.osgi
.service
.useradmin
.User
;
12 * A special user type used during authentication in order to provide the
13 * credentials required for scoping the user admin.
15 public class AuthenticatingUser
implements User
{
16 /** From com.sun.security.auth.module.*LoginModule */
17 public final static String SHARED_STATE_NAME
= "javax.security.auth.login.name";
18 /** From com.sun.security.auth.module.*LoginModule */
19 public final static String SHARED_STATE_PWD
= "javax.security.auth.login.password";
21 private final String name
;
22 private final Dictionary
<String
, Object
> credentials
;
24 public AuthenticatingUser(LdapName name
) {
26 throw new NullPointerException("Provided name cannot be null.");
27 this.name
= name
.toString();
28 this.credentials
= new Hashtable
<>();
31 public AuthenticatingUser(String name
, Dictionary
<String
, Object
> credentials
) {
33 this.credentials
= credentials
;
36 public AuthenticatingUser(String name
, char[] password
) {
38 throw new NullPointerException("Provided name cannot be null.");
40 credentials
= new Hashtable
<>();
41 credentials
.put(SHARED_STATE_NAME
, name
);
42 byte[] pwd
= DirectoryDigestUtils
.charsToBytes(password
);
43 credentials
.put(SHARED_STATE_PWD
, pwd
);
47 public String
getName() {
52 public int getType() {
56 @SuppressWarnings({ "rawtypes", "unchecked" })
58 public Dictionary
getProperties() {
59 throw new UnsupportedOperationException();
62 @SuppressWarnings({ "rawtypes", "unchecked" })
64 public Dictionary
getCredentials() {
69 public boolean hasCredential(String key
, Object value
) {
70 throw new UnsupportedOperationException();
74 public int hashCode() {
75 return name
.hashCode();
79 public String
toString() {
80 return "Authenticating user " + name
;