harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r507703 [2/9] - in /harmony/enhanced/classlib/trunk/modules: jndi/META-INF/ jndi/make/ jndi/src/main/java/javax/naming/ldap/ jndi/src/main/java/org/apache/harmony/jndi/internal/ jndi/src/main/java/org/apache/harmony/jndi/internal/nls/ jndi/...
Date Wed, 14 Feb 2007 21:42:44 GMT
Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/nls/messages.properties?view=diff&rev=507703&r1=507702&r2=507703
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/nls/messages.properties (original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/nls/messages.properties Wed Feb 14 13:42:41 2007
@@ -1,160 +1,54 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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
-#  
+#  Licensed to the Apache Software Foundation (ASF) under one or more
+#  contributor license agreements.  See the NOTICE file distributed with
+#  this work for additional information regarding copyright ownership.
+#  The ASF licenses this file to You 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.
-# 
 
 # messages for EN locale
-jndi.00=name must not be null
-jndi.01=full name doesn't apply to this binding
-jndi.02=Invalid name.
-jndi.03=Failed to clone object of Reference class.
-jndi.04=Illegal direction property value, which must be one of right_to_left, left_to_right or flat
-jndi.05=jndi.syntax.separator property must be set when jndi.syntax.direction is not flat
-jndi.06=The {0} cannot be at end of the component
-jndi.07={0}: close quote must appears at end of component in quoted string
-jndi.08={0}: close quote is required for quoted string
-jndi.09={0} is not a compound name.
-jndi.0A=A flat name can only have a single component
-jndi.0B=A flat name can only zero or one component
-jndi.0C=End quote is not at the end of element
-jndi.0D=Escape cannot be at the end of element
-jndi.0E=Wrong quote usage.
-jndi.0F=Must be a CompositeName
-jndi.10=Found invalid name, reason: {0}
-jndi.11=This is an invalid LinkRef object\!
-jndi.12=There is no address with type: {0}
-jndi.13=Non-null attribute is required for modification
-jndi.14=Modification code {0} must be one of DirContext.ADD_ATTRIBUTE, DirContext.REPLACE_ATTRIBUTE and DirContext.REMOVE_ATTRIBUTE
-jndi.15=Failed to clone object of BasicAttributes class.
-jndi.16=Value already exists.
-jndi.17=Failed to clone object of BasicAttribute class.
-jndi.18=No values available.
-jndi.19=BasicAttribute does not support this operation.
-jndi.1A=Cannot create initial context.
-jndi.1B=DirContext object is required.
-jndi.1C=class {0} not found
-jndi.1D=Expected an LdapContext object.
-jndi.1E=InitialContextFactoryBuilder cannot be reset
-jndi.1F=ObjectFactoryBuilder cannot be reset
-jndi.20=Failed to create InitialContext using factory specified in hashtable {0}
-jndi.21=Failed to create object instance
-jndi.22=other exception happens: {0}
-jndi.23=Failed to load JNDI resource files.
-jndi.24=Failed to read JNDI resource files.
-jndi.25=Failed to read JNDI resource files in java home library.
-jndi.26=URL context can't accept non-composite name: {0}
-jndi.27=Renaming of names of which one has only one component, and another has more than one component is not supported: {0} -> {1}
-jndi.28=Renaming of names using different URLs as their first components is not supported: {0} -> {1}
-jndi.29=Renaming of names using different URL prefixes is not supported: {0} -> {1}
-jndi.2A=Invalid URL: {0}
-jndi.2B=Invalid URL format: {0}
-jndi.2C=obj is an empty string array
-jndi.2D=obj is neither null, nor a string, nor a string array: {0}
-jndi.2E=The name is null
-jndi.2F=Given name is not an instance of DNSName class
-jndi.30={0} can't be used as a component for DNS name
-jndi.31=Given name is not an instance of DNSName class
-jndi.32=buffer is null
-jndi.33=Given resultQR is null
-jndi.34=hostname is null
-jndi.35=Invalid number of fields while parsing SOA record
-jndi.36=Error while parsing SOA record
-jndi.37=Invalid number of fields while parsing MX record
-jndi.38=Error while parsing MX record
-jndi.39=Invalid number of fields while parsing HINFO record
-jndi.3A=The length of character string exceed 255 octets
-jndi.3B=Length of TXT field exceed 65535
-jndi.3C=Invalid number of fields while parsing SRV record
-jndi.3D=Error while parsing SRV record
-jndi.3E=RDATA for unknown record type {0} should have value of byte[] type
-jndi.3F=Given resultRR is null
-jndi.40=Unable to connect: bad IP address
-jndi.41=Error while querying DNS server
-jndi.42=unknown error
-jndi.43=Output buffer is too small
-jndi.44=Error while receiving message over TCP
-jndi.45=environment is null
-jndi.46=DNS class {0} is not supported
-jndi.47=DNS type {0} is not supported
-jndi.48=conflicting domains: {0} and {1}
-jndi.49=Unable to parse DNS URL {0}. {1}
-jndi.4A=found object is not a DirContext
-jndi.4B=Only instances of CompositeName class or DNSName class are acceptable
-jndi.4C=Unknown record class: {0}
-jndi.4D=Unknown record type: {0}
-jndi.4E=found object is not a Context
-jndi.4F=found object is not a Context or target contexts are not equal
-jndi.50=contentSwt should be equal to 1 or 2
-jndi.51=Given name of prefix is null
-jndi.52=Can't append an absolute DNS name
-jndi.53=Root domain should be the rightmost one
-jndi.54=The length of the name is more than 255 characters
-jndi.55=Null label is not the rightmost one
-jndi.56=DNS name shouldn't start with a dot
-jndi.57=The length of {0} label is more than 63 characters
-jndi.58=The value of parameter mesObj is null
-jndi.59=Domain label is too long.
-jndi.5A=The domain name is more than {0} octets long: {1}
-jndi.5B=Input byte array is null
-jndi.5C=The result string buffer is null
-jndi.5D=Truncated data while parsing the domain name
-jndi.5E=value or buffer is null
-jndi.5F=Character string is too long
-jndi.60=mesBytes or result is null
-jndi.61=Given array is null or has the length less than four
-jndi.62=Given string is not in appropriate format
-jndi.63=Given string representation is null
-jndi.64=The domain label is too long: {0}
-jndi.65=obj should be either null, String or array of String
-jndi.66=Extra characters encountered at the end of the URL
-jndi.67=strForm is null
-jndi.68=Empty URL
-jndi.69=Specified scheme is not dns
-jndi.6A=Bad URL syntax
-jndi.6B=types is null
-jndi.6C=classes is null
-jndi.6D=Name {0} was not found
-jndi.6E=Unable to perform zone transfer
-jndi.6F=Both name and IP are null
-jndi.70=zoneName is null
-jndi.71=no question record
-jndi.72=Request and Answer have different ids
-jndi.73=no question record
-jndi.74=Not an RMI URL, incorrect prefix: {0}
-jndi.75=Invalid port number in URL: {0}
-jndi.76=Object instantiated using the URL specified in environment is not a context: {0}
-jndi.77=Reference is empty
-jndi.78=Reference contains no valid addresses
-jndi.79=RMI Client Socket Factory cannot be instantiated
-jndi.7A=Name is not bound: {0}
-jndi.7B=Cannot bind empty name
-jndi.7C=Name is already bound: {0}
-jndi.7D=Cannot rebind empty name
-jndi.7E=Cannot unbind empty name
-jndi.7F=RMI Registry is a flat context and doesn't support subcontexts
-jndi.80=Name specifies an object that is not a context: {0}
-jndi.81=Cannot create reference for RMI registry that is being accessed using localhost
-jndi.82=Cannot bind to RMI Registry object that is neither Remote nor Reference nor Referenceable
-jndi.83=NamingManager.getObjectInstance() failed
-jndi.84=Cannot install RMISecurityManager
-jndi.85=Error unmarshalling return value
-jndi.86=Undeclared checked exception
-jndi.87=Invalid method hash: {0}
-jndi.88=Interface hash mismatch, expected: {0}, received: {1}
-jndi.89=Error marshalling return
-jndi.8A=Invalid method number: {0}
-jndi.8B=attrs must not be null
-jndi.8C=component must not be null
-
-jndi.err.00=. The stack trace of the root exception is: 
+ldap.00=Should not be null
+ldap.01=is not an LdapName
+ldap.02=Posn must be in the range [0,size()]
+ldap.03=should not be empty!
+ldap.04=is empty!
+ldap.05=The index must be in the range [0,size()]
+ldap.06=obj is null or not an instance of Rdn
+ldap.07=StartTLS received a wrong response instead of 1.3.6.1.4.1.1466.20037:
+ldap.08=Could not instantiate any StartTLSResponse implementation class...
+ldap.09=No specific StartTLSResponse implementation classes defined to instantiate...
+ldap.0A=[LDAP: error code 1 - operationsError: server internal failure]
+ldap.0B=[LDAP: error code 2 - Protocol error]
+ldap.0C=[LDAP: error code 3 - timeLimitExceeded: timelimit reached before sorting was completed]
+ldap.0D=[LDAP: error code 4 - Size limit exceeded]
+ldap.0E=[LDAP: error code 7 - Authentication method not supported]
+ldap.0F=[LDAP: error code 8 - strongAuthRequired: refused to return sorted results via insecure protocol]
+ldap.10=[LDAP: error code 9 - Partial results being returned]
+ldap.1B=[LDAP: error code 11 - adminLimitExceeded: too many matching entries for the server to sort]
+ldap.1C=[LDAP: error code 16 - noSuchAttribute: unrecognized attribute type in sort key]
+ldap.11=[LDAP: error code 18 - inappropriateMatching: unrecognized or inappropriate matching rule in sort key]
+ldap.12=[LDAP: error code 50 - insufficientAccessRights: refused to return sorted results to this client]
+ldap.13=[LDAP: error code 51 - busy:  too busy to process]
+ldap.14=[LDAP: error code 53 - unwillingToPerform: unable to sort]
+ldap.15=[LDAP: error code 80 - other: unknown]
+ldap.16=[LDAP: error code 
+ldap.17=Invalid name: 
+ldap.18=The type must not be empty: 
+ldap.19=obj is not an instance of String or byte array
+ldap.1A=Cannot convert hex String to UTF8
+ldap.1B=Method not implemented
+ldap.1C=An equal symbol was not found!
+ldap.1D=The type should not contain quotation
+ldap.1E=The type should not contain any of the following special characters
+ldap.1F=Invalid Relative distinguished name string
+ldap.20=Invalid Hex Character
+ldap.21=was not found
+ldap.22=foundObjects is null
+ldap.23= not found in jar file 
\ No newline at end of file

Added: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/AttributeTypeAndValuePair.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/AttributeTypeAndValuePair.java?view=auto&rev=507703
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/AttributeTypeAndValuePair.java (added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/AttributeTypeAndValuePair.java Wed Feb 14 13:42:41 2007
@@ -0,0 +1,62 @@
+/* 
+ *  Licensed to the Apache Software Foundation (ASF) under one or more 
+ *  contributor license agreements.  See the NOTICE file distributed with 
+ *  this work for additional information regarding copyright ownership. 
+ *  The ASF licenses this file to You 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.harmony.jndi.internal.parser;
+
+/**
+ * Represents a Type And a Value Pair
+ * 
+ * @author Osvaldo C. Demo
+ */
+public class AttributeTypeAndValuePair {
+
+    private Object value;
+
+    private String type;
+
+    /**
+     * Constructor
+     * 
+     * @param id
+     *            the Type
+     * @param object
+     *            the Value
+     */
+    public AttributeTypeAndValuePair(String id, Object object) {
+        this.value = object;
+        this.type = id;
+    }
+
+    /**
+     * Getter for value
+     * 
+     * @return the value
+     */
+    public Object getValue() {
+        return value;
+    }
+
+    /**
+     * Getter for type
+     * 
+     * @return the type
+     */
+    public String getType() {
+        return type;
+    }
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/AttributeTypeAndValuePair.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapNameParser.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapNameParser.java?view=auto&rev=507703
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapNameParser.java (added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapNameParser.java Wed Feb 14 13:42:41 2007
@@ -0,0 +1,86 @@
+/* 
+ *  Licensed to the Apache Software Foundation (ASF) under one or more 
+ *  contributor license agreements.  See the NOTICE file distributed with 
+ *  this work for additional information regarding copyright ownership. 
+ *  The ASF licenses this file to You 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.harmony.jndi.internal.parser;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.naming.InvalidNameException;
+import javax.naming.Name;
+import javax.naming.NameParser;
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapName;
+import javax.naming.ldap.Rdn;
+
+/**
+ * A Distinguised Name Parser according with the RFC2253 and RFC1779 for use
+ * with LdapName only
+ * 
+ * @author Osvaldo C. Demo
+ * @author Juan Giannuzzo
+ */
+public class LdapNameParser implements NameParser, LdapParser {
+    private String s = null;
+
+    /**
+     * Constructor
+     * 
+     * @param s
+     *            the string to parse
+     */
+    public LdapNameParser(String s) {
+        this.s = s;
+    }
+
+    /**
+     * For using with the NameParser interface
+     * 
+     * @return an LdapName if possible
+     */
+    public Name parse(String arg0) throws NamingException {
+        return new LdapName(arg0);
+    }
+
+    /**
+     * Returns the parsed list of Rdns
+     */
+    public List getList() throws InvalidNameException {
+        List list = new ArrayList();
+        int from = 0;
+        char[] c = s.toCharArray();
+
+        if (s.compareTo("") == 0)
+            return list;
+        if (s.startsWith(",") || s.startsWith(";"))
+            throw new InvalidNameException("Invalid name: " + s);
+
+        for (int i = 0; i < c.length; i++) {
+            if ((c[i] == ',' || c[i] == ';') && c[i - 1] != '\\') {
+
+                if (s.substring(from, i).compareTo("") == 0)
+                    throw new InvalidNameException("Invalid name: " + s);
+                list.add(new Rdn(s.substring(from, i)));
+                from = i + 1;
+            }
+        }
+        list.add(new Rdn(s.substring(from, s.length())));
+        Collections.reverse(list);
+        return list;
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapNameParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapParser.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapParser.java?view=auto&rev=507703
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapParser.java (added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapParser.java Wed Feb 14 13:42:41 2007
@@ -0,0 +1,34 @@
+/* 
+ *  Licensed to the Apache Software Foundation (ASF) under one or more 
+ *  contributor license agreements.  See the NOTICE file distributed with 
+ *  this work for additional information regarding copyright ownership. 
+ *  The ASF licenses this file to You 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.harmony.jndi.internal.parser;
+
+import java.util.List;
+
+import javax.naming.InvalidNameException;
+
+/**
+ * Should be used when implementing a new Distinguished Name Parser
+ * 
+ * @author Juan Giannuzzo
+ * 
+ */
+public interface LdapParser {
+
+    public List getList() throws InvalidNameException;
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapRdnParser.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapRdnParser.java?view=auto&rev=507703
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapRdnParser.java (added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapRdnParser.java Wed Feb 14 13:42:41 2007
@@ -0,0 +1,222 @@
+/* 
+ *  Licensed to the Apache Software Foundation (ASF) under one or more 
+ *  contributor license agreements.  See the NOTICE file distributed with 
+ *  this work for additional information regarding copyright ownership. 
+ *  The ASF licenses this file to You 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.harmony.jndi.internal.parser;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.naming.InvalidNameException;
+
+import org.apache.harmony.jndi.internal.nls.Messages;
+
+/**
+ * Class used to parse RDN components of a Distinguished name
+ * 
+ * @author Osvaldo C. Demo
+ * 
+ */
+public class LdapRdnParser implements LdapParser {
+
+    private static String name = null;
+
+    LdapTypeAndValueList list = new LdapTypeAndValueList();
+
+    private List attrList;
+
+    private List listAll;
+
+    private RelaxedDnParser parser = null;
+
+    /**
+     * Constructor
+     */
+    public LdapRdnParser(String name) {
+        if (name.endsWith("+")) {
+            LdapRdnParser.name = name.substring(0, name.lastIndexOf('+'));
+        } else {
+            LdapRdnParser.name = name;
+        }
+    }
+
+    /**
+     * Used to get the list of Type/Values
+     */
+    public List getList() throws InvalidNameException {
+        try {
+            checkTypeRestrictions(name);
+            parser = new RelaxedDnParser(name);
+            listAll = (List) parser.parse();
+        } catch (IOException e) {
+            throw new InvalidNameException(Messages.getString("ldap.17") + name);
+        }
+        attrList = (List) listAll.get(0);
+        for (Iterator iter = attrList.iterator(); iter.hasNext();) {
+            AttributeTypeAndValuePair element = (AttributeTypeAndValuePair) iter
+                    .next();
+            list.put(element.getType(), element.getValue());
+        }
+        return list.toAttributeList();
+    }
+
+    private void checkTypeRestrictions(String rdn) throws InvalidNameException {
+        int in = rdn.indexOf("=");
+        try {
+            if (rdn.substring(0, in).length() == 0) {
+                throw new InvalidNameException(Messages.getString("ldap.18")
+                        + rdn);
+            }
+        } catch (StringIndexOutOfBoundsException e) {
+            throw new InvalidNameException(Messages.getString("ldap.17") + rdn);
+        }
+    }
+
+    /**
+     * returns a string escaped according to the rules specified in RFC 2253.
+     * 
+     * @param obj
+     *            the String or byteArray to escape
+     * @return The escaped value
+     * @throws ClassCastException
+     *             when obj is not an instance of String or ByteArray
+     */
+    public static String escapeValue(Object obj) {
+        if (obj instanceof String) {
+            String val = String.valueOf((String) obj);
+            return getEscaped(val.toCharArray().clone());
+        } else if (obj instanceof byte[]) {
+            return getHexValues((byte[]) obj);
+        } else {
+            throw new ClassCastException(Messages.getString("ldap.19"));
+        }
+    }
+
+    private static String getEscaped(char[] chars) {
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0; i < chars.length; i++) {
+            if (isSpecialChar(chars, i))
+                sb.append("\\");
+            sb.append(new Character(chars[i]));
+        }
+        return sb.toString();
+    }
+
+    private static String getHexValues(byte[] byteArray) {
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0; i < byteArray.length; i++) {
+            sb.append(Integer.toHexString(byteArray[i] >> 4 & 0x0F));
+            sb.append(Integer.toHexString(byteArray[i] & 0x0F)); 
+        }
+        return "#" + sb.toString();
+    }
+
+    /**
+     * Given an attribute value string formated according to the rules specified
+     * in RFC 2253, returns the unescaped value.
+     * 
+     * @param val
+     *            String to unescape
+     * @return the unescaped value (String or ByteArray)
+     */
+    public static Object unescapeValue(String val) {
+        if (val.startsWith("#") && numeralCounter(val)) {
+            return getByteFromHexString(val);
+        } else if (val.startsWith("#")) {
+            return getByteFromHexString(val);
+        } else {
+            char[] chars = new String(val.trim()).toCharArray();
+            return getUnEscapedValues(chars);
+        }
+
+    }
+
+    private static boolean numeralCounter(String val) {
+        int counter = 0;
+        for (int i = 0; i < val.length(); i++) {
+            if (val.charAt(i) == '#') {
+                counter++;
+            }
+        }
+        if (counter == 1) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private static String getUnEscapedValues(char[] chars) {
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0; i < chars.length; i++) {
+            if (chars[i] != '\\') {
+                sb.append(chars[i]);
+            } else {
+                try {
+                    if (!isSpecialChar(chars, i + 1)
+                            && !isSpecialChar(chars, i + 2)) {
+                        try {
+                            sb.append(RelaxedDnParser.hexToUTF8(new String(
+                                    chars, i + 1, 2)));
+                            i = i + 2;
+                        } catch (IOException e) {
+                            throw new IllegalArgumentException(Messages.getString("ldap.1A"));
+                        }
+                    }
+                } catch (ArrayIndexOutOfBoundsException e) {
+
+                }
+
+            }
+        }
+        return sb.toString();
+    }
+
+    private static byte[] getByteFromHexString(String val) {
+        String str = val.substring(val.indexOf("#") + 1);
+        if (str.length() % 2 != 0) {
+            throw new IllegalArgumentException(Messages.getString("ldap.1A"));
+        }
+        byte[] ret = null;
+        try {
+            ret = new byte[str.length() / 2];
+            for (int i = 0; i < ret.length; i++) {
+                ret[i] = (byte) Integer.parseInt(str
+                        .substring(2 * i, 2 * i + 2), 16);
+            }
+        } catch (NumberFormatException e) {
+            throw new IllegalArgumentException(Messages.getString("ldap.17") + val);
+        }
+        return ret;
+    }
+
+    private static boolean isSpecialChar(char[] chars, int index) {
+        switch (chars[index]) {
+        case '"':
+        case '\\':
+        case ',':
+        case '=':
+        case '+':
+        case '<':
+        case '>':
+        case '#':
+        case ';':
+            return true;
+        default:
+            return false;
+        }
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapRdnParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapTypeAndValueList.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapTypeAndValueList.java?view=auto&rev=507703
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapTypeAndValueList.java (added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapTypeAndValueList.java Wed Feb 14 13:42:41 2007
@@ -0,0 +1,216 @@
+/* 
+ *  Licensed to the Apache Software Foundation (ASF) under one or more 
+ *  contributor license agreements.  See the NOTICE file distributed with 
+ *  this work for additional information regarding copyright ownership. 
+ *  The ASF licenses this file to You 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.harmony.jndi.internal.parser;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import javax.naming.directory.BasicAttribute;
+import javax.naming.ldap.Rdn;
+
+import org.apache.harmony.jndi.internal.nls.Messages;
+
+/**
+ * 
+ * This class mantains a list of relative distinguished names
+ * it supports multiple values for any attribute
+ * 
+ * @author Osvaldo C. Demo
+ *
+ */
+public class LdapTypeAndValueList implements Map {
+
+    private List list = null;
+    
+    private static final long serialVersionUID = -4540483835059087783L;
+    
+    private Map attributes = new TreeMap();
+    
+    /**
+     * @return the list size
+     */
+    public int size() {
+        return attributes.size();
+    }
+
+    /**
+     * @return false when is not empty, true otherwise.
+     */
+    public boolean isEmpty() {
+        return attributes.isEmpty();
+    }
+
+    /**
+     * Used to check if a key exists in the list
+     * @return true if the key exists, false otherwise.
+     */
+    public boolean containsKey(Object key) {
+        return attributes.containsKey(key);
+    }
+
+    /**
+     * Used to check if a value exists in the list
+     * @return true if the value exists, false otherwise.
+     */
+    public boolean containsValue(Object value) {
+        return attributes.containsValue(value);
+    }
+
+    /**
+     * Used to get the values list from a key
+     * @return the list of values corresponding to the key
+     */
+    public Object get(Object key) {
+        return attributes.get(key);
+    }
+
+    /**
+     * Used to insert Key/Value pairs
+     * 
+     * @param key the key
+     * @param value a value
+     * @return the list of values corresponding to this key
+     */
+    public Object put(Object key, Object value) {
+        if (attributes.get(new ValueWrapper((String)key)) == null) {
+            list = new ArrayList();
+            list.add(new ValueWrapper(value));
+            attributes.put(new ValueWrapper((String)key),list);
+        } else {
+            list = (List)attributes.get(new ValueWrapper((String)key));
+            list.add(new ValueWrapper(value));
+            Collections.sort(list);
+            attributes.put(new ValueWrapper((String)key),list);
+        }
+        return list;
+    }
+
+    /**
+     * Removes the list of values from the given key
+     */
+    public Object remove(Object key) {
+        return attributes.remove(key);
+    }
+
+    
+    public void putAll(Map map) {
+        throw new UnsupportedOperationException(Messages.getString("ldap.1B")); 
+    }
+
+    /**
+     * Clears all contents of the list
+     */
+    public void clear() {
+        attributes.clear();
+    }
+    
+    public Set keySet() {
+        return attributes.keySet();
+    }
+
+    /**
+     * A list of attributes, each attribute can contain more than one value
+     * 
+     * @return a list of Attribute
+     */
+    public List toAttributeList() {
+        List list = new ArrayList();
+        for (Iterator iter = keySet().iterator(); iter.hasNext();) {
+            ValueWrapper element = (ValueWrapper) iter.next();
+            BasicAttribute ba = new BasicAttribute(element.getStringValue(),true);
+            List list2 = (List)attributes.get(element); 
+            for (Iterator iterator = list2.iterator(); iterator.hasNext();) {
+                ValueWrapper elementList = (ValueWrapper) iterator.next();
+                ba.add(elementList.getValue());    
+            }
+            list.add(ba);
+        }
+        return list;
+    }
+
+    public Collection values() {
+        throw new UnsupportedOperationException(Messages.getString("ldap.1B")); 
+    }
+
+    public Set entrySet() {
+        return attributes.entrySet();
+    }
+    
+    public String toString() {
+        return attributes.toString();
+    }
+    
+    /**
+     * Its a wrapper for String/ByteArray that implements the Comparable interface 
+     * and uses an upper case string value to compare 
+     * 
+     * @author Juan Giannuzzo
+     * @author Osvaldo C. Demo
+     */
+    private class ValueWrapper implements Comparable {
+    	
+        private Object value;
+    	
+        /**
+         * Constructor 
+         * @param value String value to make case insensitive
+         */
+    	ValueWrapper(Object value){
+    		this.value=value;
+    	}
+
+        /**
+         * Returns a String Value for the stored object value
+         * 
+         * @return String value 
+         */
+		public String getStringValue() {
+            if (value instanceof String) {
+                return (String) value;    
+            } else {
+                return Rdn.escapeValue(value);
+            }
+		}
+
+        /**
+         * Getter for value
+         * @return the value object (String or ByteArray)
+         */
+        public Object getValue() {
+            return value;
+        }
+        
+        /**
+         * Used to compare CaseInsensitiveStrings
+         * 
+         * @param obj object to compare
+         * @return 0 when its equal, 1 when its greater, -1 otherwise
+         * @throws ClassCastException when the object is not an instance of CaseInsensitiveString
+         * 
+         */
+        public int compareTo(Object obj) {
+            return getStringValue().toUpperCase().compareTo(((ValueWrapper)obj).getStringValue().toUpperCase());
+		}
+	}
+}
\ No newline at end of file

Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/LdapTypeAndValueList.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/RelaxedDnParser.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/RelaxedDnParser.java?view=auto&rev=507703
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/RelaxedDnParser.java (added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/RelaxedDnParser.java Wed Feb 14 13:42:41 2007
@@ -0,0 +1,205 @@
+/* 
+ *  Licensed to the Apache Software Foundation (ASF) under one or more 
+ *  contributor license agreements.  See the NOTICE file distributed with 
+ *  this work for additional information regarding copyright ownership. 
+ *  The ASF licenses this file to You 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.harmony.jndi.internal.parser;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.naming.ldap.Rdn;
+
+import org.apache.harmony.jndi.internal.nls.Messages;
+import org.apache.harmony.security.x509.DNParser;
+
+/**
+ * A relative distinguised name parser that does less checkings than DNParser
+ * 
+ * @author Osvaldo C. Demo
+ */
+public class RelaxedDnParser extends DNParser {
+
+    private static final char[] specialChars = new char[] { '!', '$', '%', '&',
+            '\'', '(', ')', '*', '/', ':', '<', '=', '>', '?', '@', '[', ']',
+            '^', '_', '`', '{', '|', '}', '~', '\"', '#', '+', ',', '\\', ';' };
+
+    /**
+     * Constructor
+     * 
+     * @param dn
+     *            the String to parse
+     * @throws IOException
+     */
+    public RelaxedDnParser(String dn) throws IOException {
+        super(dn);
+    }
+
+    protected String nextAT() throws IOException {
+        int equalIndex = pos;
+        try {
+            while (chars[equalIndex] != '=') {
+                equalIndex++; // points to the equals on the current attribute
+                // type pair
+            }
+        } catch (ArrayIndexOutOfBoundsException e) {
+            throw new IOException(Messages.getString("ldap.1C"));
+        }
+
+        // Check for quotations and special chars on the type
+        for (int i = pos; i < equalIndex; i++) {
+            if (chars[i] == '\\') {
+                throw new IOException(Messages.getString("ldap.1D"));
+            }
+            for (int j = 0; j < specialChars.length; j++) {
+                if (chars[i] == specialChars[j]) {
+                    throw new IOException(Messages.getString("ldap.1E"));
+                }
+            }
+        }
+        return super.nextAT();
+    }
+
+    protected String hexAV() throws IOException {
+        beg = pos; // store '#' position
+        pos++;
+
+        while (true) {
+            // check for end of attribute value
+            // looks for space and component separators
+            if (pos == length || chars[pos] == '+' || chars[pos] == ','
+                    || chars[pos] == ';') {
+                end = pos;
+                break;
+            }
+
+            if (chars[pos] >= 'A' && chars[pos] <= 'F') {
+                chars[pos] += 32; // to low case
+            }
+            pos++;
+        }
+
+        // verify length of hex string
+        // encoded byte array must be even number
+        int hexLen = end - beg; // skip first '#' char
+        // get byte encoding from string representation
+        encoded = new byte[hexLen / 2];
+        for (int i = 0, p = beg + 1; i < encoded.length; p += 2, i++) {
+            encoded[i] = (byte) getByte(p);
+        }
+        return new String(chars, beg, hexLen);
+
+    }
+
+    /**
+     * Begin to parse the string given in the constructor
+     */
+    public List parse() throws IOException {
+        List list = new ArrayList();
+
+        String attValue;
+        String attType = nextAT();
+        List atav = new ArrayList();
+        while (true) {
+            if (pos == length) {
+                // empty Attribute Value
+                atav.add(new AttributeTypeAndValuePair(attType, ""));
+                list.add(0, atav);
+                return list;
+            }
+
+            switch (chars[pos]) {
+            case '"':
+                attValue = quotedAV();
+                atav.add(new AttributeTypeAndValuePair(attType, attValue));
+                break;
+            case '#':
+                attValue = hexAV();
+                atav.add(new AttributeTypeAndValuePair(attType, Rdn
+                        .unescapeValue(attValue)));
+                break;
+            case '+':
+                // empty attribute value
+                atav.add(new AttributeTypeAndValuePair(attType, ""));
+                break;
+            default:
+                attValue = escapedAV();
+                atav.add(new AttributeTypeAndValuePair(attType, attValue));
+            }
+
+            if (pos >= length) {
+                list.add(0, atav);
+                return list;
+            }
+
+            if (chars[pos] == ',' || chars[pos] == ';') {
+                throw new IOException(Messages.getString("ldap.1F"));
+            }
+
+            pos++;
+            attType = nextAT();
+        }
+    }
+
+    protected char getEscaped() throws IOException {
+        pos++;
+        if (pos == length) {
+            throw new IOException(Messages.getString("ldap.1F"));
+        }
+
+        switch (chars[pos]) {
+        case '"':
+            return chars[pos];
+        case '\\':
+            hasQE = true;
+            return hexToUTF8(new String(chars, pos++, 2));
+        case ',':
+        case '=':
+        case '+':
+        case '<':
+        case '>':
+        case '#':
+        case ';':
+        case ' ':
+            // FIXME: escaping is allowed only for leading or trailing space
+            // char
+            return chars[pos];
+        default:
+            // RFC doesn't explicitly say that escaped hex pair is
+            // interpreted as UTF-8 char. It only contains an example of such
+            // DN.
+            return super.getUTF8();
+        }
+    }
+
+    /**
+     * Converts an String in Hexadecimal to a character
+     * 
+     * @param hex
+     *            the Hexadecimal string
+     * @throws IOException
+     *             when an invalid Digit is passed or when the size is different
+     *             than 2
+     * @return the corresponding character
+     */
+    public static Character hexToUTF8(String hex) throws IOException {
+        try {
+            return new Character((char) Integer.parseInt(hex, 16));
+        } catch (NumberFormatException e) {
+            throw new IOException(Messages.getString("ldap.20"));
+        }
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/parser/RelaxedDnParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/ClassFinder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/ClassFinder.java?view=auto&rev=507703
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/ClassFinder.java (added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/ClassFinder.java Wed Feb 14 13:42:41 2007
@@ -0,0 +1,169 @@
+/* 
+ *  Licensed to the Apache Software Foundation (ASF) under one or more 
+ *  contributor license agreements.  See the NOTICE file distributed with 
+ *  this work for additional information regarding copyright ownership. 
+ *  The ASF licenses this file to You 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.harmony.jndi.internal.tls.config;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.jar.JarFile;
+
+import org.apache.harmony.jndi.internal.nls.Messages;
+
+/**
+ * In charge to look for in the configuration file
+ * "META-INF/services/javax.naming.ldap.StartTlsResponse" the classes that
+ * correspond to a service provider implementation.
+ * 
+ * @author Osvaldo C. Demo
+ * @author Juan Giannuzzo
+ */
+public class ClassFinder {
+
+    /**
+     * relative path to the Configuration File
+     */
+    public static String cFile = "META-INF" + File.separator + "services"
+            + File.separator + "javax.naming.ldap.StartTlsResponse";
+
+    private List jars = new ArrayList();
+
+    private List dirs = new ArrayList();
+
+    private Set classlist = new HashSet();;
+
+    /**
+     * It gives back one lists with the classes that were found in the
+     * configuration file
+     * 
+     * @return a String array containing the full qualified name of the classes
+     * @throws ConfigFileNotFound
+     *             if configuration file does not exists
+     */
+    public String[] getClassList() throws ConfigFileNotFound {
+        if (classlist.isEmpty()) {
+            throw new ConfigFileNotFound(cFile + Messages.getString("ldap.21"));
+        }
+        String[] ret = new String[classlist.size()];
+
+        for (int i = 0; i < ret.length; i++) {
+            ret[i] = (String) classlist.toArray()[i];
+        }
+        return ret;
+    }
+
+    /**
+     * Constructor
+     * 
+     * @param name
+     *            String array containing paths in where the configuration file
+     *            will look for
+     */
+    public ClassFinder(String[] name) {
+        for (int i = 0; i < name.length; i++) {
+            if ((new File(name[i]).isDirectory())) {
+                DirFinder d = new DirFinder(name[i]);
+                JarFinder j = new JarFinder(name[i]);
+                dirs.addAll(d.getObjects()); // TODO check type safety here
+                jars.addAll(j.getObjects()); // TODO check type safety here
+            } else {
+                jars.add(new File(name[i]));
+            }
+        }
+        try {
+
+            fillList();
+        } catch (FileNotFoundException e) {
+        } catch (IOException e) {
+        }
+    }
+
+    /**
+     * In charge of filling the list of classes found within Jar archives and
+     * directories
+     * 
+     * @throws IOException
+     *             when the file was not found
+     */
+    private void fillList() throws IOException {
+        BufferedReader reader = null;
+        JarFile jarFile = null;
+
+        for (Iterator iter = dirs.iterator(); iter.hasNext();) {
+            File element = (File) iter.next();
+            reader = new BufferedReader(new FileReader(element));
+            StringTokenizer tk = new StringTokenizer(parseConfigFile(reader),
+                    System.getProperty("line.separator"));
+            while (tk.hasMoreTokens()) {
+                classlist.add((String) tk.nextElement());
+            }
+        }
+
+        for (Iterator iter = jars.iterator(); iter.hasNext();) {
+            File element = (File) iter.next();
+            jarFile = new JarFile(element);
+            try {
+                reader = new BufferedReader(new InputStreamReader(jarFile
+                        .getInputStream(jarFile.getJarEntry(cFile))));
+                StringTokenizer tk = new StringTokenizer(
+                        parseConfigFile(reader), System
+                                .getProperty("line.separator"));
+                while (tk.hasMoreTokens()) {
+                    classlist.add((String) tk.nextElement());
+                }
+            } catch (NullPointerException e) {
+                // Ignore jar files without a
+                // META-INF/services/javax.naming.ldap.StartTlsResponse file
+            }
+        }
+    }
+
+    /**
+     * Parses the content of a configuration file (plain text)
+     * 
+     * @param reader
+     *            a BufferedReader with the contents of the text file
+     * @return a string with the clases separated by the "line.separator"
+     *         character
+     */
+    private String parseConfigFile(BufferedReader reader) {
+        StringBuffer sb = new StringBuffer();
+        String line = null;
+        String[] l = null;
+        try {
+            while ((line = reader.readLine()) != null) {
+                l = line.trim().split("#");
+                if (!(l[0].equals(""))) {
+                    sb.append(l[0].trim());
+                    sb.append(System.getProperty("line.separator"));
+                }
+            }
+            reader.close();
+        } catch (IOException e) {
+        }
+        return sb.toString();
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/ClassFinder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/ConfigFileNotFound.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/ConfigFileNotFound.java?view=auto&rev=507703
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/ConfigFileNotFound.java (added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/ConfigFileNotFound.java Wed Feb 14 13:42:41 2007
@@ -0,0 +1,38 @@
+/* 
+ *  Licensed to the Apache Software Foundation (ASF) under one or more 
+ *  contributor license agreements.  See the NOTICE file distributed with 
+ *  this work for additional information regarding copyright ownership. 
+ *  The ASF licenses this file to You 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.harmony.jndi.internal.tls.config;
+
+/**
+ * Throwned when the configuration file is not found.
+ * 
+ * @author Osvaldo C. Demo
+ */
+public class ConfigFileNotFound extends Exception {
+
+    private static final long serialVersionUID = -457507371257269081L;
+
+    /**
+     * Constructor
+     * 
+     * @param name
+     *            String giving a clarification of the ocurred problem
+     */
+    public ConfigFileNotFound(String name) {
+        super(name);
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/ConfigFileNotFound.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/DirFinder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/DirFinder.java?view=auto&rev=507703
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/DirFinder.java (added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/DirFinder.java Wed Feb 14 13:42:41 2007
@@ -0,0 +1,52 @@
+/* 
+ *  Licensed to the Apache Software Foundation (ASF) under one or more 
+ *  contributor license agreements.  See the NOTICE file distributed with 
+ *  this work for additional information regarding copyright ownership. 
+ *  The ASF licenses this file to You 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.harmony.jndi.internal.tls.config;
+
+import java.io.File;
+import java.util.Iterator;
+
+/**
+ * This class finds the file
+ * "META-INF/services/javax.naming.ldap.StartTlsResponse" in a directory
+ * 
+ * @author Osvaldo C. Demo
+ */
+public class DirFinder extends Finder {
+
+    /**
+     * Class constructor
+     * 
+     * @param name
+     *            path where to start the search for the config file
+     */
+    protected DirFinder(String name) {
+        super(name);
+    }
+
+    /**
+     * Begins the search process
+     */
+    protected void doSearch() {
+        for (Iterator iter = super.allObjects.iterator(); iter.hasNext();) {
+            File element = (File) iter.next();
+            if (element.getAbsolutePath().endsWith(ClassFinder.cFile)) {
+                foundThis(element.getAbsoluteFile());
+            }
+        }
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/DirFinder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/Finder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/Finder.java?view=auto&rev=507703
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/Finder.java (added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/Finder.java Wed Feb 14 13:42:41 2007
@@ -0,0 +1,101 @@
+/* 
+ *  Licensed to the Apache Software Foundation (ASF) under one or more 
+ *  contributor license agreements.  See the NOTICE file distributed with 
+ *  this work for additional information regarding copyright ownership. 
+ *  The ASF licenses this file to You 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.harmony.jndi.internal.tls.config;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.harmony.jndi.internal.nls.Messages;
+
+/**
+ * It is used as it bases to look for archives within a given relative path
+ * 
+ * @author Osvaldo C. Demo
+ */
+public abstract class Finder {
+
+    /**
+     * In order to store the found objects
+     */
+    protected List foundObjects;
+
+    /**
+     * In order to store all the objects
+     */
+    protected List allObjects;
+
+    private Finder() {
+        foundObjects = new ArrayList();
+        allObjects = new ArrayList();
+    }
+
+    /**
+     * Constructor
+     * 
+     * @param name
+     *            the path to start scanning
+     */
+    protected Finder(String name) {
+        this();
+        fillList(new File(name));
+        doSearch();
+    }
+
+    /**
+     * This returns a list with the found objects
+     * 
+     * @return the found objects list
+     */
+    public List getObjects() {
+        if (foundObjects == null) {
+            throw new NullPointerException(Messages.getString("ldap.22"));
+        }
+        return foundObjects;
+    }
+
+    /**
+     * Used to add an object to the found list
+     * 
+     * @param name
+     *            the object to add
+     */
+    protected void foundThis(Object name) {
+        foundObjects.add((File) name);
+    }
+
+    /**
+     * Fills the lists with all the objects from the entered relative route
+     * 
+     * @param dir
+     *            the relative route to start
+     */
+    private void fillList(File dir) {
+        File[] files = dir.listFiles();
+        for (int i = 0; i < files.length; ++i) {
+            allObjects.add(files[i]);
+            if (files[i].isDirectory())
+                fillList(files[i]);
+        }
+    }
+
+    /**
+     * Write this method to search based on the desired criteria
+     */
+    protected abstract void doSearch();
+}

Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/Finder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/JarFinder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/JarFinder.java?view=auto&rev=507703
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/JarFinder.java (added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/JarFinder.java Wed Feb 14 13:42:41 2007
@@ -0,0 +1,83 @@
+/* 
+ *  Licensed to the Apache Software Foundation (ASF) under one or more 
+ *  contributor license agreements.  See the NOTICE file distributed with 
+ *  this work for additional information regarding copyright ownership. 
+ *  The ASF licenses this file to You 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.harmony.jndi.internal.tls.config;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+import org.apache.harmony.jndi.internal.nls.Messages;
+
+/**
+ * This class finds jars only containing "META-INF/services" directory
+ * 
+ * @author Osvaldo C. Demo
+ */
+public class JarFinder extends Finder {
+
+    /**
+     * Constructor
+     * 
+     * @param name
+     *            path where to start the search for Jar files
+     */
+    public JarFinder(String name) {
+        super(name);
+    }
+
+    protected void doSearch() {
+        for (Iterator iter = super.allObjects.iterator(); iter.hasNext();) {
+            File element = (File) iter.next();
+            if (element.getName().endsWith("jar")) {
+                try {
+                    findService(element.getAbsoluteFile());
+                } catch (Exception e) {
+                }
+            }
+        }
+    }
+
+    /**
+     * Searchs for the configuration file inside the Jar
+     * 
+     * @param element
+     *            JarFile to search in
+     * 
+     * @throws Exception
+     *             if config file was not found
+     */
+    public void findService(File element) throws Exception {
+        JarFile jarFile = null;
+        JarEntry entry = null;
+        try {
+            jarFile = new JarFile(element);
+            entry = jarFile
+                    .getJarEntry(ClassFinder.cFile);
+        } catch (IOException e) {
+        }
+        if (entry != null) {
+            foundThis(element.getAbsoluteFile());
+        } else {
+            throw new Exception(
+                    ClassFinder.cFile + Messages.getString("ldap.23")
+                            + element.getAbsolutePath());
+        }
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/JarFinder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/MergePath.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/MergePath.java?view=auto&rev=507703
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/MergePath.java (added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/MergePath.java Wed Feb 14 13:42:41 2007
@@ -0,0 +1,77 @@
+/* 
+ *  Licensed to the Apache Software Foundation (ASF) under one or more 
+ *  contributor license agreements.  See the NOTICE file distributed with 
+ *  this work for additional information regarding copyright ownership. 
+ *  The ASF licenses this file to You 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.harmony.jndi.internal.tls.config;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+/**
+ * Used to treat correctly the path elements.
+ * 
+ * @author Osvaldo C. Demo
+ * 
+ */
+public class MergePath {
+
+    private List pathnames = new ArrayList();
+
+    /**
+     * Constructor
+     * 
+     * @param path
+     *            Array of string with the path names
+     */
+    public MergePath(String[] path) {
+        super();
+        for (int i = 0; i < path.length; i++) {
+            addPathNames(path[i]);
+        }
+    }
+
+    /**
+     * add a path to the list
+     * 
+     * @param path
+     *            the string with the path to add, or multiple path separated by
+     *            "path.separator".
+     */
+    private void addPathNames(String path) {
+        if (path != null) {
+            StringTokenizer st = new StringTokenizer(path, System
+                    .getProperty("path.separator"));
+            while (st.hasMoreTokens()) {
+                pathnames.add(st.nextElement().toString());
+            }
+        }
+    }
+
+    /**
+     * Returns an array of strings containing the list of paths
+     * 
+     * @return array of string with the path names
+     */
+    public String[] getPathNames() {
+        String[] ret = new String[pathnames.size()];
+        for (int i = 0; i < ret.length; i++) {
+            ret[i] = (String) pathnames.get(i);
+        }
+        return ret;
+    }
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/tls/config/MergePath.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/AllTestLdap.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/AllTestLdap.java?view=auto&rev=507703
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/AllTestLdap.java (added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/AllTestLdap.java Wed Feb 14 13:42:41 2007
@@ -0,0 +1,60 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Leonardo Soler
+ * @author Gabriel Miretti
+ * @version 1.0
+ */
+package org.apache.harmony.jndi.tests.javax.naming.ldap;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * <p>This class runs all test of the package javax.naming.ldap</p>
+ *
+ */
+public class AllTestLdap {
+
+		/**
+		 * <p>Main method to initialize the suite of test.</p>
+		 * @param args
+		 */
+	    public static void main(String[] args) {
+	        junit.textui.TestRunner.run(AllTestLdap.suite());
+	    }
+
+	    /**
+	     * <p>Here we run all test of the package.</p>
+	     * 
+	     */
+	    public static Test suite() {
+	        TestSuite suite = new TestSuite("Test for javax.naming.ldap");
+	        suite.addTest(new TestSuite(TestBasicControl.class));
+	        suite.addTest(new TestSuite(TestControlFactory.class));
+	        suite.addTest(new TestSuite(TestInitialLdapContext.class));
+	        suite.addTest(new TestSuite(TestManageReferralControl.class));
+	        suite.addTest(new TestSuite(TestSortKey.class));
+	        suite.addTest(new TestSuite(TestStartTlsRequest.class));
+	        suite.addTest(new TestSuite(TestStartTlsResponse.class));
+	        suite.addTest(new TestSuite(TestUnsolicitedNotificationEvent.class));
+	        return suite;
+	    }
+
+}
+	
+

Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/AllTestLdap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestBasicControl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestBasicControl.java?view=auto&rev=507703
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestBasicControl.java (added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestBasicControl.java Wed Feb 14 13:42:41 2007
@@ -0,0 +1,332 @@
+/* 
+ *  Licensed to the Apache Software Foundation (ASF) under one or more 
+ *  contributor license agreements.  See the NOTICE file distributed with 
+ *  this work for additional information regarding copyright ownership. 
+ *  The ASF licenses this file to You 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. 
+ */ 
+/**
+ * @author Hugo Beilis
+ * @author Leonardo Soler
+ * @author Gabriel Miretti
+ * @version 1.0
+ */
+package org.apache.harmony.jndi.tests.javax.naming.ldap;
+
+import javax.naming.ldap.BasicControl;
+import junit.framework.TestCase;
+
+/**
+ * <p>This Test class is testing the Basic Control class.</p>
+ * <p>In the next tables we are gonna see the methods that we test in this class:</p>
+ * <table class="t" cellspacing="0">
+	<tbody><th>Constructors:</th>
+		<tr>
+			<td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="" id="f00"></td>
+			<td class="c0" id="c10"><input class="a0" size="60" name="sas9nt21" readonly="readonly" value="BasicControl(String id)" id="f10"></td>
+			
+		</tr>
+		<tr>
+			<td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="" id="f00"></td>
+			<td class="c0" id="c10"><input class="a0" size="60" name="sas9nt21" readonly="readonly" value="BasicControl(String id, boolean criticality, byte[] value)" id="f10"></td>
+			
+		</tr>
+	</tbody>
+	<table>
+	<tbody><th>Method Summary:</th>
+		<tr><TD>Return</TD><TD>Method</TD></tr>
+		<tr>
+			<td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="byte[]" id="f00"></TD>
+			<td class="c0" id="c10"><input class="a0" size="60" name="sas9nt21" readonly="readonly" value="getEncodedValue()" id="f10"></td>
+			
+		</tr>
+		<tr>
+			<td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="String" id="f00"></td>
+			<td class="c0" id="c10"><input class="a0" size="60" name="sas9nt21" readonly="readonly" value="getID()" id="f10"></td>
+			
+		</tr>
+		<tr>
+			<td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="boolean" id="f00"></td>
+			<td class="c0" id="c10"><input class="a0" size="60" name="sas9nt21" readonly="readonly" value="isCritical()" id="f10"></td>
+			
+		</tr>
+		
+	</tbody>
+	</table> 
+ *
+ */
+public class TestBasicControl extends TestCase {
+
+	/**
+	 * <p>This method is not implemted.</p>
+	 * @param args Possible parameter to help us initiate all tests.
+	 */
+	public static void main(String[] args) {
+	}
+
+	/**
+	 * <p>Constructor method of the class this class.</p>
+	 * <p>Here in this case we do not do anything else of initiate the inherited constructor.</p>
+	 * @param name This parameter is used to initiate the inherited constructor. 
+	 */
+	public TestBasicControl(String name) {
+		super(name);
+	}
+
+	protected void setUp() throws Exception {
+		super.setUp();
+	}
+
+	protected void tearDown() throws Exception {
+		super.tearDown();
+	}
+
+	/**
+	 * <p>Test method for 'javax.naming.ldap.BasicControl.BasicControl(String)'</p>
+	 * <p>Here we are testing if we can create a BasicControl of an id null.</p>
+	 * <p>The expected result is an instance of BasicControl.</p>
+	 */
+	public void testBasicControlString001() {
+		
+		assertNotNull(new BasicControl(null));
+		
+	}
+	
+	/**
+	 * <p>Test method for 'javax.naming.ldap.BasicControl.BasicControl(String)'</p>
+	 * <p>Here we are testing if we can create a BasicControl of an id blank.</p>
+	 * <p>The expected result has to be an instance of BasicControl.</p>
+	 */
+	public void testBasicControlString002() {
+		
+		assertNotNull(new BasicControl(""));
+		
+	}
+	
+	/**
+	 * <p>Test method for 'javax.naming.ldap.BasicControl.BasicControl(String)'</p>
+	 * <p>Here we are testing if we can create a BasicControl of an id like "1.2.3.333".</p>
+	 * <p>The expected result has to be an instance of BasicControl.</p>
+	 */
+	public void testBasicControlString003() {
+		
+		assertNotNull(new BasicControl("1.2.3.333"));
+		
+	}
+	
+	
+	/**
+	 * <p>Test method for 'javax.naming.ldap.BasicControl.BasicControl(String, boolean, byte[])'</p>
+	 * <p>Here we are testing to constructs a control using the supplied arguments. This control's value can 
+	 * be null, and it's depend on the ANS.1 BER</p>
+	 * <p>The expected result has to be an instance of BasicControl.</p>
+	 */
+	public void testBasicControlStringBooleanByteArray001() {
+		
+		byte[] test=null;
+		assertNotNull(new BasicControl("",true,test));
+		
+	}
+	
+	/**
+	 * <p>Test method for 'javax.naming.ldap.BasicControl.BasicControl(String, boolean, byte[])'</p>
+	 * <p>Here we are testing to constructs a control using the supplied arguments. This control's encoded is not null,
+	 * is an encoded value of a string into the constructor of the BasicControl.</p>
+	 * <p>The expected result has to be an instance of BasicControl.</p>
+	 */
+	public void testBasicControlStringBooleanByteArray002() {
+		
+		byte[] test=new String("").getBytes();
+		assertNotNull(new BasicControl("",false,test));
+		
+	}
+	
+	/**
+	 * <p>Test method for 'javax.naming.ldap.BasicControl.BasicControl(String, boolean, byte[])'</p>
+	 * <p>Here we are testing how does the constructor comport if all arguments are null</p>
+	 * <p>The expected result is a null pointer exception.</p>
+	 */
+	public void testBasicControlStringBooleanByteArray003() {
+		
+		try{
+			Boolean b=null;
+			byte[] c=null;
+			String a=null;
+			BasicControl bc=new BasicControl(a,b,c);
+			fail("All Arguments can not be null.");
+		}catch (NullPointerException e) {
+			
+		}
+	}
+	
+	/**
+	 * <p>Test method for 'javax.naming.ldap.BasicControl.BasicControl(String, boolean, byte[])'</p>
+	 * <p>Here we are testing to constructs a control using the supplied arguments. This control's encoded is null,
+	 * the id string is also null.</p>
+	 * <p>The expected result has to be an instance of BasicControl.</p>
+	 */
+	public void testBasicControlStringBooleanByteArray004() {
+		
+		byte[] test=null;
+		assertNotNull(new BasicControl(null,false,test));
+		
+	}
+	
+	/**
+	 *<p>Test method for 'javax.naming.ldap.BasicControl.getID()'</p>
+	 *<p>Here we are testing the return of a basic id of a BasicControl.</p>
+	 *<p>The Expected result is an Id of the form "Control".</p> 
+	 */
+	public void testGetID001() {
+		
+		String ID="Control";
+		BasicControl bc = new BasicControl(ID);
+		assertEquals(ID,bc.getID());
+		
+	}
+
+	/**
+	 *<p>Test method for 'javax.naming.ldap.BasicControl.getID()'</p>
+	 *<p>Here we are testing the return of a basic id of a BasicControl.</p>
+	 *<p>The Expected result is an Id null.</p> 
+	 */
+	public void testGetID002() {
+		
+		String ID=null;
+		BasicControl bc = new BasicControl(ID);
+		assertEquals(ID,bc.getID());
+		
+	}
+	
+	/**
+	 *<p>Test method for 'javax.naming.ldap.BasicControl.getID()'</p>
+	 *<p>Here we are testing the return of a basic id of a BasicControl.</p>
+	 *<p>The Expected result is an Id blank.</p> 
+	 */
+	public void testGetID003() {
+		
+		String ID="";
+		BasicControl bc = new BasicControl(ID);
+		assertEquals(ID,bc.getID());
+		
+	}
+	
+	/**
+	 * <p>Test method for 'javax.naming.ldap.BasicControl.isCritical()'</p>
+	 * <p>Here we are testing a false criticality of a BasicControl. Because when we create a BasicControl with no criticality
+	 * defined a default false is set.</p>
+	 * <p>The expected result is a false criticality.</p>
+	 */
+	public void testIsCritical001() {
+		
+		BasicControl bc = new BasicControl("control");
+		assertEquals(false,bc.isCritical());
+		
+	}
+	
+	/**
+	 * <p>Test method for 'javax.naming.ldap.BasicControl.isCritical()'</p>
+	 * <p>Here we are testing a false criticality of a BasicControl. Because when we create a BasicControl with no criticality
+	 * defined a default false is set.</p>
+	 * <p>The expected result is a false criticality.</p>
+	 */
+	public void testIsCritical002() {
+		
+		BasicControl bc = new BasicControl("");
+		assertEquals(false,bc.isCritical());
+		
+	}
+
+	/**
+	 * <p>Test method for 'javax.naming.ldap.BasicControl.isCritical()'</p>
+	 * <p>Here we are testing a false criticality of a BasicControl. Because when we create a BasicControl with no criticality
+	 * defined a default false is set.</p>
+	 * <p>The expected result is a false criticality.</p>
+	 */
+	public void testIsCritical003() {
+		
+		BasicControl bc = new BasicControl(null);
+		assertEquals(false,bc.isCritical());
+		
+	}
+
+	/**
+	 * <p>Test method for 'javax.naming.ldap.BasicControl.isCritical()'</p>
+	 * <p>Here we are testing a true criticality of a BasicControl. In this case we create a BasicControl with a true 
+	 * criticity.</p>
+	 * <p>The expected result is true criticality.</p>
+	 */
+	public void testIsCritical004() {
+		
+		byte[] test = null;
+		BasicControl bc = new BasicControl("control", true, test );
+		assertEquals(true,bc.isCritical());
+		
+	}
+	/**
+	 * <p>Test method for 'javax.naming.ldap.BasicControl.isCritical()'</p>
+	 * <p>Here we are testing a true criticality of a BasicControl. In this case we create a BasicControl with a false 
+	 * criticity.</p>
+	 * <p>The expected result is false criticality.</p>
+	 */
+	public void testIsCritical005() {
+		
+		byte[] test = null;
+		BasicControl bc = new BasicControl("control", false, test );
+		assertEquals(false,bc.isCritical());
+		
+	}
+	
+	/**
+	 * <p>Test method for 'javax.naming.ldap.BasicControl.getEncodedValue()'</p>
+	 * <p>Here we are testing the return method of the encoded value of BasicControl. In this case we send an encoded value
+	 * null.</p>
+	 * <p>The expected result is a null encoded value.</p>
+	 */
+	public void testGetEncodedValue001() {
+		
+		byte[] test=null;
+		BasicControl bc=new BasicControl("control",true,test);
+		assertEquals(null,bc.getEncodedValue());
+		
+	}
+
+	/**
+	 * <p>Test method for 'javax.naming.ldap.BasicControl.getEncodedValue()'</p>
+	 * <p>Here we are testing the return method of the encoded value of BasicControl. In this case we send an encoded value
+	 * of this originaly date "4:45:40 p.m. Pacific Daylight Time on May 6, 1991" this coded in ASN.1 BER.</p>
+	 * <p>The expected result is same encoded value.</p>
+	 */
+	public void testGetEncodedValue002() {
+		
+		byte[] test={(byte)17,(byte) 11,(byte) 39,(byte) 31,(byte) 30,(byte) 35,(byte) 30,(byte) 36,(byte) 31,(byte) 36,(byte) 34,
+				(byte)35,(byte) 34,(byte) 30, (byte) 2D,(byte) 30,(byte) 37,(byte) 30,(byte) 30};
+		BasicControl bc=new BasicControl("control",true,test);
+		assertEquals(test,bc.getEncodedValue());
+		
+	}
+
+	/**
+	 * <p>Test method for 'javax.naming.ldap.BasicControl.getEncodedValue()'</p>
+	 * <p>Here we are testing the return method of a not null encoded value of BasicControl. In this case we send the bytes of
+	 * a string.</p>
+	 * <p>The expected result is same encoded value.</p>
+	 */
+	public void testGetEncodedValue003() {
+				
+		byte test[]=new String("control").getBytes();
+		BasicControl bc=new BasicControl("control",true,test);
+		assertNotNull(bc.getEncodedValue());
+		
+	}
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestBasicControl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestControlFactory.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestControlFactory.java?view=auto&rev=507703
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestControlFactory.java (added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestControlFactory.java Wed Feb 14 13:42:41 2007
@@ -0,0 +1,140 @@
+/* 
+ *  Licensed to the Apache Software Foundation (ASF) under one or more 
+ *  contributor license agreements.  See the NOTICE file distributed with 
+ *  this work for additional information regarding copyright ownership. 
+ *  The ASF licenses this file to You 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. 
+ */ 
+/**
+ * @author Hugo Beilis
+ * @author Leonardo Soler
+ * @author Gabriel Miretti
+ * @version 1.0
+ */
+package org.apache.harmony.jndi.tests.javax.naming.ldap;
+
+import java.util.Hashtable;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.ldap.*;
+import org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockControl;
+import junit.framework.TestCase;
+
+/**
+ * <p>This Test class is testing the class ControlFactory in the javax.naming.ldap package.</p>
+ * <p>Here in the next tables we are gonna find all methods to be tested:</p>
+ * <table>
+ 	<tbody><th>Method Summary:</th>
+	<tr><TD>Return</TD><TD>Method</TD></tr>
+	<tr>
+		<td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="static Control" id="f00"></TD>
+		<td class="c0" id="c10"><input class="a0" size="65" name="sas9nt21" readonly="readonly" value="getControlInstance(Control ctl, Context ctx, Hashtable env)" id="f10"></td>
+		
+	</tr>
+	</tbody>
+	</table>
+ */
+public class TestControlFactory extends TestCase {
+
+	/**
+	 * <p>This method is not implemted.</p>
+	 * @param args Possible parameter to help us initiate all tests.
+	 */
+	public static void main(String[] args) {
+	}
+
+
+	/**
+	 * <p>Constructor method of the test class.</p>
+	 * <p>Here in this case we do not do anything else of initiate the inherited constructor.</p>
+	 */
+	protected void setUp() throws Exception {
+		super.setUp();
+	}
+
+	protected void tearDown() throws Exception {
+		super.tearDown();
+	}
+
+	/**
+	 * <p>Test method for 'javax.naming.ldap.ControlFactory.getControlInstance(Control, Context, Hashtable<?, ?>)'</p>
+	 * <p>Here we are testing the static method of the class ControlFactory</p>
+	 * <p>The expected result is null.</p> 
+	 */
+	public void testGetControlInstanceControlContextHashtableOfQQ001() {
+		
+		try {
+			
+			assertNull(ControlFactory.getControlInstance(null,null,null));
+			
+		} catch (NamingException e) {
+			
+		}
+	}
+	/**
+	 * <p>Test method for 'javax.naming.ldap.ControlFactory.getControlInstance(Control, Context, Hashtable<?, ?>)'</p>
+	 * <p>Here we are testing the static method of the class ControlFactory</p>
+	 * <p>The expected result is the control sended.</p> 
+	 */
+	public void testGetControlInstanceControlContextHashtableOfQQ002() {
+		
+		try {
+			MockControl cs =  new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }); 
+					
+			assertEquals(cs,ControlFactory.getControlInstance(cs,null,null));
+		} catch (NamingException e) {
+			
+		}
+	}
+
+	/**
+	 * <p>Test method for 'javax.naming.ldap.ControlFactory.getControlInstance(Control, Context, Hashtable<?, ?>)'</p>
+	 * <p>Here we are testing the static method of the class ControlFactory</p>
+	 * <p>The expected result is the control sended.</p> 
+	 */
+	public void testGetControlInstanceControlContextHashtableOfQQ003() {
+		
+		try {
+			Hashtable env = new Hashtable();
+			env.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
+			MockControl[] cs = { new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }), 
+					new MockControl("c1", true, new byte[] { 'a', 'b', 'c', 'd' }), };
+			MockControl cs2 =  new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }); 
+			InitialLdapContext ilc=new InitialLdapContext(env, cs);
+			assertEquals(cs2,ControlFactory.getControlInstance(cs2,ilc,env));
+		} catch (NamingException e) {
+			
+		}
+	}
+	
+	/**
+	 * <p>Test method for 'javax.naming.ldap.ControlFactory.getControlInstance(Control, Context, Hashtable<?, ?>)'</p>
+	 * <p>Here we are testing the static method of the class ControlFactory</p>
+	 * <p>The expected result is the control sended.</p> 
+	 */
+	public void testGetControlInstanceControlContextHashtableOfQQ004() {
+		
+		try {
+			Hashtable env = new Hashtable();
+			env.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
+			env.put(LdapContext.CONTROL_FACTORIES,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockControlFactory");
+			MockControl[] cs = { new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }),new MockControl("c1", true, new byte[] { 'a', 'b', 'c', 'd' }), };
+			MockControl cs2 =  new MockControl("c1", false, new byte[] { 1, 2, 3, 4 });
+			InitialLdapContext ilc=new InitialLdapContext(env, cs);
+			
+			assertEquals(cs2,ControlFactory.getControlInstance(cs2,ilc,env));
+		} catch (NamingException e) {
+			
+		}
+	}
+	
+}

Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestControlFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message