Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scimono-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

<modules>
<module>simple-server</module>
<module>spring-boot-server</module>
</modules>


Expand Down
90 changes: 90 additions & 0 deletions scimono-examples/spring-boot-server/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>scimono-examples</artifactId>
<groupId>com.sap.scimono.examples</groupId>
<version>0.0.8-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>spring-boot-server</artifactId>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>

<jackson-2-version>2.9.6</jackson-2-version>
<jersey-2-version>2.27</jersey-2-version>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<jvmArguments>
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
</jvmArguments>
</configuration>
</plugin>
</plugins>
</build>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.2.4.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>


<dependency>
<groupId>com.sap.scimono</groupId>
<artifactId>scimono-server</artifactId>
<version>0.0.8-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>${jersey-2-version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>${jersey-2-version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey-2-version}</version>
</dependency>

<!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>-->

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.25</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.sap.scimono.samples.spring;

import com.sap.scimono.samples.spring.jaxrs.MySCIMApplication;
import org.glassfish.jersey.servlet.ServletContainer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class ServerStart {
public static void main(String[] args) {
SpringApplication.run(ServerStart.class, args);
}

@Bean
public ServletRegistrationBean<ServletContainer> jerseyContainer() {
ServletRegistrationBean<ServletContainer> jerseyContainer = new ServletRegistrationBean<>(new ServletContainer(), "/scim/*");
jerseyContainer.addInitParameter("javax.ws.rs.Application", MySCIMApplication.class.getName());
return jerseyContainer;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.sap.scimono.samples.spring.jaxrs;

import com.sap.scimono.SCIMApplication;
import com.sap.scimono.callback.users.UsersCallback;
import org.glassfish.jersey.server.ServerProperties;

import java.util.HashMap;
import java.util.Map;

public class MySCIMApplication extends SCIMApplication {
@Override
public Map<String, Object> getProperties() {
Map<String, Object> properties = new HashMap<>(super.getProperties());
properties.put(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);

return properties;
}

@Override
public UsersCallback getUsersCallback() {
return new UsersCallbackImpl();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.sap.scimono.samples.spring.jaxrs;

import com.sap.scimono.callback.users.UsersCallback;
import com.sap.scimono.entity.Meta;
import com.sap.scimono.entity.User;
import com.sap.scimono.entity.paging.PageInfo;
import com.sap.scimono.entity.paging.PagedResult;
import com.sap.scimono.entity.patch.PatchBody;
import com.sap.scimono.exception.ResourceNotFoundException;
import com.sap.scimono.exception.SCIMException;

import javax.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;

public class UsersCallbackImpl implements UsersCallback {
private static final Map<String, User> USERS_CONTAINER = new HashMap<>();

@Override
public User getUserByUsername(String s) {
return null;
}

@Override
public User getUser(String id) {
User user = USERS_CONTAINER.get(id);
if (user == null) {
throw new ResourceNotFoundException(User.RESOURCE_TYPE_USER, id);
}

return user;
}

@Override
public PagedResult<User> getUsers(PageInfo pageInfo, String filter) {
Collection<User> allUsers = USERS_CONTAINER.values();
return new PagedResult<>(allUsers.size(), new ArrayList<>(allUsers));
}

@Override
public User createUser(User user) {
if (USERS_CONTAINER.containsKey(user.getId())) {
throw new SCIMException(SCIMException.Type.UNIQUENESS, "User with id: " + user.getId() + " already exists!", Response.Status.CONFLICT);
}

USERS_CONTAINER.put(user.getId(), user);
return user;
}

@Override
public User updateUser(User user) {
if (USERS_CONTAINER.get(user.getId()) == null) {
throw new ResourceNotFoundException(User.RESOURCE_TYPE_USER, user.getId());
}

USERS_CONTAINER.put(user.getId(), user);
return user;
}

@Override
public void patchUser(String s, PatchBody patchBody, Meta meta) {
// Not implemented
}

@Override
public void deleteUser(String id) {
USERS_CONTAINER.remove(id);
}

@Override
public Optional<String> generateId() {
return Optional.of(UUID.randomUUID().toString());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
logging.level.org.springframework.web=DEBUG