directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r201847 - /directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/NamespaceTools.java
Date Sun, 26 Jun 2005 12:37:25 GMT
Author: akarasulu
Date: Sun Jun 26 05:37:24 2005
New Revision: 201847

URL: http://svn.apache.org/viewcvs?rev=201847&view=rev
Log:
Added utility method for inferring the LDAP name for a DNS domain or a Kerberos
realm name using the algorithm in RFC 2247 here:

http://www.faqs.org/rfcs/rfc2247.html


Modified:
    directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/NamespaceTools.java

Modified: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/NamespaceTools.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/NamespaceTools.java?rev=201847&r1=201846&r2=201847&view=diff
==============================================================================
--- directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/NamespaceTools.java
(original)
+++ directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/NamespaceTools.java
Sun Jun 26 05:37:24 2005
@@ -437,5 +437,41 @@
 
         return rdn;
     }
+
+    
+    /**
+     * Uses the algorithm in <a href="http://www.faqs.org/rfcs/rfc2247.html">RFC 2247</a>
+     * to infer an LDAP name from a Kerberos realm name or a DNS domain name.
+     *
+     * @param realm the realm or domain name
+     * @return the LDAP name for the realm or domain
+     */
+    public static String inferLdapName( String realm )
+    {
+        StringBuffer buf = new StringBuffer();
+
+        while ( realm != null && ! realm.equals( "" ) )
+        {
+            int dotIndex = realm.indexOf( '.' );
+
+            if ( dotIndex != -1 )
+            {
+                String component = realm.substring( 0, dotIndex );
+                buf.append( "dc=" );
+                buf.append( component );
+                buf.append( ',' );
+
+                realm = realm.substring( dotIndex + 1 );
+            }
+            else if ( realm.length() > 0 )
+            {
+                buf.append( "dc=" );
+                buf.append( realm );
+                realm = null;
+            }
+        }
+
+        return buf.toString();
+    }
 }
 



Mime
View raw message