directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r440145 - in /directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber: ./ messages/ messages/abandon/ messages/add/ messages/bind/ messages/compare/ messages/del/ messages/extended/ ...
Date Mon, 04 Sep 2006 18:16:43 GMT
Author: elecharny
Date: Mon Sep  4 11:16:42 2006
New Revision: 440145

URL: http://svn.apache.org/viewvc?view=rev&rev=440145
Log:
Added the packages for the BER decorator.
Added some classes for BindOperation

Added:
    directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/
    directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/
    directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/abandon/
    directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/add/
    directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/bind/
    directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/bind/AuthenticationAsn1Ber.java
    directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/bind/BindRequestAsn1Ber.java
    directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/bind/SimpleAuthenticationAsn1Ber.java
    directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/compare/
    directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/del/
    directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/extended/
    directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/extended/operation/
    directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/intermediate/
    directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/modify/
    directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/modifydn/
    directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/search/
    directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/unbind/

Added: directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/bind/AuthenticationAsn1Ber.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/bind/AuthenticationAsn1Ber.java?view=auto&rev=440145
==============================================================================
--- directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/bind/AuthenticationAsn1Ber.java
(added)
+++ directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/bind/AuthenticationAsn1Ber.java
Mon Sep  4 11:16:42 2006
@@ -0,0 +1,9 @@
+
+package org.apache.directory.shared.ldap.codec.asn1ber.messages.bind;
+
+import org.apache.directory.shared.ldap.messages.bind.AuthenticationDecorator;
+
+public class AuthenticationAsn1Ber extends AuthenticationDecorator
+{
+
+}

Added: directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/bind/BindRequestAsn1Ber.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/bind/BindRequestAsn1Ber.java?view=auto&rev=440145
==============================================================================
--- directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/bind/BindRequestAsn1Ber.java
(added)
+++ directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/bind/BindRequestAsn1Ber.java
Mon Sep  4 11:16:42 2006
@@ -0,0 +1,100 @@
+/*
+ *  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.directory.shared.ldap.codec.asn1ber.messages.bind;
+
+import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.ldap.messages.bind.AuthenticationDecorator;
+import org.apache.directory.shared.ldap.messages.bind.AuthenticationOperation;
+import org.apache.directory.shared.ldap.messages.bind.BindRequestDecorator;
+import org.apache.directory.shared.ldap.messages.bind.BindRequestOperation;
+import org.apache.directory.shared.ldap.messages.bind.SaslCredentialsDecorator;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 
+ * This class is a ASN.1 BER codec decorator. It adds coding and decoding
+ * behavior to the BindRequest object. 
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class BindRequestAsn1Ber extends BindRequestDecorator 
+{
+    /** The logger */
+    private static Logger log = LoggerFactory.getLogger( BindRequestAsn1Ber.class );
+
+    /** A speedup for logger */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    /** The bind request length */
+    private transient int bindRequestLength;
+    
+    /**
+     * 
+     * Creates a new instance of BindRequestAsn1Ber.
+     *
+     * @param bindRequest The bindRequest object to decorate
+     */
+    public BindRequestAsn1Ber( BindRequestOperation bindRequest )
+    {
+        super( bindRequest );
+    }
+
+    /**
+     * Compute the BindRequest length BindRequest : 
+     * 0x60 L1 
+     *   | 
+     *   +--> 0x02 0x01 (1..127) version 
+     *   +--> 0x04 L2 name 
+     *   +--> authentication 
+     * 
+     * length(bindRequest) = lentgh(0x60) + L1
+     * L1 = length(0x02) + length(0x01) + length(version) +
+     *      length(OxO4) + length(L2) + L2 +
+     *      length(autentication) 
+     * L2 = Length(name)
+     */
+    public int computeLength()
+    {
+        bindRequestLength = 1 + 1 + 1; // Initialized with version
+
+        // The name
+        bindRequestLength += 1 + Length.getNbBytes( LdapDN.getNbBytes( getName() ) ) + LdapDN.getNbBytes(
getName() );
+
+        // The authentication
+        AuthenticationOperation authenticationDecorator = 
+            ( getAuthentication().isSimple() ?
+                new SimpleAuthenticationAsn1Ber( getAuthentication() ) :
+                new SaslCredentialsAsn1Ber( getAuthentication() ) );
+
+        bindRequestLength += authenticationDecorator.computeLength();
+
+        // Return the result.
+        int length = 1 + Length.getNbBytes( bindRequestLength ) + bindRequestLength;
+        
+        if ( IS_DEBUG )
+        {
+            log.debug( "BindRequest length : {}", length );
+        }
+
+        return length;
+    }
+}

Added: directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/bind/SimpleAuthenticationAsn1Ber.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/bind/SimpleAuthenticationAsn1Ber.java?view=auto&rev=440145
==============================================================================
--- directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/bind/SimpleAuthenticationAsn1Ber.java
(added)
+++ directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/bind/SimpleAuthenticationAsn1Ber.java
Mon Sep  4 11:16:42 2006
@@ -0,0 +1,72 @@
+/*
+ *  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.directory.shared.ldap.codec.asn1ber.messages.bind;
+
+import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.ldap.messages.bind.AuthenticationOperation;
+import org.apache.directory.shared.ldap.messages.bind.SimpleAuthenticationDecorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 
+ * The SimpleAuthentication decorator for ASN.1 Ber
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SimpleAuthenticationAsn1Ber extends SimpleAuthenticationDecorator
+{
+    /** The logger */
+    private static Logger log = LoggerFactory.getLogger( SimpleAuthenticationAsn1Ber.class
);
+
+    /** A speedup for logger */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    /**
+     * Creates a new instance of SimpleAuthenticationAsn1Ber. 
+     *
+     * @param authentication The authentication object to decorate.
+     */
+    public SimpleAuthenticationAsn1Ber( AuthenticationOperation authentication )
+    {
+        super( authentication );
+    }
+    
+    /**
+     * Compute the Simple authentication : 
+     * 
+     * length Simple authentication : 0x80 L1 simple 
+     * L1 = Length(simple) 
+     * Length(Simple authentication) = Length(0x80) + Length(L1) + Length(simple)
+     */
+    public int computeLength()
+    {
+        int length = 1;
+
+        length += Length.getNbBytes( getSimple().length ) + getSimple().length;
+
+        if ( IS_DEBUG )
+        {
+            log.debug( "Simple Authentication length : {}", length );
+        }
+
+        return length;
+    }
+}



Mime
View raw message