You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2006/09/03 14:46:45 UTC

svn commit: r439771 - in /directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/bind: Authentication.java BindRequest.java SaslCredentials.java SimpleAuthentication.java

Author: elecharny
Date: Sun Sep  3 05:46:44 2006
New Revision: 439771

URL: http://svn.apache.org/viewvc?rev=439771&view=rev
Log:
Added the first shot of BindRequest new message

Added:
    directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/bind/Authentication.java
    directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/bind/BindRequest.java
    directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/bind/SaslCredentials.java
    directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/bind/SimpleAuthentication.java

Added: directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/bind/Authentication.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/bind/Authentication.java?rev=439771&view=auto
==============================================================================
--- directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/bind/Authentication.java (added)
+++ directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/bind/Authentication.java Sun Sep  3 05:46:44 2006
@@ -0,0 +1,31 @@
+/*
+ *  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.messages.bind;
+
+/**
+ * This interface is just used to have a common interface for
+ * authentication classes, like Simple and SASL. We may have future 
+ * extensions as authentication type 1 and 2 are reserved actually in LDAP V3
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface Authentication
+{
+}

Added: directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/bind/BindRequest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/bind/BindRequest.java?rev=439771&view=auto
==============================================================================
--- directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/bind/BindRequest.java (added)
+++ directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/bind/BindRequest.java Sun Sep  3 05:46:44 2006
@@ -0,0 +1,168 @@
+/*
+ *  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.messages.bind;
+
+import org.apache.directory.shared.ldap.messages.AbstractRequest;
+import org.apache.directory.shared.ldap.messages.Request;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.utils.StringTools;
+
+/**
+ * This class stores a BindRequest Object. 
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class BindRequest extends AbstractRequest implements Request
+{
+    /**
+     * Declares the Serial Version Uid.
+     *
+     * @see <a
+     *      href="http://c2.com/cgi/wiki?AlwaysDeclareSerialVersionUid">Always
+     *      Declare Serial Version Uid</a>
+     */
+    static final long serialVersionUID = 2L;
+
+    /** The protocol Version to use. Should be 3 */
+    private int version;
+
+    /** The name of the user requesting a bind */
+    private LdapDN name;
+
+    /** The authentication used to bind the user */
+    private Authentication authentication;
+
+    /**
+     * Creates a new BindRequest object.
+     * 
+     * @param the message identifier
+     */
+    public BindRequest( int messageId )
+    {
+        super( messageId );
+    }
+
+    /**
+     * Get the user authentication
+     * 
+     * @return The user authentication
+     */
+    public Authentication getAuthentication()
+    {
+        return authentication;
+    }
+
+    /**
+     * Set the user authentication
+     * 
+     * @param authentication The user authentication
+     */
+    public void setAuthentication( Authentication authentication )
+    {
+        this.authentication = authentication;
+    }
+    
+    /**
+     * Get the user name
+     * 
+     * @return The user name
+     */
+    public LdapDN getName()
+    {
+        return name;
+    }
+
+
+    /**
+     * Set the user name
+     * 
+     * @param name
+     *            The user name
+     */
+    public void setName( LdapDN name )
+    {
+        this.name = name;
+    }
+
+    /**
+     * Get the protocol version
+     * 
+     * @return The protocol version
+     */
+    public int getVersion()
+    {
+        return version;
+    }
+
+
+    /**
+     * Check if the Ldap version in use is 3
+     * 
+     * @return true if the ldap version is 3
+     */
+    public boolean isLdapV3()
+    {
+        return version == 3;
+    }
+
+    /**
+     * Set the protocol version
+     * 
+     * @param version The protocol version
+     */
+    public void setVersion( int version )
+    {
+        this.version = version;
+    }
+    
+    /**
+     * Get a String representation of a BindRequest
+     * 
+     * @return A BindRequest String
+     */
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "    BindRequest\n" );
+        sb.append( "        Version : '" ).append( version ).append( "'\n" );
+
+        if ( StringTools.isEmpty( name.toString() ) )
+        {
+            sb.append( "        Name : anonymous\n" );
+        }
+        else
+        {
+            sb.append( "        Name : '" ).append( name.toString() ).append( "'\n" );
+
+            if ( authentication instanceof SimpleAuthentication )
+            {
+                sb.append( "        Simple authentication : '" ).append(
+                    ( ( SimpleAuthentication ) authentication ).toString() ).append( "'\n" );
+            }
+            else
+            {
+                sb.append( ( ( SaslCredentials ) authentication ).toString() );
+            }
+        }
+
+        return sb.toString();
+    }
+}

Added: directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/bind/SaslCredentials.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/bind/SaslCredentials.java?rev=439771&view=auto
==============================================================================
--- directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/bind/SaslCredentials.java (added)
+++ directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/bind/SaslCredentials.java Sun Sep  3 05:46:44 2006
@@ -0,0 +1,114 @@
+/*
+ *  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.messages.bind;
+
+import org.apache.directory.shared.ldap.utils.StringTools;
+
+/**
+ * A class which stores the SASL authentication of a BindRequest.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SaslCredentials implements Authentication
+{
+    /**
+     * Declares the Serial Version Uid.
+     *
+     * @see <a
+     *      href="http://c2.com/cgi/wiki?AlwaysDeclareSerialVersionUid">Always
+     *      Declare Serial Version Uid</a>
+     */
+    static final long serialVersionUID = 2L;
+
+    /**
+     * Any mechanism defined in RFC 2222 : KERBEROS_V4, GSSAPI, SKEY, EXTERNAL
+     */
+    private String mechanism;
+
+    /** optional credentials of the user */
+    private byte[] credentials;
+
+    /**
+     * Get the credentials
+     * 
+     * @return The credentials
+     */
+    public byte[] getCredentials()
+    {
+        return credentials;
+    }
+
+
+    /**
+     * Set the credentials
+     * 
+     * @param credentials
+     *            The credentials
+     */
+    public void setCredentials( byte[] credentials )
+    {
+        this.credentials = credentials;
+    }
+
+    /**
+     * Get the mechanism
+     * 
+     * @return The mechanism
+     */
+    public String getMechanism()
+    {
+
+        return ( ( mechanism == null ) ? null : mechanism );
+    }
+
+
+    /**
+     * Set the mechanism
+     * 
+     * @param mechanism
+     *            The mechanism
+     */
+    public void setMechanism( String mechanism )
+    {
+        this.mechanism = mechanism;
+    }
+
+    /**
+     * Get a String representation of a SaslCredential
+     * 
+     * @return A SaslCredential String
+     */
+    public String toString()
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "        Sasl credentials\n" );
+        sb.append( "            Mechanism :'" ).append( mechanism ).append( "'\n" );
+
+        if ( credentials != null )
+        {
+            sb.append( "            Credentials :'" ).
+            append( StringTools.dumpBytes( credentials ) ).append( "'\n" );
+        }
+
+        return sb.toString();
+    }
+}

Added: directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/bind/SimpleAuthentication.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/bind/SimpleAuthentication.java?rev=439771&view=auto
==============================================================================
--- directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/bind/SimpleAuthentication.java (added)
+++ directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/bind/SimpleAuthentication.java Sun Sep  3 05:46:44 2006
@@ -0,0 +1,76 @@
+/*
+ *  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.messages.bind;
+
+import org.apache.directory.shared.ldap.utils.StringTools;
+
+/**
+ * A class which stores the Simple authentication for a BindRequest.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SimpleAuthentication implements Authentication
+{
+    /**
+     * Declares the Serial Version Uid.
+     *
+     * @see <a
+     *      href="http://c2.com/cgi/wiki?AlwaysDeclareSerialVersionUid">Always
+     *      Declare Serial Version Uid</a>
+     */
+    static final long serialVersionUID = 2L;
+
+    /** The simple authentication password */
+    private byte[] simple;
+
+    /**
+     * Get the simple password
+     * 
+     * @return The password
+     */
+    public byte[] getSimple()
+    {
+        return simple;
+    }
+
+
+    /**
+     * Set the simple password
+     * 
+     * @param simple
+     *            The simple password
+     */
+    public void setSimple( byte[] simple )
+    {
+        this.simple = simple;
+    }
+
+    /**
+     * Return the simple authentication as a string.
+     * 
+     * @return The simple authentication string.
+     */
+    public String toString()
+    {
+        return ( ( simple == null ) ? 
+            "null" : 
+            StringTools.dumpBytes( simple ) );
+    }
+}