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 2014/12/28 02:53:26 UTC
svn commit: r1648141 [2/2] - in /directory/escimo/trunk:
common/src/main/java/org/apache/directory/scim/
common/src/main/java/org/apache/directory/scim/schema/
json2java/src/main/java/org/apache/directory/scim/
json2java/src/main/resources/ ldap/src/ma...
Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/GroupsAttributeHandler.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/GroupsAttributeHandler.java?rev=1648141&r1=1648140&r2=1648141&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/GroupsAttributeHandler.java (original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/GroupsAttributeHandler.java Sun Dec 28 01:53:26 2014
@@ -62,7 +62,10 @@ import org.slf4j.LoggerFactory;
*/
public class GroupsAttributeHandler extends LdapAttributeHandler
{
-
+ private String baseDn;
+
+ private String filter;
+
private static final Logger LOG = LoggerFactory.getLogger( GroupsAttributeHandler.class );
@@ -102,7 +105,7 @@ public class GroupsAttributeHandler exte
// query members based on the filter and base DN
{
MultiValType mvt = ( MultiValType ) bt;
- members = getMemberEntriesUsingFilter( mvt.getFilter(), mvt.getBaseDn(), userEntry, ctx );
+ members = getMemberEntriesUsingFilter( filter, baseDn, userEntry, ctx );
}
if ( ( members != null ) && ( !members.isEmpty() ) )
@@ -296,6 +299,28 @@ public class GroupsAttributeHandler exte
return null;
}
+ }
+ public String getBaseDn()
+ {
+ return baseDn;
+ }
+
+
+ public void setBaseDn( String baseDn )
+ {
+ this.baseDn = baseDn;
+ }
+
+
+ public String getFilter()
+ {
+ return filter;
+ }
+
+
+ public void setFilter( String filter )
+ {
+ this.filter = filter;
}
}
Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/MembersAttributeHandler.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/MembersAttributeHandler.java?rev=1648141&r1=1648140&r2=1648141&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/MembersAttributeHandler.java (original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/MembersAttributeHandler.java Sun Dec 28 01:53:26 2014
@@ -246,12 +246,7 @@ public class MembersAttributeHandler ext
String resId = jo.get( "value" ).getAsString();
String resRef = jo.get( "$ref" ).getAsString();
- ResourceSchema resSchema = provider.getUserSchema();
-
- if( resRef.endsWith( "/Groups/" + resId ) )
- {
- resSchema = provider.getGroupSchema();
- }
+ ResourceSchema resSchema = provider.getResourceSchema( ctx );
Entry resEntry = provider.fetchEntryById( resId, resSchema, ctx );
Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/MetaAttributeHandler.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/MetaAttributeHandler.java?rev=1648141&r1=1648140&r2=1648141&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/MetaAttributeHandler.java (original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/MetaAttributeHandler.java Sun Dec 28 01:53:26 2014
@@ -27,10 +27,11 @@ import org.apache.directory.api.ldap.mod
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.scim.ComplexAttribute;
-import org.apache.directory.scim.GroupResource;
import org.apache.directory.scim.RequestContext;
import org.apache.directory.scim.ServerResource;
import org.apache.directory.scim.SimpleAttribute;
+import org.apache.directory.scim.ldap.LdapResourceProvider;
+import org.apache.directory.scim.ldap.schema.ResourceSchema;
import org.apache.directory.scim.schema.BaseType;
import org.apache.directory.scim.util.ResourceUtil;
import org.slf4j.Logger;
@@ -85,19 +86,22 @@ public class MetaAttributeHandler extend
ServerResource resource = ctx.getCoreResource();
- String resourceType = "User";
+ LdapResourceProvider provider = ( LdapResourceProvider ) ctx.getProviderService();
+ ResourceSchema schema = provider.getResourceSchema( ctx );
- if( resource instanceof GroupResource )
+ String resourceUri = schema.getReqUri();
+
+ if( !resourceUri.endsWith( "/" ) )
{
- resourceType = "Group";
+ resourceUri += "/";
}
- SimpleAttribute resourceTypeAt = new SimpleAttribute( "resourceType", resourceType );
+ SimpleAttribute resourceTypeAt = new SimpleAttribute( "resourceType", resourceUri );
atList.add( resourceTypeAt );
SimpleAttribute location = new SimpleAttribute( "location" );
String locationVal = ctx.getUriInfo().getBaseUri().toString();
- locationVal = locationVal + resourceType + "s/" + resource.getId();
+ locationVal = locationVal + resourceUri + resource.getId();
location.setValue( locationVal );
atList.add( location );
Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/MultiValType.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/MultiValType.java?rev=1648141&r1=1648140&r2=1648141&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/MultiValType.java (original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/MultiValType.java Sun Dec 28 01:53:26 2014
@@ -32,16 +32,10 @@ public class MultiValType extends BaseTy
{
private SimpleTypeGroup atGroup;
- private String baseDn;
-
- private String filter;
-
- public MultiValType( String uri, String name, boolean show, SimpleTypeGroup atGroup, String baseDn, String filter )
+ public MultiValType( String uri, String name, boolean show, SimpleTypeGroup atGroup )
{
super( uri, name, show );
this.atGroup = atGroup;
- this.baseDn = baseDn;
- this.filter = filter;
}
@@ -54,24 +48,6 @@ public class MultiValType extends BaseTy
}
- /**
- * @return the baseDn
- */
- public String getBaseDn()
- {
- return baseDn;
- }
-
-
- /**
- * @return the filter
- */
- public String getFilter()
- {
- return filter;
- }
-
-
@Override
public boolean isComplex()
{
Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ResourceSchema.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ResourceSchema.java?rev=1648141&r1=1648140&r2=1648141&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ResourceSchema.java (original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ResourceSchema.java Sun Dec 28 01:53:26 2014
@@ -23,13 +23,11 @@ package org.apache.directory.scim.ldap.s
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.directory.api.util.Strings;
-import org.apache.directory.scim.AttributeHandler;
import org.apache.directory.scim.schema.BaseType;
@@ -39,18 +37,22 @@ import org.apache.directory.scim.schema.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public abstract class ResourceSchema
+public class ResourceSchema
{
private String baseDn;
private String filter;
- private List<String> uris = new ArrayList<String>();
+ private SimpleType rdnType;
+
+ private String reqUri;
+
+ private String name;
+
+ private List<String> schemaIds = new ArrayList<String>();
private Map<String, BaseType> coreTypes = new LinkedHashMap<String, BaseType>();
private Map<String, BaseType> extendedTypes = new LinkedHashMap<String, BaseType>();
- private Map<String, AttributeHandler> atHandlers = new HashMap<String, AttributeHandler>();
-
private List<String> objectClasses = new ArrayList<String>();
@@ -80,28 +82,27 @@ public abstract class ResourceSchema
public BaseType getAttribute( String name )
{
- if( name == null )
+ if ( name == null )
{
return null;
}
-
+
name = name.trim();
-
+
int colonPos = name.lastIndexOf( ":" );
- if( colonPos > 0 )
+ if ( colonPos > 0 )
{
name = name.substring( colonPos + 1 );
}
- if( name.contains( "." ) )
+ if ( name.contains( "." ) )
{
String[] atPath = name.split( "\\." );
-
+
BaseType b = _findAtType( atPath[0] );
-
-
+
SimpleTypeGroup stg = null;
-
+
if ( b instanceof ComplexType )
{
ComplexType c = ( ComplexType ) b;
@@ -112,23 +113,23 @@ public abstract class ResourceSchema
MultiValType m = ( MultiValType ) b;
stg = m.getAtGroup();
}
-
- if( stg != null )
+
+ if ( stg != null )
{
return stg.getType( atPath[1] );
}
-
+
return null;
}
return _findAtType( name );
}
-
+
private BaseType _findAtType( String name )
{
BaseType bt = coreTypes.get( name );
-
+
if ( bt == null )
{
bt = extendedTypes.get( name );
@@ -137,6 +138,7 @@ public abstract class ResourceSchema
return bt;
}
+
public void addAttributeType( String name, BaseType type )
{
if ( type != null )
@@ -153,18 +155,6 @@ public abstract class ResourceSchema
}
- public void addAttributeHandler( String name, AttributeHandler handler )
- {
- atHandlers.put( name, handler );
- }
-
-
- public AttributeHandler getHandler( String name )
- {
- return atHandlers.get( name );
- }
-
-
public Collection<BaseType> getCoreTypes()
{
return Collections.unmodifiableCollection( coreTypes.values() );
@@ -179,13 +169,7 @@ public abstract class ResourceSchema
public void addUri( String uri )
{
- uris.add( uri );
- }
-
-
- public void setAtHandlers( Map<String, AttributeHandler> atHandlers )
- {
- this.atHandlers = atHandlers;
+ schemaIds.add( uri );
}
@@ -222,8 +206,44 @@ public abstract class ResourceSchema
}
- public List<String> getUris()
+ public SimpleType getRdnType()
+ {
+ return rdnType;
+ }
+
+
+ public void setRdnType( SimpleType rdnType )
+ {
+ this.rdnType = rdnType;
+ }
+
+
+ public String getReqUri()
+ {
+ return reqUri;
+ }
+
+
+ public String getName()
+ {
+ return name;
+ }
+
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+
+ public void setReqUri( String reqUri )
+ {
+ this.reqUri = reqUri;
+ }
+
+
+ public List<String> getSchemaIds()
{
- return new ArrayList<String>( uris );
+ return new ArrayList<String>( schemaIds );
}
}
Modified: directory/escimo/trunk/ldap/src/main/resources/escimo-ldap-mapping.xml
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/resources/escimo-ldap-mapping.xml?rev=1648141&r1=1648140&r2=1648141&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/resources/escimo-ldap-mapping.xml (original)
+++ directory/escimo/trunk/ldap/src/main/resources/escimo-ldap-mapping.xml Sun Dec 28 01:53:26 2014
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
-<entities>
+<ldap-mapping>
<!-- Core User resource schema -->
- <schema id="user-core" uri="urn:scim:schemas:core:2.0:User">
+ <schema id="user-core" uri="urn:ietf:params:scim:schemas:core:2.0:User">
<attribute name="id" mappedTo="entryUUID" />
<attribute name="userName" mappedTo="uid" />
<attribute name="displayName" mappedTo="displayName" />
@@ -57,8 +57,10 @@
</at-group>
</multival-attribute>
- <multival-attribute name="groups" baseDn="ou=system"
- filter="(member=$entryDn)" handlerRef="groupsHandler" />
+ <multival-attribute name="groups" handlerRef="groupsHandler">
+ <handlerArg name="baseDn" value="ou=system"/>
+ <handlerArg name="filter" value="(member=$entryDn)"/>
+ </multival-attribute>
<multival-attribute name="entitlements" />
@@ -75,7 +77,7 @@
</schema>
<!-- Enterprise User resource schema -->
- <schema id="enterprise-user" uri="urn:scim:schemas:extension:enterprise:2.0:User">
+ <schema id="enterprise-user" uri="urn:ietf:params:scim:schemas:extension:enterprise:2.0:User">
<attribute name="employeeNumber" mappedTo="" />
<attribute name="costCenter" mappedTo="" />
<attribute name="organization" mappedTo="" />
@@ -91,28 +93,31 @@
</complex-attribute>
</schema>
- <schema id="group" uri="urn:scim:schemas:core:2.0:Group">
- <!-- the 'displayName' MUST be mapped to the RDN attribute otherwise creation of new groups fails -->
+ <schema id="group" uri="urn:ietf:params:scim:schemas:core:2.0:Group">
<attribute name="displayName" mappedTo="cn" />
<attribute name="id" mappedTo="entryUUID" />
<multival-attribute name="members" handlerRef="membersHandler"/>
<complex-attribute name="meta" handlerRef="metaHandler" />
</schema>
- <userType baseDn="ou=system" filter="(objectClass=inetOrgPerson)">
+ <resourceType name="User" baseDn="ou=system" filter="(objectClass=inetOrgPerson)">
<schemaRef id="user-core" />
<schemaRef id="enterprise-user" />
+ <rdnAtRef name="userName"/>
+ <reqUri value="/Users"/>
<objectClasses>
<objectClass>inetOrgPerson</objectClass>
</objectClasses>
- </userType>
+ </resourceType>
- <groupType baseDn="ou=system" filter="(objectClass=groupOfNames)">
+ <resourceType name="Group" baseDn="ou=system" filter="(objectClass=groupOfNames)">
<schemaRef id="group" />
+ <rdnAtRef name="displayName"/>
+ <reqUri value="/Groups"/>
<objectClasses>
<objectClass>groupOfNames</objectClass>
</objectClasses>
- </groupType>
+ </resourceType>
<atHandlers>
<handler name="activeHandler"
@@ -126,4 +131,4 @@
<handler name="membersHandler"
class="org.apache.directory.scim.ldap.handlers.MembersAttributeHandler" />
</atHandlers>
-</entities>
\ No newline at end of file
+</ldap-mapping>
\ No newline at end of file
Modified: directory/escimo/trunk/schema/src/main/java/org/apache/directory/scim/schema/JsonSchema.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/schema/src/main/java/org/apache/directory/scim/schema/JsonSchema.java?rev=1648141&r1=1648140&r2=1648141&view=diff
==============================================================================
--- directory/escimo/trunk/schema/src/main/java/org/apache/directory/scim/schema/JsonSchema.java (original)
+++ directory/escimo/trunk/schema/src/main/java/org/apache/directory/scim/schema/JsonSchema.java Sun Dec 28 01:53:26 2014
@@ -47,6 +47,10 @@ public class JsonSchema
private String desc;
+ private boolean core;
+
+ private static String CORE_SCHEMA_ID_PREFIX = "urn:ietf:params:scim:schemas:core:2.0";
+
private Map<String, JsonObject> attributes;
@@ -75,6 +79,8 @@ public class JsonSchema
this.name = obj.get( "name" ).getAsString();
this.desc = obj.get( "description" ).getAsString();
+ core = id.startsWith( CORE_SCHEMA_ID_PREFIX );
+
_readAttributeDef( obj );
}
@@ -106,8 +112,8 @@ public class JsonSchema
name = parentName + "." + name;
}
- attributes.put( name, attribute );
-
+ attributes.put( name.toLowerCase(), attribute );
+
if ( type.equals( "complex" ) )
{
_readAttributeDef( attribute );
@@ -115,6 +121,7 @@ public class JsonSchema
}
}
+
/**
* gives the schema definition of an attribute with the given name.
* JSON dot notation is also supported in the attribute's name.
@@ -128,8 +135,8 @@ public class JsonSchema
{
return attributes.get( name );
}
-
-
+
+
/**
* tells if an attribute with the given name is read-only.
*
@@ -144,29 +151,30 @@ public class JsonSchema
*/
public boolean isReadOnly( String name )
{
- JsonObject jo = getAttributeDef( name );
-
- if( jo == null )
+ JsonObject jo = getAttributeDef( name.toLowerCase() );
+
+ if ( jo == null )
{
- if( name.equals( "meta" ) )
+ if ( name.equals( "meta" ) ||
+ name.equals( "id" ) )
{
return true;
}
-
+
throw new IllegalArgumentException( "Unknown attribute name " + name );
}
-
+
JsonElement je = jo.get( "readOnly" );
-
- if( je != null )
+
+ if ( je != null )
{
return je.getAsBoolean();
}
-
+
return false;
}
-
-
+
+
/**
* @return the rawJson
*/
@@ -203,6 +211,12 @@ public class JsonSchema
}
+ public boolean isCore()
+ {
+ return core;
+ }
+
+
@Override
public String toString()
{
@@ -214,7 +228,7 @@ public class JsonSchema
{
URL url = SchemaUtil.getDefaultSchemas().get( 0 );
JsonSchema json = SchemaUtil.getSchemaJson( url );
- System.out.println(json);
+ System.out.println( json );
}
}
Modified: directory/escimo/trunk/schema/src/main/resources/serviceproviderconfig-schema.json
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/schema/src/main/resources/serviceproviderconfig-schema.json?rev=1648141&r1=1648140&r2=1648141&view=diff
==============================================================================
--- directory/escimo/trunk/schema/src/main/resources/serviceproviderconfig-schema.json (original)
+++ directory/escimo/trunk/schema/src/main/resources/serviceproviderconfig-schema.json Sun Dec 28 01:53:26 2014
@@ -1,210 +1,53 @@
{
- "id": "urn:scim:schemas:core:2.0:ServiceProviderConfig",
- "name": "ServiceProviderConfig",
- "description": "ServiceProvider Config",
- "attributes":[
- {
- "name":"documentationUrl",
- "type":"string",
- "multiValued":false,
- "description":"An HTTP addressable URL pointing to the Service Provider's human consumable help documentation.",
- "readOnly":true,
- "required":false,
- "caseExact":false
- },
- {
- "name":"patch",
- "type":"complex",
- "multiValued":false,
- "description":"A complex type that specifies PATCH configuration options. REQUIRED.",
- "readOnly":true,
- "required":true,
- "caseExact":false,
- "subAttributes":[
- {
- "name":"supported",
- "type":"boolean",
- "multiValued":false,
- "description":"Boolean value specifying whether the operation is supported. REQUIRED." ,
- "readOnly":true,
- "required":true,
- "caseExact":false
- }
- ]
- },
- {
- "name":"bulk",
- "type":"complex",
- "multiValued":false,
- "description":"A complex type that specifies BULK configuration options. REQUIRED.",
- "readOnly":true,
- "required":true,
- "caseExact":false,
- "subAttributes":[
- {
- "name":"supported",
- "type":"boolean",
- "multiValued":false,
- "description":"Boolean value specifying whether the operation is supported. REQUIRED." ,
- "readOnly":true,
- "required":true,
- "caseExact":false
- },
- {
- "name":"maxOperations",
- "type":"integer",
- "multiValued":false,
- "description":"An integer value specifying the maximum number of operations. REQUIRED." ,
- "readOnly":true,
- "required":true,
- "caseExact":false
- },
- {
- "name":"maxPayloadSize",
- "type":"integer",
- "multiValued":false,
- "description":"An integer value specifying the maximum payload size in bytes. REQUIRED." ,
- "readOnly":true,
- "required":true,
- "caseExact":false
- }
- ]
- },
- {
- "name":"filter",
- "type":"complex",
- "multiValued":false,
- "description":"A complex type that specifies FILTER options. REQUIRED.",
- "readOnly":true,
- "required":true,
- "caseExact":false,
- "subAttributes":[
- {
- "name":"supported",
- "type":"boolean",
- "multiValued":false,
- "description":"Boolean value specifying whether the operation is supported. REQUIRED." ,
- "readOnly":true,
- "required":true,
- "caseExact":false
- },
- {
- "name":"maxResults",
- "type":"integer",
- "multiValued":false,
- "description":"Integer value specifying the maximum number of Resources returned in a response. REQUIRED." ,
- "readOnly":true,
- "required":true,
- "caseExact":false
- }
- ]
- },
- {
- "name":"changePassword",
- "type":"complex",
- "multiValued":false,
- "description":"A complex type that specifies Change Password configuration options. REQUIRED.",
- "readOnly":true,
- "required":true,
- "caseExact":false,
- "subAttributes":[
- {
- "name":"supported",
- "type":"boolean",
- "multiValued":false,
- "description":"Boolean value specifying whether the operation is supported. REQUIRED." ,
- "readOnly":true,
- "required":true,
- "caseExact":false
- }
- ]
- },
- {
- "name":"sort",
- "type":"complex",
- "multiValued":false,
- "description":"A complex type that specifies Sort configuration options. REQUIRED.",
- "readOnly":true,
- "required":true,
- "caseExact":false,
- "subAttributes":[
- {
- "name":"supported",
- "type":"boolean",
- "multiValued":false,
- "description":"Boolean value specifying whether the operation is supported. REQUIRED." ,
- "readOnly":true,
- "required":true,
- "caseExact":false
- }
- ]
- },
- {
- "name":"etag",
- "type":"complex",
- "multiValued":false,
- "description":"A complex type that specifies Etag configuration options. REQUIRED.",
- "readOnly":true,
- "required":true,
- "caseExact":false,
- "subAttributes":[
- {
- "name":"supported",
- "type":"boolean",
- "multiValued":false,
- "description":"Boolean value specifying whether the operation is supported. REQUIRED." ,
- "readOnly":true,
- "required":true,
- "caseExact":false
- }
- ]
- },
- {
- "name":"authenticationSchemes",
- "type":"complex",
- "multiValued":true,
- "description":"A complex type that specifies supported Authentication Scheme properties. Instead of the standard Canonical Values for type, this attribute defines the following Canonical Values to represent common schemes: oauth, oauth2, oauthbearertoken, httpbasic, and httpdigest. To enable seamless discovery of configuration, the Service Provider SHOULD, with the appropriate security considerations, make the authenticationSchemes attribute publicly accessible without prior authentication. REQUIRED.",
- "readOnly":false,
- "required":true,
- "caseExact":false,
- "subAttributes":[
- {
- "name":"name",
- "type":"string",
- "multiValued":false,
- "description":"The common authentication scheme name; e.g., HTTP Basic. REQUIRED.",
- "readOnly":false,
- "required":true,
- "caseExact":false
- },
- {
- "name":"description",
- "type":"string",
- "multiValued":false,
- "description":"A description of the Authentication Scheme. REQUIRED.",
- "readOnly":false,
- "required":true,
- "caseExact":false
- },
- {
- "name":"specUrl",
- "type":"string",
- "multiValued":false,
- "description":"A HTTP addressable URL pointing to the Authentication Scheme's specification. REQUIRED.",
- "readOnly":false,
- "required":true,
- "caseExact":false
- },
- {
- "name":"documentationUrl",
- "type":"string",
- "multiValued":false,
- "description":"A HTTP addressable URL pointing to the Authentication Scheme's usage documentation. REQUIRED.",
- "readOnly":false,
- "required":true,
- "caseExact":false
- }
- ]
- }
- ]
-}
\ No newline at end of file
+ "schemas": [
+ "urn:ietf:params:scim:schemas:core:2.0:ServiceProviderConfig"
+ ],
+ "documentationUrl":"http://example.com/help/scim.html",
+ "patch": {
+ "supported":true
+ },
+ "bulk": {
+ "supported":true,
+ "maxOperations":1000,
+ "maxPayloadSize":1048576
+ },"filter": {
+ "supported":true,
+ "maxResults": 200
+ },
+ "changePassword" : {
+ "supported":true
+ },
+ "sort": {
+ "supported":true
+ },
+ "etag": {
+ "supported":true
+ },
+ "authenticationSchemes": [
+ {
+ "name": "OAuth Bearer Token",
+ "description":
+ "Authentication Scheme using the OAuth Bearer Token Standard",
+ "specUrl":
+ "http://tools.ietf.org/html/draft-ietf-oauth-v2-bearer-01",
+ "documentationUrl":"http://example.com/help/oauth.html",
+ "type":"oauthbearertoken",
+ "primary": true
+ },
+ {
+ "name": "HTTP Basic",
+ "description":
+ "Authentication Scheme using the Http Basic Standard",
+ "specUrl":"http://www.ietf.org/rfc/rfc2617.txt",
+ "documentationUrl":"http://example.com/help/httpBasic.html",
+ "type":"httpbasic"
+ }
+ ],
+ "meta": {
+ "location":"http://localhost:8080/v2/ServiceProviderConfig",
+ "resourceType": "ServiceProviderConfig",
+ "created": "2010-01-23T04:56:22Z",
+ "lastModified": "2011-05-13T04:42:34Z",
+ "version": "W\/\"3694e05e9dff594\""
+ }
+ }
\ No newline at end of file
Modified: directory/escimo/trunk/schema/src/main/resources/user-schema.json
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/schema/src/main/resources/user-schema.json?rev=1648141&r1=1648140&r2=1648141&view=diff
==============================================================================
--- directory/escimo/trunk/schema/src/main/resources/user-schema.json (original)
+++ directory/escimo/trunk/schema/src/main/resources/user-schema.json Sun Dec 28 01:53:26 2014
@@ -5,7 +5,6 @@
"attributes" : [
{
"name" : "userName",
- "escimoAttribute": "uid",
"type" : "string",
"multiValued" : false,
"description" : "Unique identifier for the User typically used by the user to directly authenticate to the service provider. Each User MUST include a non-empty userName value. This identifier MUST be unique across the Service Consumer's entire set of Users. REQUIRED",
@@ -36,7 +35,6 @@
},
{
"name" : "familyName",
- "escimoAttribute": "sn",
"type" : "string",
"multiValued" : false,
"description" : "The family name of the User, or Last Name in most Western languages (e.g. Jensen given the full name Ms. Barbara J Jensen, III.).",
Modified: directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/ConfigurationFilter.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/ConfigurationFilter.java?rev=1648141&r1=1648140&r2=1648141&view=diff
==============================================================================
--- directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/ConfigurationFilter.java (original)
+++ directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/ConfigurationFilter.java Sun Dec 28 01:53:26 2014
@@ -52,36 +52,6 @@ public class ConfigurationFilter impleme
public void init( FilterConfig filterConfig ) throws ServletException
{
- String configDir = filterConfig.getInitParameter( "configDir" );
-
- if( StringUtils.isBlank( configDir ) )
- {
- throw new IllegalArgumentException( "Mandatory parameter 'configDir' is missing in ConfigurationFilter declaration in web.xml" );
- }
-
- if( configDir.startsWith( "/WEB-INF" ) )
- {
- configDir = filterConfig.getServletContext().getRealPath( configDir );
- }
-
- File dir = new File( configDir );
-
- if( !dir.exists() )
- {
- boolean created = dir.mkdirs();
-
- if( !created )
- {
- throw new IllegalArgumentException( "Could not create the given config directory " + configDir );
- }
- }
-
- System.setProperty( "escimo.config.dir", dir.getAbsolutePath() );
-
- File jsonSchemaDir = new File( dir, "json-schema" );
- jsonSchemaDir.mkdir();
-
- System.setProperty( "escimo.json.schema.dir", jsonSchemaDir.getAbsolutePath() );
/*
File[] propFiles = dir.listFiles();
Modified: directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/EscimoApplication.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/EscimoApplication.java?rev=1648141&r1=1648140&r2=1648141&view=diff
==============================================================================
--- directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/EscimoApplication.java (original)
+++ directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/EscimoApplication.java Sun Dec 28 01:53:26 2014
@@ -19,28 +19,38 @@
*/
package org.apache.directory.scim.rest;
+
import java.util.HashSet;
import java.util.Set;
-import javax.ws.rs.core.Application;
+import org.apache.wink.common.WinkApplication;
+
/**
* TODO EscimoApplication.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class EscimoApplication extends Application
+public class EscimoApplication extends WinkApplication
{
private Set<Class<?>> resources = new HashSet<Class<?>>();
-
-
+
+ private static Set<Object> instances = new HashSet<Object>();
+
+
public EscimoApplication()
{
- resources.add( UserService.class );
- resources.add( GroupService.class );
- resources.add( SchemaService.class );
+ resources.add( MetaSchemaService.class );
+ }
+
+
+ @Override
+ public Set<Object> getInstances()
+ {
+ return instances;
}
-
+
+
@Override
public Set<Class<?>> getClasses()
{
Added: directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/EscimoContextListener.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/EscimoContextListener.java?rev=1648141&view=auto
==============================================================================
--- directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/EscimoContextListener.java (added)
+++ directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/EscimoContextListener.java Sun Dec 28 01:53:26 2014
@@ -0,0 +1,126 @@
+/*
+ * 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.rest;
+
+
+import java.io.File;
+import java.util.Set;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.directory.scim.ResourceProvider;
+
+
+/**
+ * TODO EscimoContextListener.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class EscimoContextListener implements ServletContextListener
+{
+ private static ResourceProvider provider;
+
+
+ public void contextInitialized( ServletContextEvent sce )
+ {
+ extractDefaultConfig( sce );
+
+ String fqcn = System.getProperty( "escimo.resource.provider",
+ "org.apache.directory.scim.ldap.LdapResourceProvider" );
+ if ( StringUtils.isBlank( fqcn ) )
+ {
+ throw new RuntimeException( "No resource provider implementation class is found" );
+ }
+
+ try
+ {
+ provider = ( ResourceProvider ) Class.forName( fqcn ).newInstance();
+ provider.init();
+
+ sce.getServletContext().setAttribute( ResourceProvider.SERVLET_CONTEXT_ATTRIBUTE_KEY, provider );
+ }
+ catch ( Exception e )
+ {
+ RuntimeException re = new RuntimeException(
+ "Unable to instantiate the resource provider implementation class " + fqcn );
+ re.initCause( e );
+ throw re;
+ }
+
+ EscimoApplication app = new EscimoApplication();
+ Set<Object> instances = app.getInstances();
+
+ // dynamic registration of resource paths
+ for ( String uri : provider.getResourceUris() )
+ {
+ ResourceService service = new ResourceService();
+ service.setPath( uri );
+ instances.add( service );
+ }
+ }
+
+
+ public void contextDestroyed( ServletContextEvent sce )
+ {
+ provider.stop();
+ }
+
+
+ private void extractDefaultConfig( ServletContextEvent sce )
+ {
+ ServletContext ctx = sce.getServletContext();
+
+ String configDir = ctx.getInitParameter( "configDir" );
+
+ if ( StringUtils.isBlank( configDir ) )
+ {
+ throw new IllegalArgumentException(
+ "Mandatory parameter 'configDir' is missing in ConfigurationFilter declaration in web.xml" );
+ }
+
+ if ( configDir.startsWith( "/WEB-INF" ) )
+ {
+ configDir = ctx.getRealPath( configDir );
+ }
+
+ File dir = new File( configDir );
+
+ if ( !dir.exists() )
+ {
+ boolean created = dir.mkdirs();
+
+ if ( !created )
+ {
+ throw new IllegalArgumentException( "Could not create the given config directory " + configDir );
+ }
+ }
+
+ System.setProperty( "escimo.config.dir", dir.getAbsolutePath() );
+
+ File jsonSchemaDir = new File( dir, "json-schema" );
+ jsonSchemaDir.mkdir();
+
+ System.setProperty( "escimo.json.schema.dir", jsonSchemaDir.getAbsolutePath() );
+ }
+}
Added: directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/MetaSchemaService.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/MetaSchemaService.java?rev=1648141&view=auto
==============================================================================
--- directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/MetaSchemaService.java (added)
+++ directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/MetaSchemaService.java Sun Dec 28 01:53:26 2014
@@ -0,0 +1,223 @@
+/*
+ * 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.rest;
+
+
+import java.util.List;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.directory.scim.ResourceProvider;
+import org.apache.directory.scim.json.ResourceSerializer;
+import org.apache.directory.scim.schema.ErrorCode;
+import org.apache.directory.scim.schema.ErrorResponse;
+import org.apache.directory.scim.schema.ErrorResponse.ScimError;
+import org.apache.directory.scim.schema.JsonSchema;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
+
+
+/**
+ * TODO MetaSchemaService.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@Path("")
+public class MetaSchemaService
+{
+
+ private static String PROVIDER_SERVICE_SCHEMA_ID = "urn:ietf:params:scim:schemas:core:2.0:ServiceProviderConfig";
+
+ @Context
+ private ServletContext servletCtx;
+
+ // variable to cache the schema object
+ private String jsonSchemas;
+
+
+ @GET
+ @Produces(
+ { MediaType.APPLICATION_JSON })
+ @Path("/Schemas")
+ public Response getJsonSchemas( @Context UriInfo uriInfo )
+ {
+ return _getJsonSchema( null, uriInfo );
+ }
+
+
+ @GET
+ @Produces(
+ { MediaType.APPLICATION_JSON })
+ @Path("/Schemas/{id}")
+ public Response getJsonSchema( @PathParam("id") String schemaId, @Context UriInfo uriInfo )
+ {
+ return _getJsonSchema( schemaId, uriInfo );
+ }
+
+
+ @GET
+ @Produces(
+ { MediaType.APPLICATION_JSON })
+ @Path("/ResourceTypes")
+ public Response getResourceTypesSchema( @Context UriInfo uriInfo )
+ {
+ return _getResourceTypeSchema( null, uriInfo );
+ }
+
+
+ @GET
+ @Produces(
+ { MediaType.APPLICATION_JSON })
+ @Path("/ResourceTypes/{resType}")
+ public Response getResourceTypeSchema( @PathParam("resType") String resType, @Context UriInfo uriInfo )
+ {
+ return _getResourceTypeSchema( resType, uriInfo );
+ }
+
+
+ @GET
+ @Produces(
+ { MediaType.APPLICATION_JSON })
+ @Path("/ServiceProviderConfig")
+ public Response getSrviceProviderSchema()
+ {
+ ResponseBuilder rb = null;
+
+ ResourceProvider provider = ( ResourceProvider ) servletCtx
+ .getAttribute( ResourceProvider.SERVLET_CONTEXT_ATTRIBUTE_KEY );
+ JsonSchema jsonSchema = provider.getJsonSchemaById( PROVIDER_SERVICE_SCHEMA_ID );
+
+ if ( jsonSchema != null )
+ {
+ rb = Response.ok( jsonSchema.getRawJson(), MediaType.APPLICATION_JSON );
+ }
+ else
+ {
+ ScimError err = new ScimError( ErrorCode.NOT_FOUND, "No schema found with the URI "
+ + PROVIDER_SERVICE_SCHEMA_ID );
+
+ ErrorResponse resp = new ErrorResponse( err );
+ String json = ResourceSerializer.serialize( resp );
+ rb = Response.status( err.getCode() ).entity( json );
+ }
+
+ return rb.build();
+ }
+
+
+ private Response _getJsonSchema( String schemaId, UriInfo uriInfo )
+ {
+ ResponseBuilder rb = null;
+
+ ResourceProvider provider = ( ResourceProvider ) servletCtx
+ .getAttribute( ResourceProvider.SERVLET_CONTEXT_ATTRIBUTE_KEY );
+
+ if ( schemaId == null )
+ {
+ List<JsonSchema> lst = provider.getJsonSchemas();
+
+ if( jsonSchemas == null )
+ {
+ JsonArray arr = new JsonArray();
+
+ JsonParser parser = new JsonParser();
+
+ for ( JsonSchema js : lst )
+ {
+ JsonElement je = parser.parse( js.getRawJson() );
+ arr.add( je );
+ }
+
+ jsonSchemas = arr.toString();
+ }
+
+ rb = Response.ok( jsonSchemas, MediaType.APPLICATION_JSON );
+ }
+ else
+ {
+ JsonSchema jsonSchema = provider.getJsonSchemaById( schemaId );
+
+ if ( jsonSchema != null )
+ {
+ rb = Response.ok( jsonSchema.getRawJson(), MediaType.APPLICATION_JSON );
+ }
+ else
+ {
+ ScimError err = new ScimError( ErrorCode.NOT_FOUND, "No schema found with the URI " + schemaId );
+
+ ErrorResponse resp = new ErrorResponse( err );
+ String json = ResourceSerializer.serialize( resp );
+ rb = Response.status( err.getCode() ).entity( json );
+ }
+ }
+
+ return rb.build();
+ }
+
+
+ private Response _getResourceTypeSchema( String resType, UriInfo uriInfo )
+ {
+ ResponseBuilder rb = null;
+
+ ResourceProvider provider = ( ResourceProvider ) servletCtx
+ .getAttribute( ResourceProvider.SERVLET_CONTEXT_ATTRIBUTE_KEY );
+
+ String servletCtxPath = uriInfo.getBaseUri().toString();
+
+ JsonElement el;
+
+ if ( resType == null )
+ {
+ el = provider.getAllResourceTypesSchema( servletCtxPath );
+ }
+ else
+ {
+ el = provider.getResourceTypeSchema( servletCtxPath, resType );
+ }
+
+ if ( el != null )
+ {
+ rb = Response.ok( el.toString(), MediaType.APPLICATION_JSON );
+ }
+ else
+ {
+ ScimError err = new ScimError( ErrorCode.NOT_FOUND, "No ResourceType found with the name " + resType );
+
+ ErrorResponse resp = new ErrorResponse( err );
+ String json = ResourceSerializer.serialize( resp );
+ rb = Response.status( err.getCode() ).entity( json );
+ }
+
+ return rb.build();
+ }
+
+}
Copied: directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/ResourceService.java (from r1647526, directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/UserService.java)
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/ResourceService.java?p2=directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/ResourceService.java&p1=directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/UserService.java&r1=1647526&r2=1648141&rev=1648141&view=diff
==============================================================================
--- directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/UserService.java (original)
+++ directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/ResourceService.java Sun Dec 28 01:53:26 2014
@@ -26,6 +26,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
+import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
@@ -45,12 +46,11 @@ import javax.ws.rs.core.StreamingOutput;
import javax.ws.rs.core.UriInfo;
import org.apache.directory.scim.ListResponse;
-import org.apache.directory.scim.MissingParameterException;
-import org.apache.directory.scim.ProviderService;
+import org.apache.directory.scim.ResourceProvider;
import org.apache.directory.scim.RequestContext;
import org.apache.directory.scim.ServerResource;
-import org.apache.directory.scim.UserResource;
import org.apache.directory.scim.json.ResourceSerializer;
+import org.apache.wink.common.AbstractDynamicResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -58,16 +58,18 @@ import org.slf4j.LoggerFactory;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-@Path( "Users" )
-public class UserService
+public class ResourceService extends AbstractDynamicResource
{
- private ProviderService provider = ServerInitializer.getProvider();
-
- private static final Logger LOG = LoggerFactory.getLogger( UserService.class );
+ private static final Logger LOG = LoggerFactory.getLogger( ResourceService.class );
+
+ @Context
+ private HttpServletRequest httpReq;
@Context
- HttpServletRequest httpReq;
+ private ServletContext servletCtx;
+
+ private ResourceProvider provider;
@GET
@Produces({MediaType.APPLICATION_JSON})
@@ -78,9 +80,11 @@ public class UserService
try
{
+ setProvider();
+
RequestContext ctx = provider.createCtx( uriInfo, httpReq );
- UserResource user = provider.getUser( ctx, userId );
+ ServerResource user = provider.getResource( ctx, userId );
String json = ResourceSerializer.serialize( user );
rb = Response.ok( json, MediaType.APPLICATION_JSON );
}
@@ -101,8 +105,9 @@ public class UserService
try
{
+ setProvider();
RequestContext ctx = provider.createCtx( uriInfo, httpReq );
- provider.deleteUser( userId, ctx );
+ provider.deleteResource( userId, ctx );
}
catch( Exception e )
{
@@ -128,9 +133,11 @@ public class UserService
try
{
+ setProvider();
+
RequestContext ctx = provider.createCtx( uriInfo, httpReq );
- provider.addUser( jsonData, ctx );
+ provider.addResource( jsonData, ctx );
ServerResource res = ctx.getCoreResource();
@@ -165,9 +172,10 @@ public class UserService
try
{
+ setProvider();
RequestContext ctx = provider.createCtx( uriInfo, httpReq );
- ServerResource res = provider.putUser( userId, jsonData, ctx );
+ ServerResource res = provider.putResource( userId, jsonData, ctx );
String json = ResourceSerializer.serialize( res );
@@ -200,9 +208,10 @@ public class UserService
try
{
+ setProvider();
RequestContext ctx = provider.createCtx( uriInfo, httpReq );
- ServerResource resource = provider.patchUser( userId, jsonData, ctx );
+ ServerResource resource = provider.patchResource( userId, jsonData, ctx );
if( resource == null )
{
@@ -240,6 +249,7 @@ public class UserService
try
{
+ setProvider();
RequestContext ctx = provider.createCtx( uriInfo, httpReq );
ListResponse lr = provider.search( filter, attributes, ctx );
@@ -264,6 +274,7 @@ public class UserService
try
{
+ setProvider();
RequestContext ctx = provider.createCtx( uriInfo, httpReq );
final InputStream in = provider.getUserPhoto( id, atName, ctx );
@@ -311,4 +322,9 @@ public class UserService
return rb.build();
}
+
+ private void setProvider()
+ {
+ provider = ( ResourceProvider ) servletCtx.getAttribute( ResourceProvider.SERVLET_CONTEXT_ATTRIBUTE_KEY );
+ }
}
Modified: directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/SchemaService.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/SchemaService.java?rev=1648141&r1=1648140&r2=1648141&view=diff
==============================================================================
--- directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/SchemaService.java (original)
+++ directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/SchemaService.java Sun Dec 28 01:53:26 2014
@@ -19,6 +19,7 @@
*/
package org.apache.directory.scim.rest;
+import javax.servlet.ServletContext;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
@@ -29,7 +30,7 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.core.UriInfo;
-import org.apache.directory.scim.ProviderService;
+import org.apache.directory.scim.ResourceProvider;
import org.apache.directory.scim.json.ResourceSerializer;
import org.apache.directory.scim.schema.ErrorCode;
import org.apache.directory.scim.schema.ErrorResponse;
@@ -45,32 +46,7 @@ import org.apache.directory.scim.schema.
public class SchemaService
{
- private ProviderService provider = ServerInitializer.getProvider();
-
-
- @GET
- @Produces({MediaType.APPLICATION_JSON})
- @Path("{uri}")
- public Response getUser( @PathParam("uri") String schemaUri, @Context UriInfo uriInfo )
- {
- ResponseBuilder rb = null;
-
- JsonSchema jsonSchema = provider.getSchema( schemaUri );
-
- if( jsonSchema != null )
- {
- rb = Response.ok( jsonSchema.getRawJson(), MediaType.APPLICATION_JSON );
- }
- else
- {
- ScimError err = new ScimError( ErrorCode.NOT_FOUND, "No schema found with the URI " + schemaUri );
-
- ErrorResponse resp = new ErrorResponse( err );
- String json = ResourceSerializer.serialize( resp );
- rb = Response.status( err.getCode() ).entity( json );
- }
-
- return rb.build();
- }
+ @Context
+ private ServletContext servletCtx;
}
Modified: directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/auth/AuthenticationFilter.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/auth/AuthenticationFilter.java?rev=1648141&r1=1648140&r2=1648141&view=diff
==============================================================================
--- directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/auth/AuthenticationFilter.java (original)
+++ directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/auth/AuthenticationFilter.java Sun Dec 28 01:53:26 2014
@@ -32,11 +32,10 @@ import javax.servlet.http.HttpServletReq
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
-import org.apache.directory.scim.ProviderService;
+import org.apache.directory.scim.ResourceProvider;
import org.apache.directory.scim.RequestContext;
import org.apache.directory.scim.ScimUtil;
import org.apache.directory.scim.json.ResourceSerializer;
-import org.apache.directory.scim.rest.ServerInitializer;
import org.apache.directory.scim.schema.ErrorCode;
import org.apache.directory.scim.schema.ErrorResponse;
import org.apache.directory.scim.schema.ErrorResponse.ScimError;
@@ -52,7 +51,7 @@ public class AuthenticationFilter implem
private EscimoAuthenticator authenticator;
- private ProviderService provider;
+ private ResourceProvider provider;
public void destroy()
{
@@ -148,7 +147,7 @@ public class AuthenticationFilter implem
if( authenticator != null )
{
- provider = ServerInitializer.getProvider();
+ provider = ( ResourceProvider ) filterConfig.getServletContext().getAttribute( ResourceProvider.SERVLET_CONTEXT_ATTRIBUTE_KEY );
provider.setAllowAuthorizedUsers( true );
}
}
Modified: directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/auth/BasicAuthenticator.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/auth/BasicAuthenticator.java?rev=1648141&r1=1648140&r2=1648141&view=diff
==============================================================================
--- directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/auth/BasicAuthenticator.java (original)
+++ directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/auth/BasicAuthenticator.java Sun Dec 28 01:53:26 2014
@@ -23,7 +23,7 @@ import javax.servlet.http.HttpServletReq
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.codec.binary.Base64;
-import org.apache.directory.scim.ProviderService;
+import org.apache.directory.scim.ResourceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -36,7 +36,7 @@ public class BasicAuthenticator implemen
{
private static final Logger LOG = LoggerFactory.getLogger( BasicAuthenticator.class );
- public String authenticate( HttpServletRequest req, ProviderService provider ) throws Exception
+ public String authenticate( HttpServletRequest req, ResourceProvider provider ) throws Exception
{
String authHeader = req.getHeader( "Authorization" );
Modified: directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/auth/EscimoAuthenticator.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/auth/EscimoAuthenticator.java?rev=1648141&r1=1648140&r2=1648141&view=diff
==============================================================================
--- directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/auth/EscimoAuthenticator.java (original)
+++ directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/auth/EscimoAuthenticator.java Sun Dec 28 01:53:26 2014
@@ -21,7 +21,7 @@ package org.apache.directory.scim.rest.a
import javax.servlet.http.HttpServletRequest;
-import org.apache.directory.scim.ProviderService;
+import org.apache.directory.scim.ResourceProvider;
/**
* TODO EscimoAuthenticator.
@@ -30,5 +30,5 @@ import org.apache.directory.scim.Provide
*/
public interface EscimoAuthenticator
{
- String authenticate( HttpServletRequest req, ProviderService provider ) throws Exception;
+ String authenticate( HttpServletRequest req, ResourceProvider provider ) throws Exception;
}
Modified: directory/escimo/trunk/server/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/server/src/main/webapp/WEB-INF/web.xml?rev=1648141&r1=1648140&r2=1648141&view=diff
==============================================================================
--- directory/escimo/trunk/server/src/main/webapp/WEB-INF/web.xml (original)
+++ directory/escimo/trunk/server/src/main/webapp/WEB-INF/web.xml Sun Dec 28 01:53:26 2014
@@ -4,17 +4,12 @@
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
+ <context-param>
+ <param-name>configDir</param-name>
+ <param-value>/WEB-INF/conf</param-value>
+ </context-param>
- <filter>
- <filter-name>escimoConfigServlet</filter-name>
- <filter-class>org.apache.directory.scim.rest.ConfigurationFilter</filter-class>
- <init-param>
- <param-name>configDir</param-name>
- <param-value>/WEB-INF/conf</param-value>
- </init-param>
- </filter>
-
- <filter>
+ <!--filter>
<filter-name>AuthenticationFilter</filter-name>
<filter-class>org.apache.directory.scim.rest.auth.AuthenticationFilter</filter-class>
<init-param>
@@ -26,7 +21,11 @@
<filter-mapping>
<filter-name>AuthenticationFilter</filter-name>
<url-pattern>/*</url-pattern>
- </filter-mapping>
+ </filter-mapping-->
+
+ <listener>
+ <listener-class>org.apache.directory.scim.rest.EscimoContextListener</listener-class>
+ </listener>
<!-- Servlets -->
<servlet>