SCIM Organization

This commit is contained in:
shimingxy
2020-06-25 16:31:04 +08:00
parent 353f4c13d7
commit 6cbc78a238
5 changed files with 396 additions and 0 deletions

View File

@@ -0,0 +1,83 @@
package org.maxkey.identity.scim.controller;
import java.io.IOException;
import java.util.Map;
import org.maxkey.identity.scim.resources.Organization;
import org.maxkey.identity.scim.resources.ScimSearchResult;
import org.maxkey.identity.scim.resources.User;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.json.MappingJacksonValue;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.UriComponentsBuilder;
/**
* This Controller is used to manage Organization
* <p>
* http://tools.ietf.org/html/draft-ietf-scim-core-schema-00#section-6
* <p>
* it is based on the SCIM 2.0 API Specification:
* <p>
* http://tools.ietf.org/html/draft-ietf-scim-api-00#section-3
*/
@RestController
@RequestMapping(value = "/identity/scim/v2/Organization")
public class OrganizationController {
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public MappingJacksonValue getOrganization(@PathVariable String id,
@RequestParam(required = false) String attributes) {
Organization user = null;
return null;
}
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<MappingJacksonValue> create(@RequestBody Organization user,
@RequestParam(required = false) String attributes,
UriComponentsBuilder builder) throws IOException {
Organization createdUser = null;
return null;
}
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
public ResponseEntity<MappingJacksonValue> replace(@PathVariable String id,
@RequestBody Organization user,
@RequestParam(required = false) String attributes)
throws IOException {
Organization createdUser = null;
return null;
}
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.OK)
public void delete(@PathVariable final String id) {
//tokenService.revokeAllTokensOfUser(id);
}
@RequestMapping(method = RequestMethod.GET)
public MappingJacksonValue searchWithGet(@RequestParam Map<String, String> requestParameters) {
return searchWithPost(requestParameters);
}
@RequestMapping(value = "/.search", method = RequestMethod.POST)
public MappingJacksonValue searchWithPost(@RequestParam Map<String, String> requestParameters) {
ScimSearchResult<User> scimSearchResult = null;
/*
requestParameters.get("filter"),
requestParameters.get("sortBy"),
requestParameters.getOrDefault("sortOrder", "ascending"), // scim default
Integer.parseInt(requestParameters.getOrDefault("count", "" + ServiceProviderConfigController.MAX_RESULTS)),
Integer.parseInt(requestParameters.getOrDefault("startIndex", "1")); // scim default
*/
String attributes = (requestParameters.containsKey("attributes") ? requestParameters.get("attributes") : "");
return null;
}
}

View File

@@ -0,0 +1,167 @@
package org.maxkey.identity.scim.resources;
import java.util.List;
public class Organization extends Resource{
/**
*
*/
private static final long serialVersionUID = -8087404240254880740L;
public static String SCHEMA = "urn:ietf:params:scim:schemas:core:2.0:Organization";
private String code;
private String name;
private String fullName;
private String parentId;
private String parentName;
private String type;
private String codePath;
private String namePath;
private String level;
private String division;
private List<OrganizationAddress> addresses;
private List<OrganizationEmail> emails;
private List<OrganizationPhoneNumber> phoneNumbers;
private String sortOrder;
private String description;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getParentName() {
return parentName;
}
public void setParentName(String parentName) {
this.parentName = parentName;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getCodePath() {
return codePath;
}
public void setCodePath(String codePath) {
this.codePath = codePath;
}
public String getNamePath() {
return namePath;
}
public void setNamePath(String namePath) {
this.namePath = namePath;
}
public String getLevel() {
return level;
}
public void setLevel(String level) {
this.level = level;
}
public String getDivision() {
return division;
}
public void setDivision(String division) {
this.division = division;
}
public String getSortOrder() {
return sortOrder;
}
public void setSortOrder(String sortOrder) {
this.sortOrder = sortOrder;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<OrganizationAddress> getAddresses() {
return addresses;
}
public void setAddresses(List<OrganizationAddress> addresses) {
this.addresses = addresses;
}
public List<OrganizationEmail> getEmails() {
return emails;
}
public void setEmails(List<OrganizationEmail> emails) {
this.emails = emails;
}
public List<OrganizationPhoneNumber> getPhoneNumbers() {
return phoneNumbers;
}
public void setPhoneNumbers(List<OrganizationPhoneNumber> phoneNumbers) {
this.phoneNumbers = phoneNumbers;
}
public Organization() {
}
}

View File

@@ -0,0 +1,71 @@
package org.maxkey.identity.scim.resources;
import java.io.Serializable;
public class OrganizationAddress extends MultiValuedAttribute implements Serializable {
/**
*
*/
private static final long serialVersionUID = 7401597570364338298L;
private String formatted;
private String streetAddress;
private String locality;
private String region;
private String postalCode;
private String country;
public static class UserAddressType {
public static final String WORK = "work";
public static final String HOME = "home";
public static final String OTHER = "other";
}
public String getFormatted() {
return formatted;
}
public void setFormatted(String formatted) {
this.formatted = formatted;
}
public String getStreetAddress() {
return streetAddress;
}
public void setStreetAddress(String streetAddress) {
this.streetAddress = streetAddress;
}
public String getLocality() {
return locality;
}
public void setLocality(String locality) {
this.locality = locality;
}
public String getRegion() {
return region;
}
public void setRegion(String region) {
this.region = region;
}
public String getPostalCode() {
return postalCode;
}
public void setPostalCode(String postalCode) {
this.postalCode = postalCode;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public OrganizationAddress() {
}
}

View File

@@ -0,0 +1,54 @@
package org.maxkey.identity.scim.resources;
import java.io.Serializable;
public class OrganizationEmail extends MultiValuedAttribute implements Serializable {
/**
*
*/
private static final long serialVersionUID = -41327146592552688L;
public static class UserEmailType {
public static final String WORK = "work";
public static final String HOME = "home";
public static final String OTHER = "other";
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public boolean isPrimary() {
return primary;
}
public void setPrimary(boolean primary) {
this.primary = primary;
}
public OrganizationEmail() {
}
public OrganizationEmail(String value, String type, boolean primary) {
super();
this.value = value;
this.type = type;
this.primary = primary;
}
}

View File

@@ -0,0 +1,21 @@
package org.maxkey.identity.scim.resources;
import java.io.Serializable;
public class OrganizationPhoneNumber extends MultiValuedAttribute implements Serializable {
/**
*
*/
private static final long serialVersionUID = 3201987266085144715L;
public static class UserPhoneNumberType {
public static final String WORK = "work";
public static final String HOME = "home";
public static final String MOBILE = "mobile";
public static final String FAX = "fax";
public static final String PAGER = "pager";
public static final String OTHER = "other";
}
}