You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by er...@apache.org on 2005/09/07 06:29:02 UTC

svn commit: r279244 - /directory/shared/kerberos/trunk/common/src/java/org/apache/kerberos/store/operations/ChangePassword.java

Author: erodriguez
Date: Tue Sep  6 21:28:50 2005
New Revision: 279244

URL: http://svn.apache.org/viewcvs?rev=279244&view=rev
Log:
Refactored method for getting relative name to remove ldap-common and antlr dependencies in kerberos-common.

Modified:
    directory/shared/kerberos/trunk/common/src/java/org/apache/kerberos/store/operations/ChangePassword.java

Modified: directory/shared/kerberos/trunk/common/src/java/org/apache/kerberos/store/operations/ChangePassword.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/trunk/common/src/java/org/apache/kerberos/store/operations/ChangePassword.java?rev=279244&r1=279243&r2=279244&view=diff
==============================================================================
--- directory/shared/kerberos/trunk/common/src/java/org/apache/kerberos/store/operations/ChangePassword.java (original)
+++ directory/shared/kerberos/trunk/common/src/java/org/apache/kerberos/store/operations/ChangePassword.java Tue Sep  6 21:28:50 2005
@@ -16,6 +16,9 @@
  */
 package org.apache.kerberos.store.operations;
 
+import java.util.Properties;
+
+import javax.naming.CompoundName;
 import javax.naming.Name;
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
@@ -31,8 +34,6 @@
 
 import org.apache.kerberos.store.ContextOperation;
 import org.apache.kerberos.store.KerberosAttribute;
-import org.apache.ldap.common.name.LdapName;
-import org.apache.ldap.common.util.NestableRuntimeException;
 
 /**
  * Command for changing a principal's password in a JNDI context.
@@ -108,35 +109,32 @@
         return null;
     }
 
-    private Name getRelativeName( DirContext ctx, String baseDn )
+    private Name getRelativeName( DirContext ctx, String baseDn ) throws NamingException
     {
+        Properties props = new Properties();
+        props.setProperty( "jndi.syntax.direction", "right_to_left" );
+        props.setProperty( "jndi.syntax.separator", "," );
+
         Name searchBaseDn = null;
 
         try
         {
-            LdapName ctxRoot = new LdapName( ctx.getNameInNamespace() );
-
-            searchBaseDn = new LdapName( baseDn );
+            Name ctxRoot = new CompoundName( ctx.getNameInNamespace(), props );
+            searchBaseDn = new CompoundName( baseDn, props );
 
-            if ( searchBaseDn.startsWith( ctxRoot ) )
+            if ( !searchBaseDn.startsWith( ctxRoot ) )
             {
-                for ( int ii = 0; ii < ctxRoot.size(); ii++ )
-                {
-                    searchBaseDn.remove( 0 );
-                }
+                throw new NamingException( "Invalid search base for Apache profiles." );
             }
-            else
-            {
-                String msg = "Failed to create initial context for ApacheDS provider";
 
-                throw new IllegalArgumentException( msg );
+            for ( int ii = 0; ii < ctxRoot.size(); ii++ )
+            {
+                searchBaseDn.remove( 0 );
             }
         }
         catch ( NamingException e )
         {
-            String msg = "Failed to find search base for ApacheDS store";
-
-            throw new NestableRuntimeException( msg, e );
+            throw new NamingException( "Failed to initialize search base for Apache profiles." );
         }
 
         return searchBaseDn;