Return-Path: Delivered-To: apmail-directory-dev-archive@www.apache.org Received: (qmail 94127 invoked from network); 13 Apr 2007 23:16:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Apr 2007 23:16:53 -0000 Received: (qmail 34739 invoked by uid 500); 13 Apr 2007 23:16:58 -0000 Delivered-To: apmail-directory-dev-archive@directory.apache.org Received: (qmail 34701 invoked by uid 500); 13 Apr 2007 23:16:58 -0000 Mailing-List: contact dev-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Apache Directory Developers List" Delivered-To: mailing list dev@directory.apache.org Received: (qmail 34689 invoked by uid 99); 13 Apr 2007 23:16:58 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Apr 2007 16:16:58 -0700 X-ASF-Spam-Status: No, hits=1.3 required=10.0 tests=SPF_PASS,TRACKER_ID X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of ole.ersoy@gmail.com designates 64.233.166.181 as permitted sender) Received: from [64.233.166.181] (HELO py-out-1112.google.com) (64.233.166.181) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Apr 2007 16:16:51 -0700 Received: by py-out-1112.google.com with SMTP id a29so774147pyi for ; Fri, 13 Apr 2007 16:16:30 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding; b=EPqFYOipShSw8/bbZGzbpQisReOQ8jZ6TzYnRCJOKgVzTnyyJfFzZclBV1iumpL9kA2IaUO4vO0RiSITVINk7idjvku8JhHbB9vmrwBqWeVGbrBww/Z0zHgQ2ApM+e/vgK+BVcldO1OCoR4A2gg/qdZX9e+QV3RaaBEctHmUC0M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding; b=KAl6f5lT0gXjO0j99vjt9K+F5VjmCCoH7x4pk3TFSbwDV97ZHrZn/Hji6i79kedjWG1lGW3ZLnPMBFYxUA/dGpssWgsp2jRQWWFJFZ9AuWGuCFdZVF1nfnlZHKpJ1X1/KDbts72U3CYSVNxsJ1cW5t93Yu1eL7TjNMeAzXpEZ6g= Received: by 10.35.57.5 with SMTP id j5mr6027516pyk.1176506175324; Fri, 13 Apr 2007 16:16:15 -0700 (PDT) Received: from ?192.168.1.24? ( [24.13.179.233]) by mx.google.com with ESMTP id n27sm4159337pyh.2007.04.13.16.16.14; Fri, 13 Apr 2007 16:16:14 -0700 (PDT) Message-ID: <46200E7C.6020105@gmail.com> Date: Fri, 13 Apr 2007 18:13:00 -0500 From: Ole Ersoy User-Agent: Thunderbird 1.5.0.10 (X11/20070302) MIME-Version: 1.0 To: Apache Directory Developers List Subject: Re: [DAS] Generating OIDs References: <461FFF1A.4020402@gmail.com> <46200638.2040403@gmail.com> In-Reply-To: <46200638.2040403@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Emmanuel Lecharny wrote: SNIP > This is not what I suggested. Did you read my mails carefully ? Maybe :-) > > I said that you should : > - have unique OIDs Yap > - use the String structure to generate the oid Yap > - and to avoid insanely long oids, use a hascode of each part of the > string to generate an oid Yap > > Something like : > private static String getOid( String prefix, String param ) > { > StringTokenizer tokens = new StringTokenizer( param, "." ); > StringBuilder oid = new StringBuilder( prefix ); > while ( tokens.hasMoreElements() ) > { > oid.append( '.' ).append( Math.abs( > tokens.nextElement().hashCode() ) ); > } > return oid.toString(); > } > > When you call it with : > getOid( "1.3.6.1.4.1.18060.0.4.100.2", > "org.apache.tuscany.das.ldap.DASConfig" ) > > you get this OID : > 1.3.6.1.4.1.18060.0.4.100.2.110308.1411517106.964893765.99222.3316647.1638106712 > > > where > org -> 110308 > apache -> 1411517106 > tuscany -> 964893765 > das -> 99222 > ldap -> 3316647 > DASConfig -> 1638106712 Yes - We are doing the same thing, except I just added the hashes and replaced "-" with "1" to get (I excluded the OID prefix part): 1103081141151710619648937659922233166471638106712 110308 11411517106 1964893765 99222 3316647 1638106712 org -> 110308 apache -> 1411517106 tuscany -> 964893765 das -> 99222 ldap -> 3316647 DASConfig -> 1638106712 > > Alex suggestion was more straight forward : simply compute a checksum > from the whome string, but keeping the result into an int ( values > longer than an int won't be accepted by the server). In fact, more or > les a hashcode of the string (absolute value of the hashcode to avoid > negative number). Here's (I think) a version of Alex's: public static String generateUnqiueOIDPostfix( String namespacedMetadata) throws NoSuchAlgorithmException { MessageDigest messageDigest = MessageDigest.getInstance("SHA-1"); byte[] digest = messageDigest.digest(namespacedMetadata.getBytes()); StringBuffer hexString = new StringBuffer(); for (int i=0;i Keep it simple, buddy ! You like? Thanks and have a great weekend Emmanuel (You should be sipping on a nice glass of wine right now btw, instead of answering my mails :-) ) - Ole , > > Emmanuel > >