directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r158215 - in directory/sandbox/trunk/asn1-new-codec: ./ src/ src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache/asn1/ src/java/org/apache/asn1/ldap/ src/java/org/apache/asn1/ldap/utils/ src/test/ src/test/org/ src/test/org/apache/ src/test/org/apache/asn1/ src/test/org/apache/asn1/ldap/ src/test/org/apache/asn1/ldap/utils/
Date Sat, 19 Mar 2005 08:01:18 GMT
Author: elecharny
Date: Sat Mar 19 00:01:15 2005
New Revision: 158215

URL: http://svn.apache.org/viewcvs?view=rev&rev=158215
Log:
Create the maven files
Create DN helper class & test

Added:
    directory/sandbox/trunk/asn1-new-codec/LICENSE.txt
    directory/sandbox/trunk/asn1-new-codec/NOTICE.txt
    directory/sandbox/trunk/asn1-new-codec/maven.xml
    directory/sandbox/trunk/asn1-new-codec/project.properties
    directory/sandbox/trunk/asn1-new-codec/project.xml
    directory/sandbox/trunk/asn1-new-codec/src/
    directory/sandbox/trunk/asn1-new-codec/src/java/
    directory/sandbox/trunk/asn1-new-codec/src/java/org/
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/utils/
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/utils/DNUtils.java
    directory/sandbox/trunk/asn1-new-codec/src/test/
    directory/sandbox/trunk/asn1-new-codec/src/test/org/
    directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/
    directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/
    directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/
    directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/utils/
    directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/utils/DNUtilsTest.java

Added: directory/sandbox/trunk/asn1-new-codec/LICENSE.txt
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/LICENSE.txt?view=auto&rev=158215
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/LICENSE.txt (added)
+++ directory/sandbox/trunk/asn1-new-codec/LICENSE.txt Sat Mar 19 00:01:15 2005
@@ -0,0 +1,204 @@
+/*
+ *                                 Apache License
+ *                           Version 2.0, January 2004
+ *                        http://www.apache.org/licenses/
+ *
+ *   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ *   1. Definitions.
+ *
+ *      "License" shall mean the terms and conditions for use, reproduction,
+ *      and distribution as defined by Sections 1 through 9 of this document.
+ *
+ *      "Licensor" shall mean the copyright owner or entity authorized by
+ *      the copyright owner that is granting the License.
+ *
+ *      "Legal Entity" shall mean the union of the acting entity and all
+ *      other entities that control, are controlled by, or are under common
+ *      control with that entity. For the purposes of this definition,
+ *      "control" means (i) the power, direct or indirect, to cause the
+ *      direction or management of such entity, whether by contract or
+ *      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ *      outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ *      "You" (or "Your") shall mean an individual or Legal Entity
+ *      exercising permissions granted by this License.
+ *
+ *      "Source" form shall mean the preferred form for making modifications,
+ *      including but not limited to software source code, documentation
+ *      source, and configuration files.
+ *
+ *      "Object" form shall mean any form resulting from mechanical
+ *      transformation or translation of a Source form, including but
+ *      not limited to compiled object code, generated documentation,
+ *      and conversions to other media types.
+ *
+ *      "Work" shall mean the work of authorship, whether in Source or
+ *      Object form, made available under the License, as indicated by a
+ *      copyright notice that is included in or attached to the work
+ *      (an example is provided in the Appendix below).
+ *
+ *      "Derivative Works" shall mean any work, whether in Source or Object
+ *      form, that is based on (or derived from) the Work and for which the
+ *      editorial revisions, annotations, elaborations, or other modifications
+ *      represent, as a whole, an original work of authorship. For the purposes
+ *      of this License, Derivative Works shall not include works that remain
+ *      separable from, or merely link (or bind by name) to the interfaces of,
+ *      the Work and Derivative Works thereof.
+ *
+ *      "Contribution" shall mean any work of authorship, including
+ *      the original version of the Work and any modifications or additions
+ *      to that Work or Derivative Works thereof, that is intentionally
+ *      submitted to Licensor for inclusion in the Work by the copyright owner
+ *      or by an individual or Legal Entity authorized to submit on behalf of
+ *      the copyright owner. For the purposes of this definition, "submitted"
+ *      means any form of electronic, verbal, or written communication sent
+ *      to the Licensor or its representatives, including but not limited to
+ *      communication on electronic mailing lists, source code control systems,
+ *      and issue tracking systems that are managed by, or on behalf of, the
+ *      Licensor for the purpose of discussing and improving the Work, but
+ *      excluding communication that is conspicuously marked or otherwise
+ *      designated in writing by the copyright owner as "Not a Contribution."
+ *
+ *      "Contributor" shall mean Licensor and any individual or Legal Entity
+ *      on behalf of whom a Contribution has been received by Licensor and
+ *      subsequently incorporated within the Work.
+ *
+ *   2. Grant of Copyright License. Subject to the terms and conditions of
+ *      this License, each Contributor hereby grants to You a perpetual,
+ *      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ *      copyright license to reproduce, prepare Derivative Works of,
+ *      publicly display, publicly perform, sublicense, and distribute the
+ *      Work and such Derivative Works in Source or Object form.
+ *
+ *   3. Grant of Patent License. Subject to the terms and conditions of
+ *      this License, each Contributor hereby grants to You a perpetual,
+ *      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ *      (except as stated in this section) patent license to make, have made,
+ *      use, offer to sell, sell, import, and otherwise transfer the Work,
+ *      where such license applies only to those patent claims licensable
+ *      by such Contributor that are necessarily infringed by their
+ *      Contribution(s) alone or by combination of their Contribution(s)
+ *      with the Work to which such Contribution(s) was submitted. If You
+ *      institute patent litigation against any entity (including a
+ *      cross-claim or counterclaim in a lawsuit) alleging that the Work
+ *      or a Contribution incorporated within the Work constitutes direct
+ *      or contributory patent infringement, then any patent licenses
+ *      granted to You under this License for that Work shall terminate
+ *      as of the date such litigation is filed.
+ *
+ *   4. Redistribution. You may reproduce and distribute copies of the
+ *      Work or Derivative Works thereof in any medium, with or without
+ *      modifications, and in Source or Object form, provided that You
+ *      meet the following conditions:
+ *
+ *      (a) You must give any other recipients of the Work or
+ *          Derivative Works a copy of this License; and
+ *
+ *      (b) You must cause any modified files to carry prominent notices
+ *          stating that You changed the files; and
+ *
+ *      (c) You must retain, in the Source form of any Derivative Works
+ *          that You distribute, all copyright, patent, trademark, and
+ *          attribution notices from the Source form of the Work,
+ *          excluding those notices that do not pertain to any part of
+ *          the Derivative Works; and
+ *
+ *      (d) If the Work includes a "NOTICE" text file as part of its
+ *          distribution, then any Derivative Works that You distribute must
+ *          include a readable copy of the attribution notices contained
+ *          within such NOTICE file, excluding those notices that do not
+ *          pertain to any part of the Derivative Works, in at least one
+ *          of the following places: within a NOTICE text file distributed
+ *          as part of the Derivative Works; within the Source form or
+ *          documentation, if provided along with the Derivative Works; or,
+ *          within a display generated by the Derivative Works, if and
+ *          wherever such third-party notices normally appear. The contents
+ *          of the NOTICE file are for informational purposes only and
+ *          do not modify the License. You may add Your own attribution
+ *          notices within Derivative Works that You distribute, alongside
+ *          or as an addendum to the NOTICE text from the Work, provided
+ *          that such additional attribution notices cannot be construed
+ *          as modifying the License.
+ *
+ *      You may add Your own copyright statement to Your modifications and
+ *      may provide additional or different license terms and conditions
+ *      for use, reproduction, or distribution of Your modifications, or
+ *      for any such Derivative Works as a whole, provided Your use,
+ *      reproduction, and distribution of the Work otherwise complies with
+ *      the conditions stated in this License.
+ *
+ *   5. Submission of Contributions. Unless You explicitly state otherwise,
+ *      any Contribution intentionally submitted for inclusion in the Work
+ *      by You to the Licensor shall be under the terms and conditions of
+ *      this License, without any additional terms or conditions.
+ *      Notwithstanding the above, nothing herein shall supersede or modify
+ *      the terms of any separate license agreement you may have executed
+ *      with Licensor regarding such Contributions.
+ *
+ *   6. Trademarks. This License does not grant permission to use the trade
+ *      names, trademarks, service marks, or product names of the Licensor,
+ *      except as required for reasonable and customary use in describing the
+ *      origin of the Work and reproducing the content of the NOTICE file.
+ *
+ *   7. Disclaimer of Warranty. Unless required by applicable law or
+ *      agreed to in writing, Licensor provides the Work (and each
+ *      Contributor provides its Contributions) on an "AS IS" BASIS,
+ *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ *      implied, including, without limitation, any warranties or conditions
+ *      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ *      PARTICULAR PURPOSE. You are solely responsible for determining the
+ *      appropriateness of using or redistributing the Work and assume any
+ *      risks associated with Your exercise of permissions under this License.
+ *
+ *   8. Limitation of Liability. In no event and under no legal theory,
+ *      whether in tort (including negligence), contract, or otherwise,
+ *      unless required by applicable law (such as deliberate and grossly
+ *      negligent acts) or agreed to in writing, shall any Contributor be
+ *      liable to You for damages, including any direct, indirect, special,
+ *      incidental, or consequential damages of any character arising as a
+ *      result of this License or out of the use or inability to use the
+ *      Work (including but not limited to damages for loss of goodwill,
+ *      work stoppage, computer failure or malfunction, or any and all
+ *      other commercial damages or losses), even if such Contributor
+ *      has been advised of the possibility of such damages.
+ *
+ *   9. Accepting Warranty or Additional Liability. While redistributing
+ *      the Work or Derivative Works thereof, You may choose to offer,
+ *      and charge a fee for, acceptance of support, warranty, indemnity,
+ *      or other liability obligations and/or rights consistent with this
+ *      License. However, in accepting such obligations, You may act only
+ *      on Your own behalf and on Your sole responsibility, not on behalf
+ *      of any other Contributor, and only if You agree to indemnify,
+ *      defend, and hold each Contributor harmless for any liability
+ *      incurred by, or claims asserted against, such Contributor by reason
+ *      of your accepting any such warranty or additional liability.
+ *
+ *   END OF TERMS AND CONDITIONS
+ *
+ *   APPENDIX: How to apply the Apache License to your work.
+ *
+ *      To apply the Apache License to your work, attach the following
+ *      boilerplate notice, with the fields enclosed by brackets "[]"
+ *      replaced with your own identifying information. (Don't include
+ *      the brackets!)  The text should be enclosed in the appropriate
+ *      comment syntax for the file format. We also recommend that a
+ *      file or class name and description of purpose be included on the
+ *      same "printed page" as the copyright notice for easier
+ *      identification within third-party archives.
+ *
+ *   Copyright [yyyy] [name of copyright owner]
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */

Added: directory/sandbox/trunk/asn1-new-codec/NOTICE.txt
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/NOTICE.txt?view=auto&rev=158215
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/NOTICE.txt (added)
+++ directory/sandbox/trunk/asn1-new-codec/NOTICE.txt Sat Mar 19 00:01:15 2005
@@ -0,0 +1,4 @@
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+

Added: directory/sandbox/trunk/asn1-new-codec/maven.xml
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/maven.xml?view=auto&rev=158215
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/maven.xml (added)
+++ directory/sandbox/trunk/asn1-new-codec/maven.xml Sat Mar 19 00:01:15 2005
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="ISO-8859-1"?> 
+  
+<project 
+  default="jar:install" 
+  >
+  
+</project>
\ No newline at end of file

Added: directory/sandbox/trunk/asn1-new-codec/project.properties
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/project.properties?view=auto&rev=158215
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/project.properties (added)
+++ directory/sandbox/trunk/asn1-new-codec/project.properties Sat Mar 19 00:01:15 2005
@@ -0,0 +1,18 @@
+maven.repo.remote=http://cvs.apache.org/repository, http://ibiblio.org/maven, http://ldapd.sourceforge.net/maven/repository
+maven.compile.source = 1.4
+maven.compile.target = 1.4
+
+maven.javadoc.private=true
+maven.javadoc.customtags=tag1 tag2
+
+tag1.name=todo
+tag1.description=To Do:
+tag1.enabled=true
+tag1.scope=all
+
+tag2.name=task
+tag2.description=Task:
+tag2.enabled=false
+tag2.scope=all
+
+maven.license.licenseFile=../../LICENSE.txt

Added: directory/sandbox/trunk/asn1-new-codec/project.xml
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/project.xml?view=auto&rev=158215
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/project.xml (added)
+++ directory/sandbox/trunk/asn1-new-codec/project.xml Sat Mar 19 00:01:15 2005
@@ -0,0 +1,179 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project>
+  <groupId>directory-asn1</groupId>
+  <id>asn1-codec</id>
+  <name>New expermiental LDAP ASN.1 codec</name>
+
+
+    <package>org.apache.asn1</package>
+    <currentVersion>0.1-SNAPSHOT</currentVersion>
+
+    <organization>
+      <name>The Apache Directory Project</name>
+      <url>http://directory.apache.org</url>
+      <logo>http://directory.apache.org/images/apache-directory-logo.png</logo>
+    </organization>
+
+    <inceptionYear>2003</inceptionYear>
+    
+    <logo>http://directory.apache.org/images/apache-directory-logo.png</logo>
+    <url>http://directory.apache.org/subprojects/asn1</url>
+
+    <issueTrackingUrl>
+      http://issues.apache.org/jira/secure/BrowseProject.jspa?id=10517
+    </issueTrackingUrl>
+
+    <siteAddress>minotaur.apache.org</siteAddress>
+    
+    <siteDirectory>
+      /www/directory.apache.org/subprojects/asn1
+    </siteDirectory>
+    <distributionDirectory>
+      /www/cvs.apache.org/dist/directory
+    </distributionDirectory>
+
+    <gumpRepositoryId>directory</gumpRepositoryId>
+
+    <repository>
+      <connection>
+        scm:svn:http://svn.apache.org/repos/asf/directory:sandbox/trunk/${module.path}
+      </connection>
+
+      <url>
+        http://svn.apache.org/viewcvs.cgi/directory/asn1/trunk/${module.path}/?root=Apache-SVN
+      </url>
+      
+      <developerConnection>
+        https://svn.apache.org/repos/asf/directory/asn1/trunk/${module.path}
+      </developerConnection>
+    </repository>
+  
+    <shortDescription>Apache ASN.1 Tools</shortDescription>
+      
+    <description>
+      This is an experimental implementation of a new LDAP ASN.1 codec
+    </description>
+
+    <mailingLists>
+      <mailingList>
+        <name>Apache Directory Developement - use [asn1] prefix</name>
+          <subscribe>
+            dev-subscribe@directory.apache.org
+          </subscribe>
+          <unsubscribe>
+            dev-unsubscribe@directory.apache.org
+          </unsubscribe>
+          <archive>
+            http://mail-archives.apache.org/eyebrowse/ViewLists
+          </archive>
+        </mailingList>
+    </mailingLists>
+    
+    <developers>
+      <developer>
+        <name>Emmanuel L├ęcharny</name>
+        <id>ele</id>
+        <email>elecharny at apache.org</email>
+        <roles>
+          <role>Developer</role>
+        </roles>
+      </developer>
+    </developers>
+
+    <licenses>
+      <license>
+        <name>Apache 2.0 License</name>
+        <url>
+          http://cvs.apache.org/viewcvs.cgi/directory/LICENSE.txt?rev=1369&amp;root=Apache-SVN&amp;view=markup
+        </url>
+        <distribution>repo</distribution>
+      </license>
+    </licenses>
+
+    <dependencies>
+      <dependency>
+        <groupId>junit</groupId>
+        <artifactId>junit</artifactId>
+        <version>3.8.1</version>
+        <url>http://junit.org</url>
+      </dependency>
+    </dependencies>        
+  
+    <build>
+      <nagEmailAddress>dev@directory.apache.org</nagEmailAddress>
+      <sourceDirectory>${basedir}/src/java</sourceDirectory>
+      <unitTestSourceDirectory>${basedir}/src/test</unitTestSourceDirectory>
+      <integrationUnitTestSourceDirectory/>
+      <aspectSourceDirectory/>
+
+      <unitTest>
+        <includes>
+          <include>**/*Test*</include>
+          <include>**/*TestCase*</include>
+        </includes>
+              
+        <excludes>
+            <exclude>**/testutils/*</exclude>
+            <exclude>**/Abstract*</exclude>
+        </excludes>
+        
+        <resources>
+          <resource>
+            <directory>${basedir}/src/test</directory>
+            <includes> 
+              <include>**/*.dtd</include>
+              <include>**/*.ldif</include>
+              <include>**/*.properties</include>
+              <include>**/*.x*</include>
+              <include>**/*.mf</include>
+              <include>**/*.jar</include>
+            </includes>
+          </resource>
+
+          <resource>
+            <directory>${basedir}/src/test</directory>
+            <includes> 
+              <include>**/*.dtd</include>
+              <include>**/*.ldif</include>
+              <include>**/*.properties</include>
+              <include>**/*.x*</include>
+              <include>**/*.mf</include>
+              <include>**/*.jar</include>
+            </includes>
+          </resource>
+        </resources>
+      </unitTest>
+    
+      <resources>
+
+        <resource>
+          <directory>${basedir}/src/java</directory>
+          <includes>
+            <include>**/*.dtd</include>
+            <include>**/*.properties</include>
+            <include>**/*.x*</include>
+          </includes>
+        </resource>
+
+        <resource>
+          <directory>${basedir}/../</directory>
+          <targetPath>META-INF</targetPath>
+          <includes>
+            <include>LICENSE.txt</include>
+            <include>NOTICE.txt</include>
+          </includes>
+        </resource>
+
+      </resources>
+      <jars></jars>
+    </build>
+    
+    <reports>
+    	<report>maven-jxr-plugin</report>
+    	<report>maven-license-plugin</report>
+        <!-- report>maven-changelog-plugin</report -->
+        <report>maven-javadoc-plugin</report>
+        <report>maven-clover-plugin</report>
+    	<report>maven-tasklist-plugin</report>
+    </reports>
+</project>
\ No newline at end of file

Added: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/utils/DNUtils.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/utils/DNUtils.java?view=auto&rev=158215
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/utils/DNUtils.java (added)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/utils/DNUtils.java Sat Mar 19 00:01:15 2005
@@ -0,0 +1,716 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.asn1.ldap.utils;
+
+/**
+ * Utility class used by the DN Parser.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public class DNUtils
+{
+    //~ Static fields/initializers -----------------------------------------------------------------
+
+    /** <safe-init-char>    ::= [0x01-0x09] | 0x0B | 0x0C | [0x0E-0x1F] | [0x21-0x39] | 0x3B | [0x3D-0x7F] */
+    private static final boolean[] SAFE_INIT_CHAR =
+    {
+        false, true, true,  true, true,  true,  true, true, 
+		true,  true, false, true, true,  false, true, true,
+        true,  true, true,  true, true,  true,  true, true, 
+		true,  true, true,  true, true,  true,  true, true,
+        false, true, true,  true, true,  true,  true, true, 
+		true,  true, true,  true, true,  true,  true, true,
+        true,  true, true,  true, true,  true,  true, true, 
+		true,  true, false, true, false, true,  true, true,
+        true,  true, true,  true, true,  true,  true, true, 
+		true,  true, true,  true, true,  true,  true, true,
+        true,  true, true,  true, true,  true,  true, true, 
+		true,  true, true,  true, true,  true,  true, true,
+        true,  true, true,  true, true,  true,  true, true, 
+		true,  true, true,  true, true,  true,  true, true,
+        true,  true, true,  true, true,  true,  true, true, 
+		true,  true, true,  true, true,  true,  true, true
+    };
+
+    /** <safe-char>        ::= [0x01-0x09] | 0x0B | 0x0C | [0x0E-0x7F] */
+    private static final boolean[] SAFE_CHAR =
+    {
+        false, true, true,  true, true, true,  true, true, 
+		true,  true, false, true, true, false, true, true, 
+        true,  true, true,  true, true, true,  true, true, 
+		true,  true, true,  true, true, true,  true, true, 
+        true,  true, true,  true, true, true,  true, true, 
+		true,  true, true,  true, true, true,  true, true, 
+        true,  true, true,  true, true, true,  true, true, 
+		true,  true, true,  true, true, true,  true, true, 
+        true,  true, true,  true, true, true,  true, true, 
+		true,  true, true,  true, true, true,  true, true, 
+        true,  true, true,  true, true, true,  true, true, 
+		true,  true, true,  true, true, true,  true, true, 
+        true,  true, true,  true, true, true,  true, true, 
+		true,  true, true,  true, true, true,  true, true, 
+        true,  true, true,  true, true, true,  true, true, 
+		true,  true, true,  true, true, true,  true, true 
+    };
+
+    /** <base64-char>    ::= 0x2B | 0x2F | [0x30-0x39] | 0x3D | [0x41-0x5A] | [0x61-0x7A] */
+    private static final boolean[] BASE64_CHAR =
+    {
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false, 
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false, 
+        false, false, false, false, false, false, false, false, 
+		false, false, false, true,  false, false, false, true, 
+        true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  false, false, false, true,  false, false, 
+        false, true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  true,  true,  true,  true,  true, 
+        true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  false, false, false, false, false, 
+        false, true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  true,  true,  true,  true,  true, 
+        true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  false, false, false, false, false 
+    };
+
+    /** <alpha>    ::= [0x41-0x5A] | [0x61-0x7A] */
+    private static final boolean[] ALPHA =
+    {
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  false, false, false, false, false,
+        false, true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  true,  true,  true,  true,  true,
+        true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  false, false, false, false, false
+    };
+
+    /** <alpha> | <digit> | '-' */
+    private static final boolean[] CHAR =
+    {
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, true,  false, false,
+        true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  false, false, false, false, false, false,
+        false, true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  true,  true,  true,  true,  true,
+        true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  false, false, false, false, false,
+        false, true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  true,  true,  true,  true,  true,
+        true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  false, false, false, false, false
+    };
+
+    /** '\'  | '"'  | '#'  | '+'  | ','  | [0-9] | ';'  | '<'  | '='  | '>'  | [A-Z] | [a-z] 
+     * 0x1C | 0x22 | 0x23 | 0x2B | 0x2C | [0x30-0x39] | 0x3B | 0x3C | 0x3D | 0x3E | [0x41-0x5A] | [0x61-0x7A] */
+    private static final boolean[] PAIR_CHAR =
+    {
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, true,  false, false, false,
+        false, false, true,  true,  false, false, false, false, 
+		false, false, false, true,  true,  false, false, false,
+        true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  false, true,  true,  true,  true,  false,
+        false, true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  true,  true,  true,  true,  true,
+        true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  false, false, false, false, false,
+        false, true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  true,  true,  true,  true,  true,
+        true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  false, false, false, false, false
+    };
+
+    /** '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' */
+    private static final boolean[] DIGIT =
+    {
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+    };
+
+    /** <hex>    ::= [0x30-0x39] | [0x41-0x46] | [0x61-0x66] */
+    private static final boolean[] HEX =
+    {
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  false, false, false, false, false, false,
+        false, true,  true,  true,  true,  true,  true,  false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, true,  true,  true,  true,  true,  true,  false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false
+    };
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Test if the current character is equal to a specific character
+     *
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     * @param car The character we want to compare with the current buffer position
+     *
+     * @return <code>true</code> if the current character equals the given character.
+     */
+    public static boolean isChar( byte[] byteArray, int index, char car )
+    {
+
+        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= byteArray.length ) )
+        {
+
+            return false;
+        }
+        else
+        {
+
+            return ( ( byteArray[index] == ( byte ) car ) ? true : false );
+        }
+    }
+
+    /**
+     * Test if the current character is a digit
+     * <digit>    ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
+     *
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return <code>true</code> if the current character is a Digit
+     */
+    public static boolean isDigit( byte[] byteArray, int index )
+    {
+
+        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= byteArray.length ) )
+        {
+
+            return false;
+        }
+        else
+        {
+
+            return ( ( ( byteArray[index] > 0 ) && DIGIT[byteArray[index]] ) ? true : false );
+        }
+    }
+
+    /**
+     * Test if the current character is a digit
+     * <digit>    ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
+     *
+     * @param byteArray The buffer which contains the data
+     *
+     * @return <code>true</code> if the current character is a Digit
+     */
+    public static boolean isDigit( byte[] byteArray )
+    {
+
+        if ( ( byteArray == null ) || ( byteArray.length == 0 ) )
+        {
+
+            return false;
+        }
+        else
+        {
+
+            return ( ( ( byteArray[0] > 0 ) && DIGIT[byteArray[0]] ) ? true : false );
+        }
+    }
+
+    /**
+     * Walk the buffer while characters are Safe String characters :
+     *  <safe-string>    ::= <safe-init-char> <safe-chars>
+     *  <safe-init-char> ::= [0x01-0x09] | 0x0B | 0x0C | [0x0E-0x1F] | [0x21-0x39] | 0x3B | [0x3D-0x7F]
+     *  <safe-chars>     ::= <safe-char> <safe-chars> |
+     *  <safe-char>      ::= [0x01-0x09] | 0x0B | 0x0C | [0x0E-0x7F]
+     *
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return The position of the first character which is not a Safe Char
+     */
+    public static int parseSafeString( byte[] byteArray, int index )
+    {
+
+        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= byteArray.length ) )
+        {
+
+            return -1;
+        }
+        else
+        {
+
+            byte c = byteArray[index];
+
+            if ( ( c < 0 ) || ( SAFE_INIT_CHAR[c] == false ) )
+            {
+
+                return -1;
+            }
+
+            index++;
+
+            while ( index < byteArray.length )
+            {
+                c = byteArray[index];
+
+                if ( ( c < 0 ) || ( SAFE_CHAR[c] == false ) )
+                {
+
+                    break;
+                }
+
+                index++;
+            }
+
+            return index;
+        }
+    }
+
+    /**
+     * Walk the buffer while characters are Alpha characters :
+     *  <alpha>    ::= [0x41-0x5A] | [0x61-0x7A]
+     * 
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return The position of the first character which is not an Alpha Char
+     */
+    public static int parseAlpha( byte[] byteArray, int index )
+    {
+
+        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= byteArray.length ) )
+        {
+
+            return -1;
+        }
+        else
+        {
+
+            byte c = byteArray[index++];
+
+            if ( ( c < 0 ) || ( ALPHA[c] == false ) )
+            {
+
+                return -1;
+            }
+            else
+            {
+
+                return index;
+            }
+        }
+    }
+
+    /**
+     * Check if the current character is an Hex Char
+     *  <hex>    ::= [0x30-0x39] | [0x41-0x46] | [0x61-0x66]
+     * 
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return <code>true</code> if the current character is a Hex Char
+     */
+    public static boolean isHex( byte[] byteArray, int index )
+    {
+
+        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= byteArray.length ) )
+        {
+
+            return false;
+        }
+        else
+        {
+
+            byte c = byteArray[index++];
+
+            if ( ( c < 0 ) || ( HEX[c] == false ) )
+            {
+
+                return false;
+            }
+            else
+            {
+
+                return true;
+            }
+        }
+    }
+
+    /**
+     * Check if the current character is a Pair Char
+     *  <pairchar>    ::= ',' | '=' | '+' | '<' | '>' | '#' | ';' | '\' | '"' | [0-9a-fA-F] [0-9a-fA-F]
+     * 
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return <code>true</code> if the current character is a Pair Char
+     */
+    public static boolean isPairChar( byte[] byteArray, int index )
+    {
+
+        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= byteArray.length ) )
+        {
+
+            return false;
+        }
+        else
+        {
+
+            byte c = byteArray[index++];
+
+            if ( ( c < 0 ) || ( PAIR_CHAR[c] == false ) )
+            {
+
+                return false;
+            }
+            else
+            {
+
+                return true;
+            }
+        }
+    }
+
+    /**
+     * Check if the current character is a String Char
+     *  <stringchar>    ::= [0x00-0xFF] - [,=+<>#;\"\n\r]
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return <code>true</code> if the current character is a String Char
+     */
+    public static boolean isStringChar( byte[] byteArray, int index )
+    {
+
+        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= byteArray.length ) )
+        {
+
+            return false;
+        }
+        else
+        {
+
+            byte c = byteArray[index++];
+
+            if ( ( c == ( byte ) 0x0A ) ||
+                    ( c == ( byte ) 0x0D ) ||
+                    ( c == ( byte ) '"' ) ||
+                    ( c == ( byte ) '#' ) ||
+                    ( c == ( byte ) '+' ) ||
+                    ( c == ( byte ) ',' ) ||
+                    ( c == ( byte ) ';' ) ||
+                    ( c == ( byte ) '<' ) ||
+                    ( c == ( byte ) '=' ) ||
+                    ( c == ( byte ) '>' ) )
+            {
+
+                return false;
+            }
+            else
+            {
+
+                return true;
+            }
+        }
+    }
+
+    /**
+     * Check if the current character is a Quote Char
+     *  <quotechar>    ::= [0x00-0xFF] - [\"]
+     * 
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return <code>true</code> if the current character is a Quote Char
+     */
+    public static boolean isQuoteChar( byte[] byteArray, int index )
+    {
+
+        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= byteArray.length ) )
+        {
+
+            return false;
+        }
+        else
+        {
+
+            byte c = byteArray[index++];
+
+            if ( ( c == ( byte ) '\\' ) || ( c == ( byte ) '"' ) )
+            {
+
+                return false;
+            }
+            else
+            {
+
+                return true;
+            }
+        }
+    }
+
+    /**
+     * Parse an hex pair
+     *   <hexpair>    ::= <hex> <hex>
+     *
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return The new position  
+     */
+    public static int parseHexPair( byte[] byteArray, int index )
+    {
+
+        if ( isHex( byteArray, index ) && isHex( byteArray, index + 1 ) )
+        {
+
+            return index + 2;
+        }
+        else
+        {
+
+            return -1;
+        }
+    }
+
+    /**
+     * Parse an hex string, which is a list of hex pairs
+     *  <hexstring>    ::= <hexpair> <hexpairs>
+     *  <hexpairs>    ::= <hexpair> <hexpairs> | e
+     *
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return Return the first position which is not an hex pair
+     */
+    public static int parseHexString( byte[] byteArray, int index )
+    {
+
+        if ( parseHexPair( byteArray, index ) == -1 )
+        {
+
+            return -1;
+        }
+        else
+        {
+            index += 2;
+        }
+
+        while ( parseHexPair( byteArray, index ) != -1 )
+        {
+            index += 2;
+        }
+
+        return index;
+    }
+
+    /**
+     * Check if the current character is a CHAR.
+     *   <char>    ::= <alpha> | <digit> | '-'
+     *
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return The position of the next character, if the current one is a CHAR.
+     */
+    public static int parseChar( byte[] byteArray, int index )
+    {
+
+        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= byteArray.length ) )
+        {
+
+            return -1;
+        }
+        else
+        {
+
+            byte c = byteArray[index++];
+
+            if ( ( c < 0 ) || ( CHAR[c] == false ) )
+            {
+
+                return -1;
+            }
+            else
+            {
+
+                return index;
+            }
+        }
+    }
+
+    /**
+     * Walk the buffer while characters are Base64 characters : 
+     * 	<base64-string>      ::= <base64-char> <base64-chars>
+     *  <base64-chars>       ::= <base64-char> <base64-chars> |
+     *  <base64-char>        ::= 0x2B | 0x2F | [0x30-0x39] | 0x3D | [0x41-0x5A] | [0x61-0x7A]
+     *
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return The position of the first character which is not a Base64 Char
+     */
+    public static int parseBase64String( byte[] byteArray, int index )
+    {
+
+        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= byteArray.length ) )
+        {
+
+            return -1;
+        }
+        else
+        {
+
+            byte c = byteArray[index];
+
+            if ( ( c < 0 ) || ( BASE64_CHAR[c] == false ) )
+            {
+
+                return -1;
+            }
+
+            index++;
+
+            while ( index < byteArray.length )
+            {
+                c = byteArray[index];
+
+                if ( ( c < 0 ) || ( BASE64_CHAR[c] == false ) )
+                {
+
+                    break;
+                }
+
+                index++;
+            }
+
+            return index;
+        }
+    }
+
+    /**
+     * Check if a text is present at the current position in a buffer.
+     *
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     * @param text The text we want to check
+     *
+     * @return <code>true</code> if the buffer contains the text.
+     */
+    public static int areEquals( byte[] byteArray, int index, String text )
+    {
+
+        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( byteArray.length <= index ) ||
+                ( index < 0 ) || ( text == null ) )
+        {
+
+            return -1;
+        }
+        else
+        {
+
+        	return areEquals(byteArray, index, text.getBytes());
+        }
+    }
+
+    /**
+     * Check if a text is present at the current position in a buffer.
+     *
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     * @param byteArray2 The text we want to check
+     *
+     * @return <code>true</code> if the buffer contains the text.
+     */
+    public static int areEquals( byte[] byteArray, int index, byte[] byteArray2 )
+    {
+
+        if ( ( byteArray == null ) || 
+        		( byteArray.length == 0 ) || 
+				( byteArray.length <= index ) ||
+                ( index < 0 ) || 
+				( byteArray2 == null ) || 
+				( byteArray2.length == 0 ) || 
+				( byteArray2.length > byteArray.length + index ) )
+        {
+
+            return -1;
+        }
+        else
+        {
+
+            for ( int i = 0; i < byteArray2.length; i++ )
+            {
+
+                if ( byteArray[index++] != byteArray2[i] )
+                {
+
+                    return -1;
+                }
+            }
+
+            return index;
+        }
+    }
+}

Added: directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/utils/DNUtilsTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/utils/DNUtilsTest.java?view=auto&rev=158215
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/utils/DNUtilsTest.java (added)
+++ directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/utils/DNUtilsTest.java Sat Mar 19 00:01:15 2005
@@ -0,0 +1,62 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.asn1.ldap.utils;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+
+/**
+ * Test the class DNUtils
+ */
+public class DNUtilsTest extends TestCase
+{
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Test the DNUtils AreEquals method
+     */
+    public void testAreEquals()
+    {
+
+        // Full compare
+        Assert.assertEquals( 6, DNUtils.areEquals( "azerty".getBytes(), 0, "azerty" ) );
+
+        // First character is !=
+        Assert.assertEquals( -1, DNUtils.areEquals( "azerty".getBytes(), 0, "Azerty" ) );
+
+        // Compare to an empty string
+        Assert.assertEquals( -1, DNUtils.areEquals( "azerty".getBytes(), 0, "" ) );
+
+        // Index must be incremented after each comparison
+        Assert.assertEquals( 1, DNUtils.areEquals( "azerty".getBytes(), 0, "a" ) );
+        Assert.assertEquals( 2, DNUtils.areEquals( "azerty".getBytes(), 1, "z" ) );
+        Assert.assertEquals( 3, DNUtils.areEquals( "azerty".getBytes(), 2, "e" ) );
+        Assert.assertEquals( 4, DNUtils.areEquals( "azerty".getBytes(), 3, "r" ) );
+        Assert.assertEquals( 5, DNUtils.areEquals( "azerty".getBytes(), 4, "t" ) );
+        Assert.assertEquals( 6, DNUtils.areEquals( "azerty".getBytes(), 5, "y" ) );
+
+        // length too short
+        Assert.assertEquals( -1, DNUtils.areEquals( "azerty".getBytes(), 5, "azerty" ) );
+
+        // last character
+        Assert.assertEquals( 6, DNUtils.areEquals( "azerty".getBytes(), 5, "y" ) );
+
+        // In the middle
+        Assert.assertEquals( 4, DNUtils.areEquals( "azerty".getBytes(), 2, "er" ) );
+    }
+}



Mime
View raw message