]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.cms/src/org/argeo/cms/util/useradmin/UserAdminUtils.java
Merge security.ui bundle in the cms.ui.workbench bundle
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / util / useradmin / UserAdminUtils.java
index e6e3e91e0fc552687fe9a5bf37a5b31f3229dc69..9ccc3057f3a355d66d369cdd06f3bd5633f2567f 100644 (file)
@@ -10,7 +10,6 @@ import javax.naming.ldap.Rdn;
 import javax.security.auth.Subject;
 import javax.security.auth.x500.X500Principal;
 
-import org.argeo.ArgeoException;
 import org.argeo.cms.CmsException;
 import org.argeo.cms.CmsView;
 import org.argeo.cms.auth.AuthConstants;
@@ -107,7 +106,7 @@ public class UserAdminUtils {
                        else
                                return false;
                } catch (InvalidNameException e) {
-                       throw new ArgeoException("User " + user + " has an unvalid dn: "
+                       throw new CmsException("User " + user + " has an unvalid dn: "
                                        + userName, e);
                }
        }
@@ -136,7 +135,7 @@ public class UserAdminUtils {
                Subject subject = Subject.getSubject(AccessController.getContext());
                if (subject != null)
                        return subject;
-               throw new CmsException("Cannot find related subject");
+               throw new RuntimeException("Cannot find related subject");
        }
 
        // HOME MANAGEMENT
@@ -161,18 +160,14 @@ public class UserAdminUtils {
        // HELPERS TO RETRIEVE REMARKABLE PROPERTIES
        /** Simply retrieves the user uid from his dn with no useradmin */
        public static String getUserUid(String dn) {
-               try {
-                       LdapName ldapName = new LdapName(dn);
-                       Rdn last = ldapName.getRdn(ldapName.size() - 1);
-                       if (last.getType().toLowerCase().equals(LdifName.uid.name())
-                                       || last.getType().toLowerCase().equals(LdifName.cn.name()))
-                               return (String) last.getValue();
-                       else
-                               throw new ArgeoException("Cannot retrieve user uid, "
-                                               + "non valid dn: " + dn);
-               } catch (InvalidNameException e) {
-                       throw new ArgeoException("Cannot parse LDAP name " + dn, e);
-               }
+               LdapName ldapName = getLdapName(dn);
+               Rdn last = ldapName.getRdn(ldapName.size() - 1);
+               if (last.getType().toLowerCase().equals(LdifName.uid.name())
+                               || last.getType().toLowerCase().equals(LdifName.cn.name()))
+                       return (String) last.getValue();
+               else
+                       throw new CmsException("Cannot retrieve user uid, "
+                                       + "non valid dn: " + dn);
        }
 
        /**
@@ -231,7 +226,7 @@ public class UserAdminUtils {
                        }
                        return dname;
                } catch (InvalidNameException e) {
-                       throw new ArgeoException("Unable to get domain name for " + dn, e);
+                       throw new CmsException("Unable to get domain name for " + dn, e);
                }
        }
 
@@ -241,7 +236,7 @@ public class UserAdminUtils {
                try {
                        return new LdapName(dn);
                } catch (InvalidNameException e) {
-                       throw new ArgeoException("Cannot parse LDAP name " + dn, e);
+                       throw new CmsException("Cannot parse LDAP name " + dn, e);
                }
        }
 }
\ No newline at end of file