You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ka...@apache.org on 2010/09/05 19:14:02 UTC
svn commit: r992827 [3/4] - in /directory/sandbox/kayyagari/http-directory:
./ directory-http-ui/ directory-http-ui/src/ directory-http-ui/src/main/
directory-http-ui/src/main/java/ directory-http-ui/src/main/java/org/
directory-http-ui/src/main/java/o...
Added: directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/webapp/META-INF/LICENSE
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/webapp/META-INF/LICENSE?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/webapp/META-INF/LICENSE (added)
+++ directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/webapp/META-INF/LICENSE Sun Sep 5 17:13:58 2010
@@ -0,0 +1,343 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+--------------------------------------------------------------------------------------------------
+ANTLR 2 License
+
+We reserve no legal rights to the ANTLR--it is fully in the public domain. An individual or company
+may do whatever they wish with source code distributed with ANTLR or the code generated by ANTLR,
+including the incorporation of ANTLR, or its output, into commerical software.
+
+We encourage users to develop software with ANTLR. However, we do ask that credit is given to us
+for developing ANTLR. By "credit", we mean that if you use ANTLR or incorporate any source code
+into one of your programs (commercial product, research project, or otherwise) that you acknowledge
+this fact somewhere in the documentation, research report, etc... If you like ANTLR and have developed
+a nice tool with the output, please mention that you developed it using ANTLR. In addition, we ask that
+the headers remain intact in our source code. As long as these guidelines are kept, we expect to
+continue enhancing this system and expect to make other tools available as they are completed.
+
+--------------------------------------------------------------------------------------------------
+/**
+ * JDBM LICENSE v1.00
+ *
+ * Redistribution and use of this software and associated documentation
+ * ("Software"), with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain copyright
+ * statements and notices. Redistributions must also contain a
+ * copy of this document.
+ *
+ * 2. Redistributions in binary form must reproduce the
+ * above copyright notice, this list of conditions and the
+ * following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * 3. The name "JDBM" must not be used to endorse or promote
+ * products derived from this Software without prior written
+ * permission of Cees de Groot. For written permission,
+ * please contact cg@cdegroot.com.
+ *
+ * 4. Products derived from this Software may not be called "JDBM"
+ * nor may "JDBM" appear in their names without prior written
+ * permission of Cees de Groot.
+ *
+ * 5. Due credit should be given to the JDBM Project
+ * (http://jdbm.sourceforge.net/).
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE JDBM PROJECT AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
+ * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CEES DE GROOT OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Copyright 2000 (C) Cees de Groot. All Rights Reserved.
+ * Contributions are Copyright (C) 2000 by their associated contributors.
+ *
+ * $Id: LICENSE.txt,v 1.1 2000/05/05 23:59:52 boisvert Exp $
+ */
+--------------------------------------------------------------------------------------------------
+Copyright (c) 2000-2006 The Legion Of The Bouncy Castle (http://www.bouncycastle.org)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+and associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial
+portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+--------------------------------------------------------------------------------------------------
+JUG (package org/safehaus/uuid) is licensed under the AL v2.
+--------------------------------------------------------------------------------------------------
+Opensymphony Quartz is licensed under the AL v2.
+--------------------------------------------------------------------------------------------------
+Spring is licensed under the AL v2.
+--------------------------------------------------------------------------------------------------
+slf4j license:
+Copyright (c) 2004-2007 QOS.ch All rights reserved. Permission is hereby granted, free of charge,
+to any person obtaining a copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation the rights to use, copy,
+modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
+persons to whom the Software is furnished to do so, subject to the following conditions: The above
+copyright notice and this permission notice shall be included in all copies or substantial portions
+of the Software.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+--------------------------------------------------------------------------------------------------
+Copyright (c) 1999, 2004 Tanuki Software
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of the Java Service Wrapper and associated
+documentation files (the "Software"), to deal in the Software
+without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sub-license,
+and/or sell copies of the Software, and to permit persons to
+whom the Software is furnished to do so, subject to the
+following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+
+Portions of the Software have been derived from source code
+developed by Silver Egg Technology under the following license:
+
+Copyright (c) 2001 Silver Egg Technology
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sub-license, and/or
+sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
Added: directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/webapp/META-INF/NOTICE
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/webapp/META-INF/NOTICE?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/webapp/META-INF/NOTICE (added)
+++ directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/webapp/META-INF/NOTICE Sun Sep 5 17:13:58 2010
@@ -0,0 +1,30 @@
+
+Apache Directory Server
+Copyright 2003-2008 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
+
+Safehaus JUG
+Copyright 2005 Safehaus
+
+This product includes software developed at
+Safehaus (http://docs.safehaus.org/display/HAUS/Home).
+
+OpenSymphony Quartz
+Copyright 2004-2005 OpenSymphony
+
+This product includes software developed at
+OpenSymphony (http://www.opensymphony.com/).
+
+ ======================================================================
+ == NOTICE file corresponding to section 4 d of the Apache License, ==
+ ======================================================================
+
+ This product includes software developed by
+ the Apache Software Foundation (http://www.apache.org).
+
+ This product also includes software developed by
+ Clinton Begin (http://www.ibatis.com).
Added: directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/webapp/WEB-INF/web.xml?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/webapp/WEB-INF/web.xml (added)
+++ directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/webapp/WEB-INF/web.xml Sun Sep 5 17:13:58 2010
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE web-app
+ PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<web-app>
+
+ <listener>
+ <listener-class>org.apache.directory.server.http.AppContextListener</listener-class>
+ </listener>
+<!--
+ <filter>
+ <filter-name>LoggingFilter</filter-name>
+ <filter-class>org.apache.directory.server.http.LoggingFilter</filter-class>
+ </filter>
+
+ <filter>
+ <filter-name>AuthenticationFilter</filter-name>
+ <filter-class>org.apache.directory.server.http.AuthenticationFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>LoggingFilter</filter-name>
+ <servlet-name>HttpDirectoryServlet</servlet-name>
+ </filter-mapping>
+ <filter-mapping>
+ <filter-name>AuthenticationFilter</filter-name>
+ <servlet-name>HttpDirectoryServlet</servlet-name>
+ </filter-mapping>
+ -->
+ <servlet>
+ <servlet-name>HttpDirectoryServlet</servlet-name>
+ <servlet-class>org.apache.directory.server.http.HttpDirectoryServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>HttpDirectoryServlet</servlet-name>
+ <url-pattern>/ldap/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
Added: directory/sandbox/kayyagari/http-directory/directory-webapp/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/directory-webapp/src/test/resources/log4j.properties?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/directory-webapp/src/test/resources/log4j.properties (added)
+++ directory/sandbox/kayyagari/http-directory/directory-webapp/src/test/resources/log4j.properties Sun Sep 5 17:13:58 2010
@@ -0,0 +1,45 @@
+#############################################################################
+# 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.
+#############################################################################
+log4j.rootCategory=warn, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+
+log4j.appender.R=org.apache.log4j.RollingFileAppender
+log4j.appender.R.File=apacheds-rolling.log
+
+log4j.appender.R.MaxFileSize=1024KB
+# Keep some backup files
+log4j.appender.R.MaxBackupIndex=5
+
+log4j.appender.R.layout=org.apache.log4j.PatternLayout
+log4j.appender.R.layout.ConversionPattern=[%d{HH:mm:ss}] %p [%c] - %m%n
+
+log4j.appender.stdout.layout.ConversionPattern=[%d{HH:mm:ss}] %p [%c] - %m%n
+
+# with these we'll not get innundated when switching to DEBUG
+log4j.logger.org.apache.directory.shared.ldap.name=FATAL
+log4j.logger.org.apache.directory.shared=warn
+log4j.logger.org.apache.directory.server.core=WARN
+
+log4j.logger.org.apache.directory.server.schema.registries=FATAL
+log4j.logger.org.apache.directory.server.http=DEBUG
+log4j.logger.org.mortbay.log=WARN
+log4j.logger.JdbmTable=WARN
+log4j.logger.org.apache.directory.server.xdbm=WARN
+log4j.logger.JdbmIndex=WARN
+log4j.logger.org.apache.directory.server.config=WARN
Added: directory/sandbox/kayyagari/http-directory/ldap-http-connection/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-http-connection/pom.xml?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-http-connection/pom.xml (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-http-connection/pom.xml Sun Sep 5 17:13:58 2010
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.directory.server</groupId>
+ <artifactId>http-directory</artifactId>
+ <version>1.5.8-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.directory.http.client</groupId>
+ <artifactId>ldap-http-connection</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <name>a LdapConnection implementation using HTTP as transport</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.directory.server</groupId>
+ <artifactId>ldap-json-codec</artifactId>
+ <version>1.5.8-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ <version>4.0.1</version>
+ </dependency>
+
+ </dependencies>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.1</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: directory/sandbox/kayyagari/http-directory/ldap-http-connection/src/main/java/org/apache/directory/http/client/JsonEntryToResponseCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-http-connection/src/main/java/org/apache/directory/http/client/JsonEntryToResponseCursor.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-http-connection/src/main/java/org/apache/directory/http/client/JsonEntryToResponseCursor.java (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-http-connection/src/main/java/org/apache/directory/http/client/JsonEntryToResponseCursor.java Sun Sep 5 17:13:58 2010
@@ -0,0 +1,250 @@
+/*
+ * 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.http.client;
+
+
+import java.util.Iterator;
+
+import org.apache.directory.server.codec.json.JsonBuilder;
+import org.apache.directory.server.http.AppConstants;
+import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.cursor.ClosureMonitor;
+import org.apache.directory.shared.ldap.cursor.Cursor;
+import org.apache.directory.shared.ldap.cursor.InvalidCursorPositionException;
+import org.apache.directory.shared.ldap.entry.DefaultEntry;
+import org.apache.directory.shared.ldap.message.LdapResult;
+import org.apache.directory.shared.ldap.message.LdapResultImpl;
+import org.apache.directory.shared.ldap.message.SearchResultDone;
+import org.apache.directory.shared.ldap.message.SearchResultDoneImpl;
+import org.apache.directory.shared.ldap.message.SearchResultEntry;
+import org.apache.directory.shared.ldap.message.SearchResultEntryImpl;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+
+
+/**
+ * A cursor to get SearchResponses after setting the underlying cursor's
+ * ServerEntry object in SearchResultEnty object
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class JsonEntryToResponseCursor<Response> implements Cursor<Response>
+{
+ /** a reference to hold the SearchResultDone response */
+ private SearchResultDone searchDoneResp;
+
+ private int messageId;
+
+ private DefaultEntry entry;
+
+ private Iterator<JsonElement> results;
+
+ private ClosureMonitor monitor;
+
+
+ public JsonEntryToResponseCursor()
+ {
+ results = new JsonArray().iterator();
+ }
+
+ public JsonEntryToResponseCursor( String jsonSearchResults )
+ {
+ JsonObject json = new JsonParser().parse( jsonSearchResults ).getAsJsonObject();
+
+ JsonArray resultsArray = json.get( AppConstants.SEARCH_RESULTS_KEY ).getAsJsonArray();
+ results = resultsArray.iterator();
+
+ searchDoneResp = new SearchResultDoneImpl();
+ LdapResult original = JsonBuilder.get().fromJson( json.get( AppConstants.LDAP_RESULT_KEY ), LdapResultImpl.class );
+
+ LdapResult userResult = searchDoneResp.getLdapResult();
+ userResult.setErrorMessage( original.getErrorMessage() );
+ userResult.setMatchedDn( original.getMatchedDn() );
+ userResult.setReferral( original.getReferral() );
+ userResult.setResultCode( original.getResultCode() );
+ }
+
+
+ public boolean available()
+ {
+ return ( entry != null );
+ }
+
+
+ public void close() throws Exception
+ {
+ results = null;
+ entry = null;
+ }
+
+
+ public void close( Exception e ) throws Exception
+ {
+ close();
+ }
+
+
+ public Response get() throws Exception
+ {
+ if( !available() )
+ {
+ throw new InvalidCursorPositionException( "no entry present at this current position" );
+ }
+
+ SearchResultEntry se = new SearchResultEntryImpl( messageId );
+ se.setEntry( entry );
+
+ return ( Response ) se;
+ }
+
+
+ public boolean next() throws Exception
+ {
+ boolean next = results.hasNext();
+ if ( next )
+ {
+ JsonElement json = results.next();
+ entry = JsonBuilder.get().fromJson( json, DefaultEntry.class );
+ }
+
+ return next;
+ }
+
+
+ /**
+ * gives the SearchResultDone message received at the end of search results
+ *
+ * @return the SearchResultDone message, null if the search operation fails for any reason
+ */
+ public SearchResultDone getSearchDone()
+ {
+ return searchDoneResp;
+ }
+
+
+ public boolean isClosed() throws Exception
+ {
+ return ( ( results == null ) || results.hasNext() );
+ }
+
+
+ public boolean isElementReused()
+ {
+ return true;
+ }
+
+
+ public Iterator<Response> iterator()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void after( Response resp ) throws Exception
+ {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void afterLast() throws Exception
+ {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public boolean first() throws Exception
+ {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void before( Response resp ) throws Exception
+ {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void beforeFirst() throws Exception
+ {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public boolean last() throws Exception
+ {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public boolean previous() throws Exception
+ {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void setClosureMonitor( ClosureMonitor monitor )
+ {
+ this.monitor = monitor;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isAfterLast() throws Exception
+ {
+ throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
+ .concat( "." ).concat( "isAfterLast()" ) ) );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isBeforeFirst() throws Exception
+ {
+ throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
+ .concat( "." ).concat( "isBeforeFirst()" ) ) );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isFirst() throws Exception
+ {
+ throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
+ .concat( "." ).concat( "isFirst()" ) ) );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isLast() throws Exception
+ {
+ throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
+ .concat( "." ).concat( "isLast()" ) ) );
+ }
+}
Added: directory/sandbox/kayyagari/http-directory/ldap-http-connection/src/main/java/org/apache/directory/http/client/LdapHttpConnection.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-http-connection/src/main/java/org/apache/directory/http/client/LdapHttpConnection.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-http-connection/src/main/java/org/apache/directory/http/client/LdapHttpConnection.java (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-http-connection/src/main/java/org/apache/directory/http/client/LdapHttpConnection.java Sun Sep 5 17:13:58 2010
@@ -0,0 +1,1113 @@
+/*
+ * 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.http.client;
+
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.directory.ldap.client.api.LdapConnection;
+import org.apache.directory.ldap.client.api.NetworkSchemaLoader;
+import org.apache.directory.server.codec.json.JsonBuilder;
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.http.AppConstants;
+import org.apache.directory.shared.asn1.primitives.OID;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.cursor.Cursor;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.exception.LdapException;
+import org.apache.directory.shared.ldap.filter.SearchScope;
+import org.apache.directory.shared.ldap.message.AbandonRequest;
+import org.apache.directory.shared.ldap.message.AbstractResultResponse;
+import org.apache.directory.shared.ldap.message.AddRequest;
+import org.apache.directory.shared.ldap.message.AddRequestImpl;
+import org.apache.directory.shared.ldap.message.AddResponse;
+import org.apache.directory.shared.ldap.message.AliasDerefMode;
+import org.apache.directory.shared.ldap.message.BindRequest;
+import org.apache.directory.shared.ldap.message.BindRequestImpl;
+import org.apache.directory.shared.ldap.message.BindResponse;
+import org.apache.directory.shared.ldap.message.BindResponseImpl;
+import org.apache.directory.shared.ldap.message.CompareRequest;
+import org.apache.directory.shared.ldap.message.CompareRequestImpl;
+import org.apache.directory.shared.ldap.message.CompareResponse;
+import org.apache.directory.shared.ldap.message.DeleteRequest;
+import org.apache.directory.shared.ldap.message.DeleteRequestImpl;
+import org.apache.directory.shared.ldap.message.DeleteResponse;
+import org.apache.directory.shared.ldap.message.ExtendedRequest;
+import org.apache.directory.shared.ldap.message.ExtendedResponse;
+import org.apache.directory.shared.ldap.message.Message;
+import org.apache.directory.shared.ldap.message.ModifyDnRequest;
+import org.apache.directory.shared.ldap.message.ModifyDnRequestImpl;
+import org.apache.directory.shared.ldap.message.ModifyDnResponse;
+import org.apache.directory.shared.ldap.message.ModifyRequest;
+import org.apache.directory.shared.ldap.message.ModifyRequestImpl;
+import org.apache.directory.shared.ldap.message.ModifyResponse;
+import org.apache.directory.shared.ldap.message.Response;
+import org.apache.directory.shared.ldap.message.ResultResponseRequest;
+import org.apache.directory.shared.ldap.message.SearchRequest;
+import org.apache.directory.shared.ldap.message.SearchRequestImpl;
+import org.apache.directory.shared.ldap.message.SearchResultEntry;
+import org.apache.directory.shared.ldap.message.control.Control;
+import org.apache.directory.shared.ldap.name.DN;
+import org.apache.directory.shared.ldap.name.RDN;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.util.EntityUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * TODO LdapHttpConnection.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class LdapHttpConnection implements LdapConnection
+{
+
+ /** the SchemaManager */
+ private SchemaManager schemaManager;
+
+ private AtomicInteger messageId = new AtomicInteger( 0 );
+
+ private static final Logger LOG = LoggerFactory.getLogger( LdapHttpConnection.class );
+
+ private URL serviceUrl;
+
+ /** list of controls supported by the server */
+ private List<String> supportedControls;
+
+ /** The ROOT DSE entry */
+ private Entry rootDSE;
+
+ private HttpClient client;
+
+ private String bindUri;
+
+ private String searhUri;
+
+ private String modifyUri;
+
+ private String modifyDnUri;
+
+ private String unBindUri;
+
+ private String addUri;
+
+ private String deleteUri;
+
+ private String compareUri;
+
+ private Header sessionHeader;
+
+
+ public LdapHttpConnection( URL url ) throws Exception
+ {
+ serviceUrl = url;
+
+ bindUri = url + AppConstants.BIND_URI;
+ searhUri = url + AppConstants.SEARCH_URI;
+ modifyUri = url + AppConstants.MODIFY_URI;
+ modifyDnUri = url + AppConstants.MODIFY_DN_URI;
+ unBindUri = url + AppConstants.UNBIND_URI;
+ addUri = url + AppConstants.ADD_URI;
+ deleteUri = url + AppConstants.DELETE_URI;
+ compareUri = url + AppConstants.COMPARE_URI;
+
+ client = new DefaultHttpClient();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean close() throws IOException
+ {
+ try
+ {
+ unBind();
+ }
+ catch ( Exception e )
+ {
+ throw new IOException( e.getMessage() );
+ }
+
+ return true;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean connect() throws LdapException, IOException
+ {
+ if ( client == null )
+ {
+ client = new DefaultHttpClient();
+ }
+
+ return true;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public AddResponse add( AddRequest addRequest ) throws LdapException
+ {
+ try
+ {
+ int newId = messageId.incrementAndGet();
+ addRequest.setMessageId( newId );
+
+ HttpPost post = new HttpPost( addUri );
+ post.setHeader( sessionHeader );
+ post.setEntity( new StringEntity( JsonBuilder.toJson( addRequest ) ) );
+
+ HttpResponse response = client.execute( post );
+
+ String json = EntityUtils.toString( response.getEntity() );
+ System.out.println( json );
+
+ AddResponse resp = ( AddResponse ) JsonBuilder.fromJson( json, AbstractResultResponse.class );
+
+ return resp;
+ }
+ catch ( Exception e )
+ {
+ throw new LdapException( e );
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public AddResponse add( Entry entry ) throws LdapException
+ {
+ AddRequest addRequest = new AddRequestImpl();
+ addRequest.setEntry( entry );
+
+ return add( addRequest );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public CompareResponse compare( CompareRequest compareRequest ) throws LdapException
+ {
+ try
+ {
+ int newId = messageId.incrementAndGet();
+ compareRequest.setMessageId( newId );
+
+ HttpPost post = new HttpPost( compareUri );
+ post.setHeader( sessionHeader );
+
+ post.setEntity( new StringEntity( JsonBuilder.toJson( compareRequest ) ) );
+ HttpResponse response = client.execute( post );
+ String json = EntityUtils.toString( response.getEntity() );
+
+ CompareResponse resp = ( CompareResponse ) JsonBuilder.fromJson( json, AbstractResultResponse.class );
+ return resp;
+ }
+ catch ( Exception e )
+ {
+ throw new LdapException( e );
+ }
+
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public CompareResponse compare( DN dn, String attributeName, byte[] value ) throws LdapException
+ {
+ CompareRequest compareRequest = new CompareRequestImpl();
+ compareRequest.setName( dn );
+ compareRequest.setAttributeId( attributeName );
+ compareRequest.setAssertionValue( value );
+
+ return compare( compareRequest );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public CompareResponse compare( DN dn, String attributeName, String value ) throws LdapException
+ {
+ CompareRequest compareRequest = new CompareRequestImpl();
+ compareRequest.setName( dn );
+ compareRequest.setAttributeId( attributeName );
+ compareRequest.setAssertionValue( value );
+
+ return compare( compareRequest );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public CompareResponse compare( String dn, String attributeName, byte[] value ) throws LdapException
+ {
+ return compare( new DN( dn ), attributeName, value );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public CompareResponse compare( String dn, String attributeName, String value ) throws LdapException
+ {
+ return compare( new DN( dn ), attributeName, value );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public CompareResponse compare( DN dn, String attributeName, Value<?> value ) throws LdapException
+ {
+ CompareRequest compareRequest = new CompareRequestImpl();
+ compareRequest.setName( dn );
+ compareRequest.setAttributeId( attributeName );
+
+ if ( value.isBinary() )
+ {
+ compareRequest.setAssertionValue( value.getBytes() );
+ }
+ else
+ {
+ compareRequest.setAssertionValue( value.getString() );
+ }
+
+ return compare( compareRequest );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public CompareResponse compare( String dn, String attributeName, Value<?> value ) throws LdapException
+ {
+ return compare( new DN( dn ), attributeName, value );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public DeleteResponse delete( DeleteRequest deleteRequest ) throws LdapException
+ {
+ try
+ {
+ int newId = messageId.incrementAndGet();
+ deleteRequest.setMessageId( newId );
+
+ HttpPost post = new HttpPost( deleteUri );
+ post.setHeader( sessionHeader );
+
+ post.setEntity( new StringEntity( JsonBuilder.toJson( deleteRequest ) ) );
+ HttpResponse response = client.execute( post );
+ String json = EntityUtils.toString( response.getEntity() );
+
+ DeleteResponse resp = ( DeleteResponse ) JsonBuilder.fromJson( json, AbstractResultResponse.class );
+
+ return resp;
+ }
+ catch ( Exception e )
+ {
+ throw new LdapException( e );
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public DeleteResponse delete( DN dn ) throws LdapException
+ {
+ DeleteRequest deleteRequest = new DeleteRequestImpl();
+ deleteRequest.setName( dn );
+
+ return delete( deleteRequest );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public DeleteResponse delete( String dn ) throws LdapException
+ {
+ return delete( new DN( dn ) );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean doesFutureExistFor( Integer messageId )
+ {
+ return false;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SchemaManager getSchemaManager()
+ {
+ return schemaManager;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<String> getSupportedControls() throws LdapException
+ {
+ if ( supportedControls != null )
+ {
+ return supportedControls;
+ }
+
+ if ( rootDSE == null )
+ {
+ fetchRootDSE();
+ }
+
+ supportedControls = new ArrayList<String>();
+
+ EntryAttribute attr = rootDSE.get( SchemaConstants.SUPPORTED_CONTROL_AT );
+
+ for ( Value<?> value : attr )
+ {
+ supportedControls.add( value.getString() );
+ }
+
+ return supportedControls;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isAuthenticated()
+ {
+ return ( sessionHeader != null );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isConnected()
+ {
+ return true;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isControlSupported( String controlOID ) throws LdapException
+ {
+ return false;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void loadSchema() throws LdapException
+ {
+ try
+ {
+ NetworkSchemaLoader loader = new NetworkSchemaLoader( this );
+ schemaManager = new DefaultSchemaManager( loader );
+
+ boolean loaded = schemaManager.loadAllEnabled();
+ if ( !loaded )
+ {
+ LOG.debug( "problems encountered while initializing the schema manager {}", schemaManager.getErrors() );
+ }
+
+ LOG.debug( "schema manager was initialized successfully" );
+ }
+ catch ( Exception e )
+ {
+ throw new LdapException( e );
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Entry lookup( DN dn, String... attributes ) throws LdapException
+ {
+ Entry entry = null;
+
+ try
+ {
+ Cursor<Response> cursor = search( dn, "(objectClass=*)", SearchScope.OBJECT, attributes );
+
+ // Read the response
+ if ( cursor.next() )
+ {
+ // cursor will always hold SearchResultEntry objects cause there is no ManageDsaITControl passed with search request
+ entry = ( ( SearchResultEntry ) cursor.get() ).getEntry();
+ }
+
+ // Pass through the SaerchResultDone, or stop
+ // if we have other responses
+ cursor.next();
+
+ // And close the cursor
+ cursor.close();
+ }
+ catch ( Exception e )
+ {
+ throw new LdapException( e );
+ }
+
+ return entry;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Entry lookup( String dn, String... attributes ) throws LdapException
+ {
+ return lookup( new DN( dn ), attributes );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Entry lookup( DN dn ) throws LdapException
+ {
+ return lookup( dn, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Entry lookup( String dn ) throws LdapException
+ {
+ return lookup( dn, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ModifyResponse modify( DN dn, Modification... modifications ) throws LdapException
+ {
+ if ( dn == null )
+ {
+ LOG.debug( "received a null dn for modification" );
+ throw new IllegalArgumentException( "The DN to be modified cannot be null" );
+ }
+
+ ModifyRequest modReq = new ModifyRequestImpl();
+ modReq.setName( dn );
+
+ for ( Modification modification : modifications )
+ {
+ modReq.addModification( modification );
+ }
+
+ return modify( modReq );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ModifyResponse modify( String dn, Modification... modifications ) throws LdapException
+ {
+ return modify( new DN( dn ), modifications );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ModifyResponse modify( Entry entry, ModificationOperation modOp ) throws LdapException
+ {
+ if ( entry == null )
+ {
+ LOG.debug( "received a null entry for modification" );
+ throw new IllegalArgumentException( "Entry to be modified cannot be null" );
+ }
+
+ ModifyRequest modReq = new ModifyRequestImpl();
+ modReq.setName( entry.getDn() );
+
+ Iterator<EntryAttribute> itr = entry.iterator();
+ while ( itr.hasNext() )
+ {
+ modReq.addModification( itr.next(), modOp );
+ }
+
+ return modify( modReq );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ModifyResponse modify( ModifyRequest modRequest ) throws LdapException
+ {
+ try
+ {
+ int newId = messageId.incrementAndGet();
+ modRequest.setMessageId( newId );
+
+ HttpPost post = new HttpPost( modifyUri );
+ post.setHeader( sessionHeader );
+
+ post.setEntity( new StringEntity( JsonBuilder.toJson( modRequest ) ) );
+
+ HttpResponse response = client.execute( post );
+
+ String json = EntityUtils.toString( response.getEntity() );
+
+ ModifyResponse resp = ( ModifyResponse ) JsonBuilder.fromJson( json, AbstractResultResponse.class );
+
+ return resp;
+ }
+ catch ( Exception e )
+ {
+ throw new LdapException( e );
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ * WARNING: this method is not in compatible with CoreSession API in some cases
+ * cause this we call {@link CoreSession#move(ModifyDnRequest)} always from this method.
+ * Instead use other specific modifyDn operations like {@link #move(DN, DN)}, {@link #rename(DN, RDN)} etc..
+ */
+ public ModifyDnResponse modifyDn( ModifyDnRequest modDnRequest ) throws LdapException
+ {
+
+ try
+ {
+ int newId = messageId.incrementAndGet();
+ modDnRequest.setMessageId( newId );
+
+ HttpPost post = new HttpPost( modifyDnUri );
+ post.setHeader( sessionHeader );
+ post.setEntity( new StringEntity( JsonBuilder.toJson( modDnRequest ) ) );
+
+ HttpResponse response = client.execute( post );
+ String json = EntityUtils.toString( response.getEntity() );
+
+ ModifyDnResponse resp = ( ModifyDnResponse ) JsonBuilder.fromJson( json, AbstractResultResponse.class );
+ return resp;
+ }
+ catch ( Exception e )
+ {
+ throw new LdapException( e );
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ModifyDnResponse move( DN entryDn, DN newSuperiorDn ) throws LdapException
+ {
+ ModifyDnRequest modDnRequest = new ModifyDnRequestImpl();
+ modDnRequest.setName( entryDn );
+ modDnRequest.setNewSuperior( newSuperiorDn );
+
+ //TODO not setting the below value is resulting in error
+ //modDnRequest.setNewRdn( entryDn.getRdn() );
+
+ return modifyDn( modDnRequest );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ModifyDnResponse move( String entryDn, String newSuperiorDn ) throws LdapException
+ {
+ return move( new DN( entryDn ), new DN( newSuperiorDn ) );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ModifyDnResponse rename( DN entryDn, RDN newRdn, boolean deleteOldRdn ) throws LdapException
+ {
+ ModifyDnRequest modDnRequest = new ModifyDnRequestImpl();
+ modDnRequest.setName( entryDn );
+ modDnRequest.setNewRdn( newRdn );
+ modDnRequest.setDeleteOldRdn( deleteOldRdn );
+
+ return modifyDn( modDnRequest );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ModifyDnResponse rename( DN entryDn, RDN newRdn ) throws LdapException
+ {
+ return rename( entryDn, newRdn, false );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ModifyDnResponse rename( String entryDn, String newRdn, boolean deleteOldRdn ) throws LdapException
+ {
+ return rename( new DN( entryDn ), new RDN( newRdn ), deleteOldRdn );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ModifyDnResponse rename( String entryDn, String newRdn ) throws LdapException
+ {
+ return rename( new DN( entryDn ), new RDN( newRdn ) );
+ }
+
+
+ /**
+ * Moves and renames the given entryDn.The old RDN will be deleted
+ *
+ * @see #moveAndRename(DN, DN, boolean)
+ */
+ public ModifyDnResponse moveAndRename( DN entryDn, DN newDn ) throws LdapException
+ {
+ return moveAndRename( entryDn, newDn, true );
+ }
+
+
+ /**
+ * Moves and renames the given entryDn.The old RDN will be deleted
+ *
+ * @see #moveAndRename(DN, DN, boolean)
+ */
+ public ModifyDnResponse moveAndRename( String entryDn, String newDn ) throws LdapException
+ {
+ return moveAndRename( new DN( entryDn ), new DN( newDn ), true );
+ }
+
+
+ /**
+ * Moves and renames the given entryDn.The old RDN will be deleted if requested
+ *
+ * @param entryDn The original entry DN
+ * @param newDn The new Entry DN
+ * @param deleteOldRdn Tells if the old RDN must be removed
+ */
+ public ModifyDnResponse moveAndRename( DN entryDn, DN newDn, boolean deleteOldRdn ) throws LdapException
+ {
+ // Check the parameters first
+ if ( entryDn == null )
+ {
+ throw new IllegalArgumentException( "The entry DN must not be null" );
+ }
+
+ if ( entryDn.isRootDSE() )
+ {
+ throw new IllegalArgumentException( "The RootDSE cannot be moved" );
+ }
+
+ if ( newDn == null )
+ {
+ throw new IllegalArgumentException( "The new DN must not be null" );
+ }
+
+ if ( newDn.isRootDSE() )
+ {
+ throw new IllegalArgumentException( "The RootDSE cannot be the target" );
+ }
+
+ // Create the request
+ ModifyDnRequest modDnRequest = new ModifyDnRequestImpl();
+ modDnRequest.setName( entryDn );
+ modDnRequest.setNewRdn( newDn.getRdn() );
+ modDnRequest.setNewSuperior( newDn.getParent() );
+ modDnRequest.setDeleteOldRdn( deleteOldRdn );
+
+ return modifyDn( modDnRequest );
+ }
+
+
+ /**
+ * Moves and renames the given entryDn.The old RDN will be deleted if requested
+ *
+ * @param entryDn The original entry DN
+ * @param newDn The new Entry DN
+ * @param deleteOldRdn Tells if the old RDN must be removed
+ */
+ public ModifyDnResponse moveAndRename( String entryDn, String newDn, boolean deleteOldRdn ) throws LdapException
+ {
+ return moveAndRename( new DN( entryDn ), new DN( newDn ), deleteOldRdn );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Cursor<Response> search( SearchRequest searchRequest ) throws LdapException
+ {
+ try
+ {
+ int newId = messageId.incrementAndGet();
+
+ searchRequest.setMessageId( newId );
+
+ HttpPost post = new HttpPost( searhUri );
+ post.addHeader( sessionHeader );
+ post.setEntity( new StringEntity( JsonBuilder.get().toJson( searchRequest ) ) );
+
+ HttpResponse resp = client.execute( post );
+ String json = EntityUtils.toString( resp.getEntity() );
+ // System.out.println( json );
+
+ return new JsonEntryToResponseCursor<Response>( json );
+ }
+ catch ( Exception e )
+ {
+ LOG.warn( e.getMessage(), e );
+ }
+
+ return new JsonEntryToResponseCursor<Response>();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Cursor<Response> search( DN baseDn, String filter, SearchScope scope, String... attributes )
+ throws LdapException
+ {
+ // generate some random operation number
+ SearchRequest searchRequest = new SearchRequestImpl();
+
+ searchRequest.setBase( baseDn );
+ searchRequest.setFilter( filter );
+ searchRequest.setScope( scope );
+ searchRequest.addAttributes( attributes );
+ searchRequest.setDerefAliases( AliasDerefMode.DEREF_ALWAYS );
+
+ return search( searchRequest );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Cursor<Response> search( String baseDn, String filter, SearchScope scope, String... attributes )
+ throws LdapException
+ {
+ return search( new DN( baseDn ), filter, scope, attributes );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void unBind() throws Exception
+ {
+ messageId.set( 0 );
+ if ( client != null )
+ {
+ HttpPost post = new HttpPost( unBindUri );
+ post.setHeader( sessionHeader );
+ HttpResponse response = client.execute( post );
+ LOG.debug( "unbind request succeeded with return code {}", response.getStatusLine().getStatusCode() );
+ client.getConnectionManager().shutdown();
+ sessionHeader = null;
+ client = null;
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ExtendedResponse extended( String oid ) throws LdapException
+ {
+ throw new UnsupportedOperationException(
+ "extended operations are not supported on CoreSession based connection" );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ExtendedResponse extended( ExtendedRequest extendedRequest ) throws LdapException
+ {
+ return extended( ( String ) null );
+
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ExtendedResponse extended( OID oid, byte[] value ) throws LdapException
+ {
+ return extended( ( String ) null );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ExtendedResponse extended( OID oid ) throws LdapException
+ {
+ return extended( ( String ) null );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ExtendedResponse extended( String oid, byte[] value ) throws LdapException
+ {
+ return extended( ( String ) null );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setTimeOut( long timeOut )
+ {
+ throw new UnsupportedOperationException( "setting timeout is not supported on CoreSession" );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void abandon( AbandonRequest abandonRequest )
+ {
+ throw new UnsupportedOperationException( "abandon operation is not supported" );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void abandon( int messageId )
+ {
+ abandon( null );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public BindResponse bind() throws LdapException, IOException
+ {
+ BindRequest bindReq = new BindRequestImpl();
+ bindReq.setName( DN.EMPTY_DN );
+ bindReq.setCredentials( ( byte[] ) null );
+
+ return bind( bindReq );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public BindResponse bind( BindRequest bindRequest ) throws LdapException, IOException
+ {
+ int newId = messageId.incrementAndGet();
+ bindRequest.setMessageId( newId );
+
+ BindResponse bindResp = null;
+
+ try
+ {
+ connect();
+
+ HttpPost post = new HttpPost( bindUri );
+ post.setEntity( new StringEntity( JsonBuilder.get().toJson( bindRequest ) ) );
+
+ HttpResponse resp = client.execute( post );
+ sessionHeader = resp.getHeaders( AppConstants.SESSION_ID )[0];
+
+ System.out.println( "received session header " + sessionHeader );
+
+ HttpEntity entity = resp.getEntity();
+ String json = EntityUtils.toString( entity );
+
+ LOG.debug( "received json {}", json );
+
+ bindResp = JsonBuilder.get().fromJson( json, BindResponseImpl.class );
+ }
+ catch ( IOException e )
+ {
+ LOG.warn( e.getMessage(), e );
+ throw e;
+ }
+
+ return bindResp;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public BindResponse bind( DN name, String credentials ) throws LdapException, IOException
+ {
+ byte[] credBytes = ( credentials == null ? StringTools.EMPTY_BYTES : StringTools.getBytesUtf8( credentials ) );
+
+ BindRequest bindReq = new BindRequestImpl();
+ bindReq.setName( name );
+ bindReq.setCredentials( credBytes );
+
+ return bind( bindReq );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public BindResponse bind( String name, String credentials ) throws LdapException, IOException
+ {
+ return bind( new DN( name ), credentials );
+ }
+
+
+ private void addResponseControls( ResultResponseRequest iReq, Message clientResp )
+ {
+ Collection<Control> ctrlSet = iReq.getResultResponse().getControls().values();
+
+ for ( Control c : ctrlSet )
+ {
+ clientResp.addControl( c );
+ }
+ }
+
+ /**
+ * fetches the rootDSE from the server
+ * @throws LdapException
+ */
+ public Entry fetchRootDSE() throws LdapException
+ {
+ Cursor<Response> cursor = null;
+ try
+ {
+ cursor = search( "", "(objectClass=*)", SearchScope.OBJECT, "*", "+" );
+ cursor.next();
+ SearchResultEntry searchRes = ( SearchResultEntry ) cursor.get();
+
+ rootDSE = searchRes.getEntry();
+ }
+ catch ( Exception e )
+ {
+ String msg = "Failed to fetch the RootDSE";
+ LOG.error( msg );
+ throw new LdapException( msg, e );
+ }
+ finally
+ {
+ if ( cursor != null )
+ {
+ try
+ {
+ cursor.close();
+ }
+ catch ( Exception e )
+ {
+ LOG.error( "Failed to close open cursor", e );
+ }
+ }
+ }
+
+ return rootDSE;
+ }
+
+
+ public static void main( String[] args ) throws Exception
+ {
+ LdapHttpConnection con = new LdapHttpConnection( new URL( "http://localhost:7009/adminapp/ldap" ) );
+ BindResponse resp = con.bind( "uid=admin,ou=system", "secret" );
+ System.out.println( resp );
+
+ // con.loadSchema();
+ // JsonBuilder.setSchemaManager( con.getSchemaManager() );
+
+ Entry entry = con.lookup( "uid=admin,ou=system" );
+ System.out.println( entry );
+
+ con.unBind();
+ con.bind( "uid=admin,ou=system", "secret" );
+
+ ModifyRequest modReq = new ModifyRequestImpl();
+ modReq.setName( entry.getDn() );
+ modReq.add( SchemaConstants.CN_AT, "http administrator" );
+
+ // System.out.println( con.modify( modReq ) );
+
+ entry = con.lookup( "uid=admin,ou=system" );
+ System.out.println( entry );
+
+ Cursor<Response> cursor = con.search( "cn=apache,ou=schema", "(objectClass=*)", SearchScope.ONELEVEL,
+ "objectClass" );
+ while ( cursor.next() )
+ {
+ // System.out.println( ( ( SearchResultEntry ) cursor.get() ).getEntry() );
+ }
+
+ cursor.close();
+ }
+}
Added: directory/sandbox/kayyagari/http-directory/ldap-json-codec/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-json-codec/pom.xml?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-json-codec/pom.xml (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-json-codec/pom.xml Sun Sep 5 17:13:58 2010
@@ -0,0 +1,56 @@
+<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>
+ <groupId>org.apache.directory.server</groupId>
+ <artifactId>http-directory</artifactId>
+ <version>1.5.8-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.directory.server</groupId>
+ <artifactId>ldap-json-codec</artifactId>
+ <packaging>jar</packaging>
+ <name>ldap-json-codec</name>
+
+ <properties>
+ <org.apache.directory.shared.version>0.9.20-SNAPSHOT</org.apache.directory.shared.version>
+ <shared.groupId>org.apache.directory.shared</shared.groupId>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.7</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>apacheds-core-api</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>1.4</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.1</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/AbstractResultResponseCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/AbstractResultResponseCodec.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/AbstractResultResponseCodec.java (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/AbstractResultResponseCodec.java Sun Sep 5 17:13:58 2010
@@ -0,0 +1,112 @@
+/*
+ * 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.codec.json;
+
+import java.lang.reflect.Type;
+
+import org.apache.directory.server.http.AppConstants;
+import org.apache.directory.shared.ldap.codec.MessageTypeEnum;
+import org.apache.directory.shared.ldap.message.AbstractResultResponse;
+import org.apache.directory.shared.ldap.message.AddResponseImpl;
+import org.apache.directory.shared.ldap.message.BindResponseImpl;
+import org.apache.directory.shared.ldap.message.CompareResponseImpl;
+import org.apache.directory.shared.ldap.message.DeleteResponseImpl;
+import org.apache.directory.shared.ldap.message.LdapResult;
+import org.apache.directory.shared.ldap.message.LdapResultImpl;
+import org.apache.directory.shared.ldap.message.ModifyDnResponseImpl;
+import org.apache.directory.shared.ldap.message.ModifyResponseImpl;
+
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
+/**
+ * TODO AbstractResultResponseCodec.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class AbstractResultResponseCodec implements JsonSerializer<AbstractResultResponse>, JsonDeserializer<AbstractResultResponse>
+{
+
+ public AbstractResultResponse deserialize( JsonElement element, Type typeOfT, JsonDeserializationContext context )
+ throws JsonParseException
+ {
+ JsonObject json = element.getAsJsonObject();
+
+ AbstractResultResponse response = null;
+ MessageTypeEnum type = MessageTypeEnum.valueOf( json.get( "type" ).getAsString() );
+
+ switch( type )
+ {
+ case BIND_RESPONSE: response = new BindResponseImpl();
+ break;
+
+ case ADD_RESPONSE: response = new AddResponseImpl();
+ break;
+
+ case COMPARE_RESPONSE: response = new CompareResponseImpl();
+ break;
+
+ case DEL_RESPONSE: response = new DeleteResponseImpl();
+ break;
+
+ case MODIFY_RESPONSE: response = new ModifyResponseImpl();
+ break;
+
+ case MODIFYDN_RESPONSE: response = new ModifyDnResponseImpl();
+ break;
+
+ default: new IllegalArgumentException( "message response type " + type + " is not yet supported" );
+ }
+
+ JsonElement messageId = json.get( "messageId" );
+ if( messageId != null )
+ {
+ response.setMessageId( messageId.getAsInt() );
+ }
+
+ LdapResult parsedResult = JsonBuilder.fromJson( json.get( AppConstants.LDAP_RESULT_KEY ), LdapResultImpl.class );
+
+ LdapResult respResult = response.getLdapResult();
+ respResult.setErrorMessage( parsedResult.getErrorMessage() );
+ respResult.setMatchedDn( parsedResult.getMatchedDn() );
+ respResult.setReferral( parsedResult.getReferral() );
+ respResult.setResultCode( parsedResult.getResultCode() );
+
+ return response;
+ }
+
+ public JsonElement serialize( AbstractResultResponse src, Type typeOfSrc, JsonSerializationContext context )
+ {
+ JsonObject json = new JsonObject();
+
+ json.addProperty( "messageId", src.getMessageId() );
+ json.addProperty( "type", src.getType().name() );
+ json.add( AppConstants.LDAP_RESULT_KEY, JsonBuilder.toJsonTree( src.getLdapResult() ) );
+
+ return json;
+ }
+
+}
Added: directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/DnCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/DnCodec.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/DnCodec.java (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/DnCodec.java Sun Sep 5 17:13:58 2010
@@ -0,0 +1,63 @@
+/*
+ * 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.codec.json;
+
+import java.lang.reflect.Type;
+
+import org.apache.directory.shared.ldap.exception.LdapException;
+import org.apache.directory.shared.ldap.name.DN;
+
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonPrimitive;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
+/**
+ * TODO DnEncoder.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DnCodec implements JsonSerializer<DN>, JsonDeserializer<DN>
+{
+
+ public JsonElement serialize( DN src, Type typeOfSrc, JsonSerializationContext context )
+ {
+ return new JsonPrimitive( src.getName() );
+ }
+
+ public DN deserialize( JsonElement json, Type typeOfT, JsonDeserializationContext context )
+ throws JsonParseException
+ {
+ try
+ {
+ return new DN( json.getAsString() );
+ }
+ catch( LdapException e )
+ {
+ throw new JsonParseException( e );
+ }
+ }
+
+}
Added: directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/JsonBuilder.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/JsonBuilder.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/JsonBuilder.java (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/JsonBuilder.java Sun Sep 5 17:13:58 2010
@@ -0,0 +1,163 @@
+/*
+ * 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.codec.json;
+
+
+import java.lang.reflect.Type;
+
+import org.apache.directory.server.codec.json.operations.add.AddRequestCodec;
+import org.apache.directory.server.codec.json.operations.bind.BindRequestCodec;
+import org.apache.directory.server.codec.json.operations.bind.BindResponseCodec;
+import org.apache.directory.server.codec.json.operations.compare.CompareRequestCodec;
+import org.apache.directory.server.codec.json.operations.delete.DeleteRequestCodec;
+import org.apache.directory.server.codec.json.operations.modify.DefaultModificationCodec;
+import org.apache.directory.server.codec.json.operations.modify.ModifyRequestCodec;
+import org.apache.directory.server.codec.json.operations.modifydn.ModifyDnRequestCodec;
+import org.apache.directory.server.codec.json.operations.search.ClonedServerEntryCodec;
+import org.apache.directory.server.codec.json.operations.search.DefaultEntryCodec;
+import org.apache.directory.server.codec.json.operations.search.EntryAttributeCodec;
+import org.apache.directory.server.codec.json.operations.search.SearchRequestCodec;
+import org.apache.directory.server.core.entry.ClonedServerEntry;
+import org.apache.directory.server.core.entry.ClonedServerEntrySearch;
+import org.apache.directory.shared.ldap.entry.AbstractValue;
+import org.apache.directory.shared.ldap.entry.BinaryValue;
+import org.apache.directory.shared.ldap.entry.DefaultEntry;
+import org.apache.directory.shared.ldap.entry.DefaultEntryAttribute;
+import org.apache.directory.shared.ldap.entry.DefaultModification;
+import org.apache.directory.shared.ldap.entry.StringValue;
+import org.apache.directory.shared.ldap.message.AbstractResultResponse;
+import org.apache.directory.shared.ldap.message.AddRequestImpl;
+import org.apache.directory.shared.ldap.message.BindRequestImpl;
+import org.apache.directory.shared.ldap.message.BindResponseImpl;
+import org.apache.directory.shared.ldap.message.CompareRequestImpl;
+import org.apache.directory.shared.ldap.message.DeleteRequestImpl;
+import org.apache.directory.shared.ldap.message.LdapResultImpl;
+import org.apache.directory.shared.ldap.message.ModifyDnRequestImpl;
+import org.apache.directory.shared.ldap.message.ModifyRequestImpl;
+import org.apache.directory.shared.ldap.message.SearchRequestImpl;
+import org.apache.directory.shared.ldap.name.DN;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParseException;
+
+
+/**
+ * TODO JsonBuilder.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class JsonBuilder
+{
+
+ private static final GsonBuilder BUILDER = new GsonBuilder();
+ private static Gson gson;
+
+ private static SchemaManager schemaManager;
+
+ static
+ {
+ BUILDER.registerTypeAdapter( BindResponseImpl.class, new BindResponseCodec() );
+ BUILDER.registerTypeAdapter( BindRequestImpl.class, new BindRequestCodec() );
+
+ BUILDER.registerTypeAdapter( AddRequestImpl.class, new AddRequestCodec() );
+ BUILDER.registerTypeAdapter( DeleteRequestImpl.class, new DeleteRequestCodec() );
+ BUILDER.registerTypeAdapter( SearchRequestImpl.class, new SearchRequestCodec() );
+ BUILDER.registerTypeAdapter( ModifyRequestImpl.class, new ModifyRequestCodec() );
+ BUILDER.registerTypeAdapter( ModifyDnRequestImpl.class, new ModifyDnRequestCodec() );
+ BUILDER.registerTypeAdapter( CompareRequestImpl.class, new CompareRequestCodec() );
+
+ BUILDER.registerTypeAdapter( LdapResultImpl.class, new LdapResultCodec() );
+ BUILDER.registerTypeAdapter( DN.class, new DnCodec() );
+ BUILDER.registerTypeAdapter( DefaultEntryAttribute.class, new EntryAttributeCodec() );
+ BUILDER.registerTypeAdapter( DefaultEntry.class, new DefaultEntryCodec() );
+ BUILDER.registerTypeAdapter( ClonedServerEntry.class, new ClonedServerEntryCodec() );
+ BUILDER.registerTypeAdapter( ClonedServerEntrySearch.class, new ClonedServerEntryCodec() );
+ BUILDER.registerTypeAdapter( DefaultModification.class, new DefaultModificationCodec() );
+ BUILDER.registerTypeAdapter( AbstractResultResponse.class, new AbstractResultResponseCodec() );
+ BUILDER.registerTypeAdapter( StringValue.class, new ValueCodec() );
+ BUILDER.registerTypeAdapter( BinaryValue.class, new ValueCodec() );
+ BUILDER.registerTypeAdapter( AbstractValue.class, new ValueCodec() );
+
+ gson = BUILDER.create();
+ }
+
+
+ public static <T> T fromJson( String json, Class<T> classOfT ) throws JsonParseException
+ {
+ return gson.fromJson( json, classOfT );
+ }
+
+
+ public static <T> T fromJson( JsonElement json, Class<T> classOfT ) throws JsonParseException
+ {
+ return gson.fromJson( json, classOfT );
+ }
+
+
+ public static JsonElement toJsonTree( Object src )
+ {
+ return gson.toJsonTree( src );
+ }
+
+
+ public static String toJson( Object src, Type typeOfSrc )
+ {
+ return gson.toJson( src, typeOfSrc );
+ }
+
+
+ public static String toJson( Object src )
+ {
+ return gson.toJson( src );
+ }
+
+ public static DN decodeDn( String jsonDn )
+ {
+ return gson.fromJson( jsonDn, DN.class );
+ }
+
+ public static DN decodeDn( JsonElement jsonDn )
+ {
+ return gson.fromJson( jsonDn, DN.class );
+ }
+
+
+ public static Gson get()
+ {
+ return gson;
+ }
+
+
+ public static SchemaManager getSchemaManager()
+ {
+ return schemaManager;
+ }
+
+
+ public static void setSchemaManager( SchemaManager schemaManager )
+ {
+ JsonBuilder.schemaManager = schemaManager;
+ }
+
+}
Added: directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/JsonEncoder.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/JsonEncoder.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/JsonEncoder.java (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/JsonEncoder.java Sun Sep 5 17:13:58 2010
@@ -0,0 +1,53 @@
+/*
+ * 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.codec.json;
+
+
+import org.apache.directory.shared.ldap.message.BindResponseImpl;
+import org.apache.directory.shared.ldap.message.LdapResultImpl;
+
+
+/**
+ * TODO JsonEncoder.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class JsonEncoder
+{
+
+// public BindRequest decode( String json )
+// {
+//
+// }
+
+
+ public String encode( BindResponseImpl addResp )
+ {
+ return JsonBuilder.get().toJson( addResp );
+ }
+
+
+ public String encode( LdapResultImpl result )
+ {
+ return JsonBuilder.get().toJson( result );
+ }
+
+}