directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r992802 - in /directory/apacheds/trunk/http-directory-bridge: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/directory/ src/main/java/org/apache/directory/server/
Date Sun, 05 Sep 2010 15:17:11 GMT
Author: kayyagari
Date: Sun Sep  5 15:17:08 2010
New Revision: 992802

URL: http://svn.apache.org/viewvc?rev=992802&view=rev
Log:
o a module to bridge the ldap directory service to a http web app
  Using this module the DirectoryService instance can be made accessible to web applications


Added:
    directory/apacheds/trunk/http-directory-bridge/
    directory/apacheds/trunk/http-directory-bridge/pom.xml
    directory/apacheds/trunk/http-directory-bridge/src/
    directory/apacheds/trunk/http-directory-bridge/src/main/
    directory/apacheds/trunk/http-directory-bridge/src/main/java/
    directory/apacheds/trunk/http-directory-bridge/src/main/java/org/
    directory/apacheds/trunk/http-directory-bridge/src/main/java/org/apache/
    directory/apacheds/trunk/http-directory-bridge/src/main/java/org/apache/directory/
    directory/apacheds/trunk/http-directory-bridge/src/main/java/org/apache/directory/server/
    directory/apacheds/trunk/http-directory-bridge/src/main/java/org/apache/directory/server/BindResponseHolder.java
    directory/apacheds/trunk/http-directory-bridge/src/main/java/org/apache/directory/server/HttpDirectoryService.java

Added: directory/apacheds/trunk/http-directory-bridge/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/http-directory-bridge/pom.xml?rev=992802&view=auto
==============================================================================
--- directory/apacheds/trunk/http-directory-bridge/pom.xml (added)
+++ directory/apacheds/trunk/http-directory-bridge/pom.xml Sun Sep  5 15:17:08 2010
@@ -0,0 +1,21 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <artifactId>apacheds-parent</artifactId>
+    <groupId>org.apache.directory.server</groupId>
+    <version>1.5.8-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>apacheds-http-directory-bridge</artifactId>
+  <name>Integrates DirectoryService instance with a web application</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>apacheds-core</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+  </dependencies>
+
+</project>

Added: directory/apacheds/trunk/http-directory-bridge/src/main/java/org/apache/directory/server/BindResponseHolder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/http-directory-bridge/src/main/java/org/apache/directory/server/BindResponseHolder.java?rev=992802&view=auto
==============================================================================
--- directory/apacheds/trunk/http-directory-bridge/src/main/java/org/apache/directory/server/BindResponseHolder.java
(added)
+++ directory/apacheds/trunk/http-directory-bridge/src/main/java/org/apache/directory/server/BindResponseHolder.java
Sun Sep  5 15:17:08 2010
@@ -0,0 +1,60 @@
+/*
+ *   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.server;
+
+
+import org.apache.directory.ldap.client.api.LdapConnection;
+import org.apache.directory.shared.ldap.message.BindResponse;
+
+
+/**
+ * A holder class for holding LdapConnection and BindResponse object.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class BindResponseHolder
+{
+    /** the ldap connection */
+    private LdapConnection connection;
+
+    /** the bind response */
+    private BindResponse response;
+
+
+    public BindResponseHolder( BindResponse response, LdapConnection connection )
+    {
+        this.response = response;
+        this.connection = connection;
+    }
+
+
+    public LdapConnection getConnection()
+    {
+        return connection;
+    }
+
+
+    public BindResponse getResponse()
+    {
+        return response;
+    }
+
+}

Added: directory/apacheds/trunk/http-directory-bridge/src/main/java/org/apache/directory/server/HttpDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/http-directory-bridge/src/main/java/org/apache/directory/server/HttpDirectoryService.java?rev=992802&view=auto
==============================================================================
--- directory/apacheds/trunk/http-directory-bridge/src/main/java/org/apache/directory/server/HttpDirectoryService.java
(added)
+++ directory/apacheds/trunk/http-directory-bridge/src/main/java/org/apache/directory/server/HttpDirectoryService.java
Sun Sep  5 15:17:08 2010
@@ -0,0 +1,105 @@
+/*
+ *   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.server;
+
+
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.LdapCoreSessionConnection;
+import org.apache.directory.shared.ldap.message.BindRequest;
+import org.apache.directory.shared.ldap.message.BindResponse;
+import org.apache.directory.shared.ldap.message.BindResponseImpl;
+import org.apache.directory.shared.ldap.message.LdapResult;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+
+
+/**
+ * A wrapper containing the instance of DirectoryService instance to prevent web applications
from 
+ * accessing the DirectoryService.
+ * 
+ * An instance of this class gets injected into every webapp's context to let the web applications

+ * access the DirectoryService through LdapCoreSessionConnection.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class HttpDirectoryService
+{
+    /** the directory service instance */
+    private final DirectoryService dirService;
+
+    /** 
+     * name of key used while injecting the directory service instance into the
+     * webapp's servlet context
+     */
+    public static final String KEY = HttpDirectoryService.class.getName();
+
+
+    public HttpDirectoryService( DirectoryService dirService )
+    {
+        this.dirService = dirService;
+    }
+
+
+    /**
+     * performs bind operation on the directory service with the given bind request.
+     * 
+     * This method returns a holder containing a LdapConection and the BindResponse, this
+     * is to allow the caller to access any special controls that might be associated with
a
+     * bind response. 
+     * 
+     * @param bindReq the bind request
+     * @return a holder containing LdapConnection and BindResponse objects. LdapConnection
will
+     *         be set to null If the bind operation is not successful
+     */
+    public BindResponseHolder bind( BindRequest bindReq )
+    {
+        BindResponseHolder holder = null;
+        BindResponse resp = null;
+
+        try
+        {
+            LdapCoreSessionConnection connection = new LdapCoreSessionConnection( dirService
);
+
+            resp = connection.bind( bindReq );
+
+            holder = new BindResponseHolder( resp, connection );
+        }
+        catch ( Exception e )
+        {
+            resp = new BindResponseImpl();
+
+            LdapResult result = resp.getLdapResult();
+            result.setErrorMessage( e.getMessage() );
+            result.setResultCode( ResultCodeEnum.getResultCode( e ) );
+
+            holder = new BindResponseHolder( resp, null );
+        }
+
+        return holder;
+    }
+
+
+    public SchemaManager getSchemaManager()
+    {
+        return dirService.getSchemaManager();
+    }
+
+}



Mime
View raw message