]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org/argeo/osgi/useradmin/OsUserDirectory.java
1 package org
.argeo
.osgi
.useradmin
;
4 import java
.util
.ArrayList
;
5 import java
.util
.Dictionary
;
8 import javax
.naming
.NameNotFoundException
;
9 import javax
.naming
.NamingException
;
10 import javax
.naming
.directory
.Attributes
;
11 import javax
.naming
.directory
.BasicAttributes
;
12 import javax
.naming
.ldap
.LdapName
;
14 import org
.argeo
.util
.naming
.LdapAttrs
;
15 import org
.osgi
.framework
.Filter
;
16 import org
.osgi
.service
.useradmin
.User
;
18 public class OsUserDirectory
extends AbstractUserDirectory
{
19 private final String osUsername
= System
.getProperty("user.name");
20 private final LdapName osUserDn
;
21 private final LdifUser osUser
;
23 public OsUserDirectory(URI uriArg
, Dictionary
<String
, ?
> props
) {
24 super(uriArg
, props
, false);
26 osUserDn
= new LdapName(LdapAttrs
.uid
.name() + "=" + osUsername
+ "," + getUserBase() + "," + getBaseDn());
27 Attributes attributes
= new BasicAttributes();
28 attributes
.put(LdapAttrs
.uid
.name(), osUsername
);
29 osUser
= new LdifUser(this, osUserDn
, attributes
);
30 } catch (NamingException e
) {
31 throw new UserDirectoryException("Cannot create system user", e
);
36 protected List
<LdapName
> getDirectGroups(LdapName dn
) {
37 return new ArrayList
<>();
41 protected Boolean
daoHasRole(LdapName dn
) {
42 return osUserDn
.equals(dn
);
46 protected DirectoryUser
daoGetRole(LdapName key
) throws NameNotFoundException
{
47 if (osUserDn
.equals(key
))
50 throw new NameNotFoundException("Not an OS role");
54 protected List
<DirectoryUser
> doGetRoles(Filter f
) {
55 List
<DirectoryUser
> res
= new ArrayList
<>();
56 if (f
== null || f
.match(osUser
.getProperties()))
62 protected AbstractUserDirectory
scope(User user
) {
63 throw new UnsupportedOperationException();