]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.security.core/src/org/argeo/osgi/useradmin/LdifAuthorization.java
Improve and simplify OSGi Boot
[lgpl/argeo-commons.git] / org.argeo.security.core / src / org / argeo / osgi / useradmin / LdifAuthorization.java
index 845fefd13da483a6ee88c3c48690c0f45062ad0d..e06c42e1ffb213c501ce23b2bc2edd90498b74c0 100644 (file)
@@ -9,11 +9,13 @@ import org.osgi.service.useradmin.Authorization;
 import org.osgi.service.useradmin.Role;
 import org.osgi.service.useradmin.User;
 
-public class LdifAuthorization implements Authorization, LdapNames {
+/** Basic authorization. */
+class LdifAuthorization implements Authorization {
        private final String name;
        private final String displayName;
        private final List<String> allRoles;
 
+       @SuppressWarnings("unchecked")
        public LdifAuthorization(User user, List<Role> allRoles) {
                if (user == null) {
                        this.name = null;
@@ -21,16 +23,16 @@ public class LdifAuthorization implements Authorization, LdapNames {
                } else {
                        this.name = user.getName();
                        Dictionary<String, Object> props = user.getProperties();
-                       Object displayName = props.get(LDAP_DISPLAY_NAME);
+                       Object displayName = props.get(LdifName.displayName);
                        if (displayName == null)
-                               displayName = props.get(LDAP_CN);
+                               displayName = props.get(LdifName.cn);
                        if (displayName == null)
-                               displayName = props.get(LDAP_UID);
+                               displayName = props.get(LdifName.uid);
                        if (displayName == null)
                                displayName = user.getName();
                        if (displayName == null)
-                               throw new UserDirectoryException(
-                                               "Cannot set display name for " + user);
+                               throw new UserDirectoryException("Cannot set display name for "
+                                               + user);
                        this.displayName = displayName.toString();
                }
                // roles