directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1503246 - in /directory/escimo/trunk: common/src/main/java/org/apache/directory/scim/ ldap/ ldap/src/main/java/org/apache/directory/scim/ldap/
Date Mon, 15 Jul 2013 13:54:20 GMT
Author: kayyagari
Date: Mon Jul 15 13:54:19 2013
New Revision: 1503246

URL: http://svn.apache.org/r1503246
Log:
mapping SCIM schema to LDAP schema (work in progress)

Added:
    directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ProviderService.java
    directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/SchemaMapper.java
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapSchemaMapper.java
Modified:
    directory/escimo/trunk/ldap/pom.xml

Added: directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ProviderService.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ProviderService.java?rev=1503246&view=auto
==============================================================================
--- directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ProviderService.java
(added)
+++ directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ProviderService.java
Mon Jul 15 13:54:19 2013
@@ -0,0 +1,28 @@
+/*
+ * 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.scim;
+
+/**
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface ProviderService 
+{
+
+}

Added: directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/SchemaMapper.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/SchemaMapper.java?rev=1503246&view=auto
==============================================================================
--- directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/SchemaMapper.java
(added)
+++ directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/SchemaMapper.java
Mon Jul 15 13:54:19 2013
@@ -0,0 +1,32 @@
+/*
+ *   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.scim;
+
+/**
+ * Interface for mapping schema of SCIM to that of the user data store (e.x. LDAP, RDBMS).
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface SchemaMapper
+{
+    //UserSchema getUserSchema();
+    
+    //GroupSchema getGroupSchema();
+}

Modified: directory/escimo/trunk/ldap/pom.xml
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/pom.xml?rev=1503246&r1=1503245&r2=1503246&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/pom.xml (original)
+++ directory/escimo/trunk/ldap/pom.xml Mon Jul 15 13:54:19 2013
@@ -13,6 +13,7 @@
   
   <properties>
     <ldap.api.version>1.0.0-M19</ldap.api.version>
+    <dom4j.version>1.6.1</dom4j.version>
   </properties>
   
   <dependencies>
@@ -34,6 +35,11 @@
       <artifactId>api-ldap-codec-standalone</artifactId>
       <version>${ldap.api.version}</version>
     </dependency>
-
+    
+    <dependency>
+      <groupId>dom4j</groupId>
+      <artifactId>dom4j</artifactId>
+      <version>${dom4j.version}</version>
+    </dependency>
   </dependencies>
 </project>

Added: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapSchemaMapper.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapSchemaMapper.java?rev=1503246&view=auto
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapSchemaMapper.java
(added)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapSchemaMapper.java
Mon Jul 15 13:54:19 2013
@@ -0,0 +1,127 @@
+/*
+ *   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.scim.ldap;
+
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.apache.directory.api.ldap.model.exception.LdapException;
+import org.apache.directory.api.ldap.model.schema.SchemaManager;
+import org.apache.directory.ldap.client.api.LdapConnection;
+import org.apache.directory.scim.SchemaMapper;
+import org.apache.directory.scim.common.User;
+import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * TODO LdapSchemaMapper.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class LdapSchemaMapper implements SchemaMapper
+{
+    private SchemaManager ldapSchema;
+
+    private static final Logger LOG = LoggerFactory.getLogger( LdapSchemaMapper.class );
+
+
+    public LdapSchemaMapper( LdapConnection connection )
+    {
+        try
+        {
+            connection.loadSchema();
+        }
+        catch ( LdapException e )
+        {
+            LOG.debug( "Failed to load schema from the server", e );
+            LOG.info( "Could not load schema from the LDAP server, disabling schema checks"
);
+        }
+
+        ldapSchema = connection.getSchemaManager();
+    }
+
+
+    public void loadMappings()
+    {
+        InputStream in = this.getClass().getResourceAsStream( "escimo-ldap-mapping.xml" );
+        loadMappings( in );
+    }
+
+
+    public void loadMappings( InputStream in )
+    {
+        if ( in == null )
+        {
+            throw new IllegalArgumentException( "Mapping file inputstream cannot be null"
);
+        }
+
+        BufferedReader r = new BufferedReader( new InputStreamReader( in ) );
+
+        try
+        {
+            StringBuilder sb = new StringBuilder();
+            String s = null;
+            
+            while ( ( s = r.readLine() ) != null )
+            {
+                sb.append( s )
+                  .append( "\n" );
+            }
+            
+            Document doc = DocumentHelper.parseText( sb.toString() );
+            
+            // the entities element
+            Element root = doc.getRootElement();
+            if ( root.elements().isEmpty() )
+            {
+               throw new IllegalStateException( "Invalid schema mapping file" ); 
+            }
+            
+            Element elmUser = root.element( "user" );
+        }
+        catch ( Exception e )
+        {
+            LOG.warn( "Failed to load the schema mappings", e );
+            throw new RuntimeException( e );
+        }
+        finally
+        {
+            if( r != null )
+            {
+                try
+                {
+                    r.close();
+                }
+                catch( IOException e )
+                {
+                    LOG.warn( "Failed to close the inputstream of the schema mapping file",
e );
+                }
+            }
+        }
+    }
+
+}



Mime
View raw message