From 6cbc78a238f76e3431a9382adc9860beddfa8f6f Mon Sep 17 00:00:00 2001 From: shimingxy Date: Thu, 25 Jun 2020 16:31:04 +0800 Subject: [PATCH] SCIM Organization --- .../controller/OrganizationController.java | 83 +++++++++ .../identity/scim/resources/Organization.java | 167 ++++++++++++++++++ .../scim/resources/OrganizationAddress.java | 71 ++++++++ .../scim/resources/OrganizationEmail.java | 54 ++++++ .../resources/OrganizationPhoneNumber.java | 21 +++ 5 files changed, 396 insertions(+) create mode 100644 maxkey-identitys/maxkey-identity-scim/src/main/java/org/maxkey/identity/scim/controller/OrganizationController.java create mode 100644 maxkey-identitys/maxkey-identity-scim/src/main/java/org/maxkey/identity/scim/resources/Organization.java create mode 100644 maxkey-identitys/maxkey-identity-scim/src/main/java/org/maxkey/identity/scim/resources/OrganizationAddress.java create mode 100644 maxkey-identitys/maxkey-identity-scim/src/main/java/org/maxkey/identity/scim/resources/OrganizationEmail.java create mode 100644 maxkey-identitys/maxkey-identity-scim/src/main/java/org/maxkey/identity/scim/resources/OrganizationPhoneNumber.java diff --git a/maxkey-identitys/maxkey-identity-scim/src/main/java/org/maxkey/identity/scim/controller/OrganizationController.java b/maxkey-identitys/maxkey-identity-scim/src/main/java/org/maxkey/identity/scim/controller/OrganizationController.java new file mode 100644 index 000000000..d54d92913 --- /dev/null +++ b/maxkey-identitys/maxkey-identity-scim/src/main/java/org/maxkey/identity/scim/controller/OrganizationController.java @@ -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 + *

+ * http://tools.ietf.org/html/draft-ietf-scim-core-schema-00#section-6 + *

+ * it is based on the SCIM 2.0 API Specification: + *

+ * 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 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 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 requestParameters) { + return searchWithPost(requestParameters); + } + + @RequestMapping(value = "/.search", method = RequestMethod.POST) + public MappingJacksonValue searchWithPost(@RequestParam Map requestParameters) { + ScimSearchResult 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; + } +} diff --git a/maxkey-identitys/maxkey-identity-scim/src/main/java/org/maxkey/identity/scim/resources/Organization.java b/maxkey-identitys/maxkey-identity-scim/src/main/java/org/maxkey/identity/scim/resources/Organization.java new file mode 100644 index 000000000..6bc904b73 --- /dev/null +++ b/maxkey-identitys/maxkey-identity-scim/src/main/java/org/maxkey/identity/scim/resources/Organization.java @@ -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 addresses; + + private List emails; + + private List 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 getAddresses() { + return addresses; + } + + public void setAddresses(List addresses) { + this.addresses = addresses; + } + + public List getEmails() { + return emails; + } + + public void setEmails(List emails) { + this.emails = emails; + } + + public List getPhoneNumbers() { + return phoneNumbers; + } + + public void setPhoneNumbers(List phoneNumbers) { + this.phoneNumbers = phoneNumbers; + } + + public Organization() { + } + + +} diff --git a/maxkey-identitys/maxkey-identity-scim/src/main/java/org/maxkey/identity/scim/resources/OrganizationAddress.java b/maxkey-identitys/maxkey-identity-scim/src/main/java/org/maxkey/identity/scim/resources/OrganizationAddress.java new file mode 100644 index 000000000..8e673e413 --- /dev/null +++ b/maxkey-identitys/maxkey-identity-scim/src/main/java/org/maxkey/identity/scim/resources/OrganizationAddress.java @@ -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() { + } + + +} diff --git a/maxkey-identitys/maxkey-identity-scim/src/main/java/org/maxkey/identity/scim/resources/OrganizationEmail.java b/maxkey-identitys/maxkey-identity-scim/src/main/java/org/maxkey/identity/scim/resources/OrganizationEmail.java new file mode 100644 index 000000000..04d1d71a0 --- /dev/null +++ b/maxkey-identitys/maxkey-identity-scim/src/main/java/org/maxkey/identity/scim/resources/OrganizationEmail.java @@ -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; + } + + +} diff --git a/maxkey-identitys/maxkey-identity-scim/src/main/java/org/maxkey/identity/scim/resources/OrganizationPhoneNumber.java b/maxkey-identitys/maxkey-identity-scim/src/main/java/org/maxkey/identity/scim/resources/OrganizationPhoneNumber.java new file mode 100644 index 000000000..4cdc1ce69 --- /dev/null +++ b/maxkey-identitys/maxkey-identity-scim/src/main/java/org/maxkey/identity/scim/resources/OrganizationPhoneNumber.java @@ -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"; + + } +}