Skip to content

Commit 1aad28b

Browse files
committed
Cleaning up examples to be consistent.
- javadoc tweaks - formatting - header formatting
1 parent 3c71cb1 commit 1aad28b

24 files changed

Lines changed: 150 additions & 165 deletions

File tree

scim-server-examples/scim-server-jersey-4/src/main/java/org/apache/directory/scim/example/jersey4/JerseyApplication.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
public class JerseyApplication extends Application {
4545

4646
private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(JerseyApplication.class);
47-
47+
4848
@Override
4949
public Set<Class<?>> getClasses() {
5050
return ScimResourceHelper.scimpleFeatureAndResourceClasses();
@@ -53,11 +53,11 @@ public Set<Class<?>> getClasses() {
5353
@Produces
5454
ServerConfiguration serverConfiguration() {
5555
return new ServerConfiguration()
56-
// Set any unique configuration bits
5756
.setId("scimple-jersey4-example")
5857
.setDocumentationUri("https://github.com/apache/directory-scimple")
59-
// set the auth scheme too
60-
.addAuthenticationSchema(oauthBearer());
58+
// Informational only, returned by /ServiceProviderConfig.
59+
// This does not enforce authentication. Use oauthBearer() or httpBasic() as appropriate.
60+
.addAuthenticationSchema(oauthBearer());
6161
}
6262

6363
public static void main(String[] args) {

scim-server-examples/scim-server-jersey-4/src/main/java/org/apache/directory/scim/example/jersey4/extensions/LuckyNumberExtension.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,31 @@
3131
/**
3232
* Allows a User's lucky number to be passed as part of the User's entry via
3333
* the SCIM protocol.
34-
*
34+
*
3535
* @author Chris Harm &lt;crh5255@psu.edu&gt;
3636
*/
3737
@XmlRootElement( name = "LuckyNumberExtension", namespace = "http://www.psu.edu/schemas/psu-scim" )
3838
@XmlAccessorType(XmlAccessType.NONE)
3939
@ScimExtensionType(id = LuckyNumberExtension.SCHEMA_URN, description="Lucky Numbers", name="LuckyNumbers", required=true)
4040
public class LuckyNumberExtension implements ScimExtension {
41-
41+
4242
public static final String SCHEMA_URN = "urn:mem:params:scim:schemas:extension:LuckyNumberExtension";
4343

4444
@ScimAttribute(returned=Schema.Attribute.Returned.DEFAULT, required=true)
4545
@XmlElement
4646
private long luckyNumber;
47-
47+
4848
/**
4949
* Provides the URN associated with this extension which, as defined by the
5050
* SCIM specification is the extension's unique identifier.
51-
*
51+
*
5252
* @return The extension's URN.
5353
*/
5454
@Override
5555
public String getUrn() {
5656
return SCHEMA_URN;
5757
}
5858

59-
6059
public long getLuckyNumber() {
6160
return this.luckyNumber;
6261
}

scim-server-examples/scim-server-jersey-4/src/main/java/org/apache/directory/scim/example/jersey4/service/InMemoryGroupService.java

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
/*
2-
* Licensed to the Apache Software Foundation (ASF) under one
3-
* or more contributor license agreements. See the NOTICE file
4-
* distributed with this work for additional information
5-
* regarding copyright ownership. The ASF licenses this file
6-
* to you under the Apache License, Version 2.0 (the
7-
* "License"); you may not use this file except in compliance
8-
* with the License. You may obtain a copy of the License at
9-
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
12-
* Unless required by applicable law or agreed to in writing,
13-
* software distributed under the License is distributed on an
14-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15-
* KIND, either express or implied. See the License for the
16-
* specific language governing permissions and limitations
17-
* under the License.
18-
*/
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
1919

2020
package org.apache.directory.scim.example.jersey4.service;
2121

@@ -41,16 +41,16 @@
4141
import org.apache.directory.scim.spec.resources.ScimGroup;
4242

4343
import java.util.Collections;
44-
import java.util.HashMap;
4544
import java.util.List;
4645
import java.util.Map;
4746
import java.util.UUID;
47+
import java.util.concurrent.ConcurrentHashMap;
4848

4949
@Named
5050
@ApplicationScoped
5151
public class InMemoryGroupService implements Repository<ScimGroup> {
5252

53-
private final Map<String, ScimGroup> groups = new HashMap<>();
53+
private final Map<String, ScimGroup> groups = new ConcurrentHashMap<>();
5454

5555
private SchemaRegistry schemaRegistry;
5656

@@ -89,7 +89,7 @@ public ScimGroup create(ScimGroup resource, ScimRequestContext requestContext) t
8989

9090
// check to make sure the group doesn't already exist
9191
boolean existingGroupFound = groups.values().stream()
92-
.anyMatch(group -> resource.getExternalId().equals(group.getExternalId()));
92+
.anyMatch(group -> resource.getExternalId().equals(group.getExternalId()));
9393
if (existingGroupFound) {
9494
// HTTP leaking into data layer
9595
throw new UnableToCreateResourceException(Response.Status.CONFLICT, "Group '" + resource.getExternalId() + "' already exists.");
@@ -105,7 +105,6 @@ public ScimGroup update(String id, ScimGroup resource, ScimRequestContext reques
105105
if (!groups.containsKey(id)) {
106106
throw new ResourceNotFoundException(id);
107107
}
108-
109108
groups.put(id, resource);
110109
return resource;
111110
}
@@ -115,7 +114,6 @@ public ScimGroup patch(String id, List<PatchOperation> patchOperations, ScimRequ
115114
if (!groups.containsKey(id)) {
116115
throw new ResourceNotFoundException(id);
117116
}
118-
119117
ScimGroup resource = patchHandler.apply(get(id, requestContext), patchOperations);
120118
groups.put(id, resource);
121119
return resource;
@@ -139,10 +137,10 @@ public FilterResponse<ScimGroup> find(Filter filter, ScimRequestContext requestC
139137
long startIndex = requestContext.getPageRequest().map(PageRequest::getStartIndex).map(it -> it - 1).orElse(0);
140138

141139
List<ScimGroup> result = groups.values().stream()
142-
.skip(startIndex)
143-
.limit(count)
144-
.filter(FilterExpressions.inMemory(filter, schemaRegistry.getSchema(ScimGroup.SCHEMA_URI)))
145-
.toList();
140+
.skip(startIndex)
141+
.limit(count)
142+
.filter(FilterExpressions.inMemory(filter, schemaRegistry.getSchema(ScimGroup.SCHEMA_URI)))
143+
.toList();
146144

147145
return new FilterResponse<>(result, result.size());
148146
}

scim-server-examples/scim-server-jersey-4/src/main/java/org/apache/directory/scim/example/jersey4/service/InMemoryUserService.java

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
/*
2-
* Licensed to the Apache Software Foundation (ASF) under one
3-
* or more contributor license agreements. See the NOTICE file
4-
* distributed with this work for additional information
5-
* regarding copyright ownership. The ASF licenses this file
6-
* to you under the Apache License, Version 2.0 (the
7-
* "License"); you may not use this file except in compliance
8-
* with the License. You may obtain a copy of the License at
9-
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
12-
* Unless required by applicable law or agreed to in writing,
13-
* software distributed under the License is distributed on an
14-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15-
* KIND, either express or implied. See the License for the
16-
* specific language governing permissions and limitations
17-
* under the License.
18-
*/
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
1919

2020
package org.apache.directory.scim.example.jersey4.service;
2121

@@ -50,7 +50,7 @@
5050
import java.util.concurrent.ConcurrentHashMap;
5151

5252
/**
53-
* Creates a singleton (effectively) Repository<ScimUser> with a memory-based
53+
* Creates a singleton (effectively) {@code Repository<ScimUser>} with a memory-based
5454
* persistence layer.
5555
*
5656
* @author Chris Harm &lt;crh5255@psu.edu&gt;
@@ -156,7 +156,6 @@ public ScimUser patch(String id, List<PatchOperation> patchOperations, ScimReque
156156
return resource;
157157
}
158158

159-
160159
/**
161160
* @see Repository#get(java.lang.String, ScimRequestContext)
162161
*/

scim-server-examples/scim-server-jersey/src/main/java/org/apache/directory/scim/example/jersey/JerseyApplication.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
public class JerseyApplication extends Application {
4545

4646
private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(JerseyApplication.class);
47-
47+
4848
@Override
4949
public Set<Class<?>> getClasses() {
5050
return ScimResourceHelper.scimpleFeatureAndResourceClasses();
@@ -53,11 +53,11 @@ public Set<Class<?>> getClasses() {
5353
@Produces
5454
ServerConfiguration serverConfiguration() {
5555
return new ServerConfiguration()
56-
// Set any unique configuration bits
5756
.setId("scimple-jersey-example")
5857
.setDocumentationUri("https://github.com/apache/directory-scimple")
59-
// set the auth scheme too
60-
.addAuthenticationSchema(oauthBearer());
58+
// Informational only, returned by /ServiceProviderConfig.
59+
// This does not enforce authentication. Use oauthBearer() or httpBasic() as appropriate.
60+
.addAuthenticationSchema(oauthBearer());
6161
}
6262

6363
public static void main(String[] args) {

scim-server-examples/scim-server-jersey/src/main/java/org/apache/directory/scim/example/jersey/extensions/LuckyNumberExtension.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,31 @@
3131
/**
3232
* Allows a User's lucky number to be passed as part of the User's entry via
3333
* the SCIM protocol.
34-
*
34+
*
3535
* @author Chris Harm &lt;crh5255@psu.edu&gt;
3636
*/
3737
@XmlRootElement( name = "LuckyNumberExtension", namespace = "http://www.psu.edu/schemas/psu-scim" )
3838
@XmlAccessorType(XmlAccessType.NONE)
3939
@ScimExtensionType(id = LuckyNumberExtension.SCHEMA_URN, description="Lucky Numbers", name="LuckyNumbers", required=true)
4040
public class LuckyNumberExtension implements ScimExtension {
41-
41+
4242
public static final String SCHEMA_URN = "urn:mem:params:scim:schemas:extension:LuckyNumberExtension";
4343

4444
@ScimAttribute(returned=Schema.Attribute.Returned.DEFAULT, required=true)
4545
@XmlElement
4646
private long luckyNumber;
47-
47+
4848
/**
4949
* Provides the URN associated with this extension which, as defined by the
5050
* SCIM specification is the extension's unique identifier.
51-
*
51+
*
5252
* @return The extension's URN.
5353
*/
5454
@Override
5555
public String getUrn() {
5656
return SCHEMA_URN;
5757
}
5858

59-
6059
public long getLuckyNumber() {
6160
return this.luckyNumber;
6261
}

scim-server-examples/scim-server-jersey/src/main/java/org/apache/directory/scim/example/jersey/service/InMemoryGroupService.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@
4141
import org.apache.directory.scim.spec.resources.ScimGroup;
4242

4343
import java.util.Collections;
44-
import java.util.HashMap;
4544
import java.util.List;
4645
import java.util.Map;
4746
import java.util.UUID;
47+
import java.util.concurrent.ConcurrentHashMap;
4848

4949
@Named
5050
@ApplicationScoped
5151
public class InMemoryGroupService implements Repository<ScimGroup> {
5252

53-
private final Map<String, ScimGroup> groups = new HashMap<>();
53+
private final Map<String, ScimGroup> groups = new ConcurrentHashMap<>();
5454

5555
private SchemaRegistry schemaRegistry;
5656

@@ -105,7 +105,6 @@ public ScimGroup update(String id, ScimGroup resource, ScimRequestContext reques
105105
if (!groups.containsKey(id)) {
106106
throw new ResourceNotFoundException(id);
107107
}
108-
109108
groups.put(id, resource);
110109
return resource;
111110
}
@@ -115,7 +114,6 @@ public ScimGroup patch(String id, List<PatchOperation> patchOperations, ScimRequ
115114
if (!groups.containsKey(id)) {
116115
throw new ResourceNotFoundException(id);
117116
}
118-
119117
ScimGroup resource = patchHandler.apply(get(id, requestContext), patchOperations);
120118
groups.put(id, resource);
121119
return resource;

scim-server-examples/scim-server-jersey/src/main/java/org/apache/directory/scim/example/jersey/service/InMemoryUserService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
import java.util.concurrent.ConcurrentHashMap;
5151

5252
/**
53-
* Creates a singleton (effectively) Repository<ScimUser> with a memory-based
53+
* Creates a singleton (effectively) {@code Repository<ScimUser>} with a memory-based
5454
* persistence layer.
5555
*
5656
* @author Chris Harm &lt;crh5255@psu.edu&gt;
@@ -156,7 +156,6 @@ public ScimUser patch(String id, List<PatchOperation> patchOperations, ScimReque
156156
return resource;
157157
}
158158

159-
160159
/**
161160
* @see Repository#get(java.lang.String, ScimRequestContext)
162161
*/

scim-server-examples/scim-server-memory/src/main/java/org/apache/directory/scim/example/memory/extensions/LuckyNumberExtension.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,24 @@
3131
/**
3232
* Allows a User's lucky number to be passed as part of the User's entry via
3333
* the SCIM protocol.
34-
*
34+
*
3535
* @author Chris Harm &lt;crh5255@psu.edu&gt;
3636
*/
3737
@XmlRootElement( name = "LuckyNumberExtension", namespace = "http://www.psu.edu/schemas/psu-scim" )
3838
@XmlAccessorType(XmlAccessType.NONE)
3939
@ScimExtensionType(id = LuckyNumberExtension.SCHEMA_URN, description="Lucky Numbers", name="LuckyNumbers", required=true)
4040
public class LuckyNumberExtension implements ScimExtension {
41-
41+
4242
public static final String SCHEMA_URN = "urn:mem:params:scim:schemas:extension:LuckyNumberExtension";
4343

4444
@ScimAttribute(returned=Schema.Attribute.Returned.DEFAULT, required=true)
4545
@XmlElement
4646
private long luckyNumber;
47-
47+
4848
/**
4949
* Provides the URN associated with this extension which, as defined by the
5050
* SCIM specification is the extension's unique identifier.
51-
*
51+
*
5252
* @return The extension's URN.
5353
*/
5454
@Override

scim-server-examples/scim-server-memory/src/main/java/org/apache/directory/scim/example/memory/rest/RestApplication.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
import java.util.Set;
3030

31-
import static org.apache.directory.scim.spec.schema.ServiceProviderConfiguration.AuthenticationSchema.httpBasic;
31+
import static org.apache.directory.scim.spec.schema.ServiceProviderConfiguration.AuthenticationSchema.oauthBearer;
3232

3333
@ApplicationPath("v2")
3434
public class RestApplication extends Application {
@@ -37,7 +37,10 @@ public class RestApplication extends Application {
3737
ServerConfiguration serverConfiguration() {
3838
return new ServerConfiguration()
3939
.setId("scimple-in-memory-example")
40-
.addAuthenticationSchema(httpBasic());
40+
.setDocumentationUri("https://github.com/apache/directory-scimple")
41+
// Informational only, returned by /ServiceProviderConfig.
42+
// This does not enforce authentication. Use oauthBearer() or httpBasic() as appropriate.
43+
.addAuthenticationSchema(oauthBearer());
4144
}
4245

4346
@Override

0 commit comments

Comments
 (0)