harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r585376 - in /harmony/enhanced/classlib/trunk/modules/jndi/src: main/java/org/apache/harmony/jndi/provider/ldap/ main/java/org/apache/harmony/jndi/provider/ldap/asn1/ test/java/org/apache/harmony/jndi/provider/ldap/ test/java/org/apache/har...
Date Wed, 17 Oct 2007 05:06:28 GMT
Author: tonywu
Date: Tue Oct 16 22:06:26 2007
New Revision: 585376

URL: http://svn.apache.org/viewvc?rev=585376&view=rev
Log:
Apply patch Harmony-4949 ([classlib][ldap] Add ldap delete request sending and delete response
parsing function)

Added:
    harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/DeleteOp.java
  (with props)
    harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/DeleteOpTest.java
  (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapMessage.java
    harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/asn1/LdapASN1Constant.java
    harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/asn1/ASN1TestUtils.java

Added: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/DeleteOp.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/DeleteOp.java?rev=585376&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/DeleteOp.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/DeleteOp.java
Tue Oct 16 22:06:26 2007
@@ -0,0 +1,70 @@
+/* 
+ *  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.provider.ldap;
+
+import org.apache.harmony.jndi.provider.ldap.asn1.ASN1Decodable;
+import org.apache.harmony.jndi.provider.ldap.asn1.ASN1Encodable;
+import org.apache.harmony.jndi.provider.ldap.asn1.LdapASN1Constant;
+import org.apache.harmony.jndi.provider.ldap.asn1.Utils;
+
+/**
+ * Ldap delete operation. Refer to
+ * {@link http://www.rfc-editor.org/rfc/rfc2251.txt} for detailed information
+ * 
+ */
+public class DeleteOp implements LdapOperation, ASN1Encodable, ASN1Decodable {
+    /**
+     * The distinguished name of the target entry
+     */
+    private String dn;
+
+    private LdapResult result;
+
+    public DeleteOp(String dn) {
+        this.dn = dn;
+    }
+
+    public ASN1Encodable getRequest() {
+        return this;
+    }
+
+    public int getRequestId() {
+        return LdapASN1Constant.OP_DEL_REQUEST;
+    }
+
+    public ASN1Decodable getResponse() {
+        return result = (result == null) ? new LdapResult() : result;
+    }
+
+    public int getResponseId() {
+        return LdapASN1Constant.OP_DEL_RESPONSE;
+    }
+
+    public void encodeValues(Object[] values) {
+        values[0] = Utils.getBytes(dn);
+    }
+
+    public LdapResult getResult() {
+        return result;
+    }
+
+    public void decodeValues(Object[] values) {
+        dn = Utils.getString((byte[]) values[0]);
+    }
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/DeleteOp.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapMessage.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapMessage.java?rev=585376&r1=585375&r2=585376&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapMessage.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapMessage.java
Tue Oct 16 22:06:26 2007
@@ -137,7 +137,14 @@
 
     public void encodeValues(Object[] values) {
         values[0] = ASN1Integer.fromIntValue(messageId);
-        values[1] = new ChosenValue(opIndex, requestOp);
+        // DelRequest are ASN.1 primitive
+        if (opIndex == LdapASN1Constant.OP_DEL_REQUEST) {
+            Object[] objs = new Object[1];
+            requestOp.encodeValues(objs);
+            values[1] = new ChosenValue(opIndex, objs[0]);
+        } else {
+            values[1] = new ChosenValue(opIndex, requestOp);
+        }
     }
 
     /**

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/asn1/LdapASN1Constant.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/asn1/LdapASN1Constant.java?rev=585376&r1=585375&r2=585376&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/asn1/LdapASN1Constant.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/asn1/LdapASN1Constant.java
Tue Oct 16 22:06:26 2007
@@ -41,6 +41,10 @@
     public static final int OP_ADD_REQUEST = 2;
     
     public static final int OP_ADD_RESPONSE = 3;
+
+    public static final int OP_DEL_REQUEST = 4;
+
+    public static final int OP_DEL_RESPONSE = 5;
     
     public static final ASN1Type Attribute = new ASN1SequenceWrap(
             new ASN1Type[] { ASN1OctetString.getInstance(), // type
@@ -112,6 +116,13 @@
                         }
                     }));
     
+    public static final ASN1Type DelRequest = new ASN1Implicit(
+            ASN1Constants.CLASS_APPLICATION, 10, ASN1OctetString.getInstance());
+    
+    
+    public static final ASN1Type DelResponse = new ASN1Implicit(
+            ASN1Constants.CLASS_APPLICATION, 11, LDAPResult);
+    
     public static final ASN1Type LDAPMessage = new ASN1SequenceWrap(
             new ASN1Type[] {
                     ASN1Integer.getInstance(),
@@ -119,12 +130,12 @@
                             BindResponse,
                             AddRequest,
                             AddResponse,
+                            DelRequest,
+                            DelResponse,
                             }),
                     new ASN1SequenceOf(Control) }) {
         {
             setOptional(2);
         }
     };
-    
-
 }

Added: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/DeleteOpTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/DeleteOpTest.java?rev=585376&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/DeleteOpTest.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/DeleteOpTest.java
Tue Oct 16 22:06:26 2007
@@ -0,0 +1,33 @@
+/* 
+ *  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.provider.ldap;
+
+import junit.framework.TestCase;
+
+import org.apache.harmony.jndi.provider.ldap.asn1.ASN1TestUtils;
+import org.apache.harmony.jndi.provider.ldap.asn1.LdapASN1Constant;
+
+public class DeleteOpTest extends TestCase {
+    public void test_encodeValues_$LObject() {
+        String entry = "delete entry";
+        DeleteOp op = new DeleteOp(entry);
+
+        ASN1TestUtils.checkEncode(op.getRequest(), LdapASN1Constant.DelRequest);
+
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/DeleteOpTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/asn1/ASN1TestUtils.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/asn1/ASN1TestUtils.java?rev=585376&r1=585375&r2=585376&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/asn1/ASN1TestUtils.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/asn1/ASN1TestUtils.java
Tue Oct 16 22:06:26 2007
@@ -21,6 +21,7 @@
 
 import junit.framework.Assert;
 
+import org.apache.harmony.jndi.provider.ldap.DeleteOp;
 import org.apache.harmony.jndi.provider.ldap.asn1.ASN1ChoiceWrap.ChosenValue;
 import org.apache.harmony.security.asn1.ASN1Boolean;
 import org.apache.harmony.security.asn1.ASN1Enumerated;
@@ -49,6 +50,11 @@
         } else if (type instanceof ASN1Boolean) {
             Assert.assertTrue(value instanceof Boolean);
         } else if (type instanceof ASN1OctetString) {
+            if(value instanceof DeleteOp) {
+                Object[] objs = new Object[1];
+                ((DeleteOp)value).encodeValues(objs);
+                value = objs[0];
+            }
             Assert.assertTrue(value instanceof byte[]);
         } else if (type instanceof ASN1SequenceWrap) {
             checkEncodeSequence(value, (ASN1SequenceWrap) type);



Mime
View raw message