maxkey-mxapis -> maxkey-webapis
This commit is contained in:
13
maxkey-webapis/maxkey-webapi-scim/build.gradle
Normal file
13
maxkey-webapis/maxkey-webapi-scim/build.gradle
Normal file
@@ -0,0 +1,13 @@
|
||||
description = "maxkey-webapi-scim"
|
||||
|
||||
apply plugin: 'java'
|
||||
|
||||
dependencies {
|
||||
//local jars
|
||||
implementation fileTree(dir: '../maxkey-lib/*/', include: '*.jar')
|
||||
|
||||
implementation project(":maxkey-common")
|
||||
implementation project(":maxkey-core")
|
||||
implementation project(":maxkey-persistence")
|
||||
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.mybatis.jpa.persistence.JpaPageResults;
|
||||
import org.maxkey.entity.Roles;
|
||||
import org.maxkey.entity.UserInfo;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimGroup;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimMemberRef;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimMeta;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimParameters;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimSearchResult;
|
||||
import org.maxkey.persistence.service.RoleMemberService;
|
||||
import org.maxkey.persistence.service.RolesService;
|
||||
import org.maxkey.util.DateUtils;
|
||||
import org.maxkey.util.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.converter.json.MappingJacksonValue;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
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;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/api/idm/SCIM/v2/Groups")
|
||||
public class ScimGroupController {
|
||||
final static Logger _logger = LoggerFactory.getLogger(ScimGroupController.class);
|
||||
|
||||
@Autowired
|
||||
RolesService rolesService;
|
||||
|
||||
@Autowired
|
||||
RoleMemberService roleMemberService;
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
public MappingJacksonValue get(@PathVariable String id,
|
||||
@RequestParam(required = false) String attributes) {
|
||||
Roles role = rolesService.get(id);
|
||||
ScimGroup scimGroup = role2ScimGroup(role);
|
||||
List<UserInfo> userList = roleMemberService.queryMemberByRoleId(id);
|
||||
if(userList != null && userList.size() > 0) {
|
||||
Set<ScimMemberRef> members = new HashSet<ScimMemberRef>();
|
||||
for (UserInfo user : userList) {
|
||||
members.add(new ScimMemberRef(user.getDisplayName(),user.getId()));
|
||||
}
|
||||
scimGroup.setMembers(members);
|
||||
}
|
||||
return new MappingJacksonValue(scimGroup);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
public MappingJacksonValue create(@RequestBody ScimGroup scimGroup,
|
||||
@RequestParam(required = false) String attributes,
|
||||
UriComponentsBuilder builder) throws IOException {
|
||||
Roles role =scimGroup2Role(scimGroup);
|
||||
rolesService.insert(role);
|
||||
return get(role.getId(),attributes);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
|
||||
public MappingJacksonValue replace(@PathVariable String id,
|
||||
@RequestBody ScimGroup scimGroup,
|
||||
@RequestParam(required = false) String attributes)
|
||||
throws IOException {
|
||||
Roles role =scimGroup2Role(scimGroup);
|
||||
rolesService.update(role);
|
||||
return get(role.getId(),attributes);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public void delete(@PathVariable final String id) {
|
||||
rolesService.remove(id);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public MappingJacksonValue searchWithGet(@ModelAttribute ScimParameters requestParameters) {
|
||||
return searchWithPost(requestParameters);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/.search", method = RequestMethod.POST)
|
||||
public MappingJacksonValue searchWithPost(@ModelAttribute ScimParameters requestParameters) {
|
||||
requestParameters.parse();
|
||||
_logger.debug("requestParameters {} ",requestParameters);
|
||||
Roles queryModel = new Roles();
|
||||
queryModel.setPageSize(requestParameters.getCount());
|
||||
queryModel.calculate(requestParameters.getStartIndex());
|
||||
|
||||
JpaPageResults<Roles> orgResults = rolesService.queryPageResults(queryModel);
|
||||
List<ScimGroup> resultList = new ArrayList<ScimGroup>();
|
||||
for(Roles group : orgResults.getRows()) {
|
||||
resultList.add(role2ScimGroup(group));
|
||||
}
|
||||
ScimSearchResult<ScimGroup> scimSearchResult =
|
||||
new ScimSearchResult<ScimGroup>(
|
||||
resultList,
|
||||
orgResults.getRecords(),
|
||||
queryModel.getPageSize(),
|
||||
requestParameters.getStartIndex());
|
||||
return new MappingJacksonValue(scimSearchResult);
|
||||
}
|
||||
|
||||
public ScimGroup role2ScimGroup(Roles group) {
|
||||
ScimGroup scimGroup = new ScimGroup();
|
||||
scimGroup.setId(group.getId());
|
||||
scimGroup.setExternalId(group.getId());
|
||||
scimGroup.setDisplayName(group.getRoleName());
|
||||
|
||||
ScimMeta meta = new ScimMeta("Group");
|
||||
if(StringUtils.isNotBlank(group.getCreatedDate())){
|
||||
meta.setCreated(
|
||||
DateUtils.parse(group.getCreatedDate(), DateUtils.FORMAT_DATE_YYYY_MM_DD_HH_MM_SS));
|
||||
}
|
||||
if(StringUtils.isNotBlank(group.getModifiedDate())){
|
||||
meta.setLastModified(
|
||||
DateUtils.parse(group.getModifiedDate(), DateUtils.FORMAT_DATE_YYYY_MM_DD_HH_MM_SS));
|
||||
}
|
||||
scimGroup.setMeta(meta);
|
||||
|
||||
return scimGroup;
|
||||
}
|
||||
|
||||
public Roles scimGroup2Role(ScimGroup scimGroup) {
|
||||
Roles role = new Roles();
|
||||
role.setId(scimGroup.getId());
|
||||
role.setRoleName(scimGroup.getDisplayName());
|
||||
return role;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.mybatis.jpa.persistence.JpaPageResults;
|
||||
import org.maxkey.entity.Organizations;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimMeta;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimOrganization;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimParameters;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimSearchResult;
|
||||
import org.maxkey.persistence.service.OrganizationsService;
|
||||
import org.maxkey.util.DateUtils;
|
||||
import org.maxkey.util.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.converter.json.MappingJacksonValue;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
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 = "/api/idm/SCIM/v2/Organizations")
|
||||
public class ScimOrganizationController {
|
||||
final static Logger _logger = LoggerFactory.getLogger(ScimOrganizationController.class);
|
||||
|
||||
@Autowired
|
||||
OrganizationsService organizationsService;
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
public MappingJacksonValue get(@PathVariable String id,
|
||||
@RequestParam(required = false) String attributes) {
|
||||
Organizations org = organizationsService.get(id);
|
||||
ScimOrganization scimOrg = org2ScimOrg(org);
|
||||
|
||||
return new MappingJacksonValue(scimOrg);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
public MappingJacksonValue create(@RequestBody ScimOrganization scimOrg,
|
||||
@RequestParam(required = false) String attributes,
|
||||
UriComponentsBuilder builder) throws IOException {
|
||||
Organizations createOrg = scimOrg2Org(scimOrg);
|
||||
organizationsService.insert(createOrg);
|
||||
return get(createOrg.getId(), attributes);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
|
||||
public MappingJacksonValue replace(@PathVariable String id,
|
||||
@RequestBody ScimOrganization scimOrg,
|
||||
@RequestParam(required = false) String attributes)throws IOException {
|
||||
Organizations updateOrg = scimOrg2Org(scimOrg);
|
||||
organizationsService.update(updateOrg);
|
||||
return get(id, attributes);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public void delete(@PathVariable final String id) {
|
||||
organizationsService.remove(id);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public MappingJacksonValue searchWithGet(@ModelAttribute ScimParameters requestParameters) {
|
||||
return searchWithPost(requestParameters);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/.search", method = RequestMethod.POST)
|
||||
public MappingJacksonValue searchWithPost(@ModelAttribute ScimParameters requestParameters) {
|
||||
requestParameters.parse();
|
||||
_logger.debug("requestParameters {} ",requestParameters);
|
||||
Organizations queryModel = new Organizations();
|
||||
queryModel.setPageSize(requestParameters.getCount());
|
||||
queryModel.calculate(requestParameters.getStartIndex());
|
||||
|
||||
JpaPageResults<Organizations> orgResults = organizationsService.queryPageResults(queryModel);
|
||||
List<ScimOrganization> resultList = new ArrayList<ScimOrganization>();
|
||||
for(Organizations org : orgResults.getRows()) {
|
||||
resultList.add(org2ScimOrg(org));
|
||||
}
|
||||
ScimSearchResult<ScimOrganization> scimSearchResult =
|
||||
new ScimSearchResult<ScimOrganization>(
|
||||
resultList,
|
||||
orgResults.getRecords(),
|
||||
queryModel.getPageSize(),
|
||||
requestParameters.getStartIndex());
|
||||
|
||||
return new MappingJacksonValue(scimSearchResult);
|
||||
}
|
||||
|
||||
public ScimOrganization org2ScimOrg(Organizations org) {
|
||||
ScimOrganization scimOrg = new ScimOrganization();
|
||||
scimOrg.setId(org.getId());
|
||||
scimOrg.setCode(org.getOrgCode());
|
||||
scimOrg.setName(org.getOrgName());
|
||||
scimOrg.setDisplayName(org.getOrgName());
|
||||
scimOrg.setFullName(org.getFullName());
|
||||
scimOrg.setType(org.getType());
|
||||
scimOrg.setLevel(org.getLevel());
|
||||
scimOrg.setDivision(org.getDivision());
|
||||
scimOrg.setSortOrder(org.getSortOrder());
|
||||
scimOrg.setCodePath(org.getCodePath());
|
||||
scimOrg.setNamePath(org.getNamePath());
|
||||
scimOrg.setDescription(org.getDescription());
|
||||
|
||||
scimOrg.setParentId(org.getParentId());
|
||||
scimOrg.setParent(org.getParentId());
|
||||
//scimOrg.setParentCode(org.getParentId());
|
||||
scimOrg.setParentName(org.getParentName());
|
||||
|
||||
scimOrg.setParentName(org.getParentName());
|
||||
if(StringUtils.isNotBlank(org.getSortOrder())) {
|
||||
scimOrg.setOrder(Long.parseLong(org.getSortOrder()));
|
||||
}else {
|
||||
scimOrg.setOrder(1);
|
||||
}
|
||||
scimOrg.setExternalId(org.getId());
|
||||
|
||||
ScimMeta meta = new ScimMeta("Organization");
|
||||
|
||||
if(StringUtils.isNotBlank(org.getCreatedDate())){
|
||||
meta.setCreated(
|
||||
DateUtils.parse(org.getCreatedDate(), DateUtils.FORMAT_DATE_YYYY_MM_DD_HH_MM_SS));
|
||||
}
|
||||
if(StringUtils.isNotBlank(org.getModifiedDate())){
|
||||
meta.setLastModified(
|
||||
DateUtils.parse(org.getModifiedDate(), DateUtils.FORMAT_DATE_YYYY_MM_DD_HH_MM_SS));
|
||||
}
|
||||
scimOrg.setMeta(meta);
|
||||
return scimOrg;
|
||||
}
|
||||
|
||||
public Organizations scimOrg2Org(ScimOrganization scimOrg) {
|
||||
Organizations org = new Organizations();
|
||||
org.setId(scimOrg.getId());
|
||||
org.setOrgCode(scimOrg.getCode());
|
||||
org.setFullName(scimOrg.getFullName());
|
||||
org.setOrgName(StringUtils.isNotBlank(scimOrg.getName()) ? scimOrg.getName():scimOrg.getDisplayName());
|
||||
org.setParentId(StringUtils.isNotBlank(scimOrg.getParentId())? scimOrg.getParentId():scimOrg.getParent());
|
||||
org.setParentCode(scimOrg.getParentCode());
|
||||
org.setParentName(scimOrg.getParentName());
|
||||
org.setSortOrder(StringUtils.isNotBlank(scimOrg.getSortOrder() )?scimOrg.getSortOrder():scimOrg.getOrder()+"");
|
||||
org.setLevel(scimOrg.getLevel());
|
||||
org.setType(scimOrg.getType());
|
||||
org.setDivision(scimOrg.getDivision());
|
||||
org.setDescription(scimOrg.getDescription());
|
||||
return org;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/api/idm/SCIM/v2/ServiceProviderConfig")
|
||||
public class ScimServiceProviderConfigController {
|
||||
|
||||
public static final int MAX_RESULTS = 500;
|
||||
public static final int MAX_RESULTS_LIMIT = 5000;
|
||||
|
||||
@RequestMapping
|
||||
@ResponseBody
|
||||
public ServiceProviderConfig getConfig() {
|
||||
return ServiceProviderConfig.INSTANCE;
|
||||
}
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public static final class ServiceProviderConfig {
|
||||
|
||||
public static final ServiceProviderConfig INSTANCE = new ServiceProviderConfig();
|
||||
public static final String SCHEMA = "urn:ietf:params:scim:schemas:core:2.0:ServiceProviderConfig";
|
||||
public final Supported patch = new Supported(false);
|
||||
public final Supported bulk = new BulkSupported(false);
|
||||
public final Supported filter = new FilterSupported(true, MAX_RESULTS);
|
||||
public final Supported changePassword = new Supported(false);
|
||||
public final Supported sort = new Supported(true);
|
||||
public final Supported etag = new Supported(false);
|
||||
public final Supported xmlDataFormat = new Supported(false);
|
||||
public final AuthenticationSchemes authenticationSchemes = new AuthenticationSchemes(
|
||||
new AuthenticationSchemes.AuthenticationScheme("Oauth2 Bearer",
|
||||
"OAuth2 Bearer access token is used for authorization.", "http://tools.ietf.org/html/rfc6749",
|
||||
"http://oauth.net/2/"));
|
||||
public Set<String> schemas = new HashSet<>();
|
||||
|
||||
private ServiceProviderConfig() {
|
||||
schemas.add(SCHEMA);
|
||||
}
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public static class Schemas {
|
||||
public final Set<String> schemas = new HashSet<>();
|
||||
|
||||
public Schemas(String coreSchema) {
|
||||
schemas.add(coreSchema);
|
||||
}
|
||||
}
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public static class Supported {
|
||||
public final boolean supported;
|
||||
|
||||
public Supported(boolean b) {
|
||||
supported = b;
|
||||
}
|
||||
}
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public static class FilterSupported extends Supported {
|
||||
public final Integer maxResults;
|
||||
|
||||
public FilterSupported(boolean b, Integer maxResults) {
|
||||
super(b);
|
||||
this.maxResults = maxResults;
|
||||
}
|
||||
}
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public static class BulkSupported extends Supported {
|
||||
public final Integer maxOperations;
|
||||
public final Integer maxPayloadSize;
|
||||
|
||||
public BulkSupported(boolean b) {
|
||||
super(b);
|
||||
this.maxOperations = null;
|
||||
this.maxPayloadSize = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
static class AuthenticationSchemes {
|
||||
public AuthenticationScheme[] authenticationSchemes;
|
||||
|
||||
public AuthenticationSchemes(AuthenticationScheme... authenticationScheme) {
|
||||
this.authenticationSchemes = authenticationScheme;
|
||||
|
||||
}
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public static class AuthenticationScheme {
|
||||
public final String name;
|
||||
public final String description;
|
||||
public final String specUrl;
|
||||
public final String documentationUrl;
|
||||
|
||||
AuthenticationScheme(String name, String description, String specUrl, String documentationUrl) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.specUrl = specUrl;
|
||||
this.documentationUrl = documentationUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.mybatis.jpa.persistence.JpaPageResults;
|
||||
import org.maxkey.constants.ConstsStatus;
|
||||
import org.maxkey.entity.Roles;
|
||||
import org.maxkey.entity.UserInfo;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimEnterprise;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimFormattedName;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimGroupRef;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimManager;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimMeta;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimParameters;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimSearchResult;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimUser;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimUserEmail;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimUserPhoneNumber;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimOrganizationEmail.UserEmailType;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimOrganizationPhoneNumber.UserPhoneNumberType;
|
||||
import org.maxkey.persistence.service.RolesService;
|
||||
import org.maxkey.persistence.service.UserInfoService;
|
||||
import org.maxkey.util.DateUtils;
|
||||
import org.maxkey.util.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.converter.json.MappingJacksonValue;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
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 User
|
||||
* <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 = "/api/idm/SCIM/v2/Users")
|
||||
public class ScimUserController {
|
||||
final static Logger _logger = LoggerFactory.getLogger(ScimUserController.class);
|
||||
@Autowired
|
||||
private UserInfoService userInfoService;
|
||||
|
||||
@Autowired
|
||||
RolesService rolesService;
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
public MappingJacksonValue get(@PathVariable String id,
|
||||
@RequestParam(required = false) String attributes) {
|
||||
UserInfo userInfo = userInfoService.get(id);
|
||||
ScimUser scimUser = userInfo2ScimUser(userInfo);
|
||||
return new MappingJacksonValue(scimUser);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
public MappingJacksonValue create(@RequestBody ScimUser user,
|
||||
@RequestParam(required = false) String attributes,
|
||||
UriComponentsBuilder builder) throws IOException {
|
||||
UserInfo userInfo = scimUser2UserInfo(user);
|
||||
userInfoService.insert(userInfo);
|
||||
return get(userInfo.getId(),attributes);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
|
||||
public MappingJacksonValue replace(@PathVariable String id,
|
||||
@RequestBody ScimUser user,
|
||||
@RequestParam(required = false) String attributes)
|
||||
throws IOException {
|
||||
UserInfo userInfo = scimUser2UserInfo(user);
|
||||
userInfoService.update(userInfo);
|
||||
return get(id,attributes);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public void delete(@PathVariable final String id) {
|
||||
userInfoService.remove(id);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public MappingJacksonValue searchWithGet(@ModelAttribute ScimParameters requestParameters) {
|
||||
return searchWithPost(requestParameters);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/.search", method = RequestMethod.POST)
|
||||
public MappingJacksonValue searchWithPost(@ModelAttribute ScimParameters requestParameters) {
|
||||
requestParameters.parse();
|
||||
_logger.debug("requestParameters {} ",requestParameters);
|
||||
UserInfo queryModel = new UserInfo();
|
||||
queryModel.setPageSize(requestParameters.getCount());
|
||||
queryModel.calculate(requestParameters.getStartIndex());
|
||||
|
||||
JpaPageResults<UserInfo> orgResults = userInfoService.queryPageResults(queryModel);
|
||||
List<ScimUser> resultList = new ArrayList<ScimUser>();
|
||||
for(UserInfo user : orgResults.getRows()) {
|
||||
resultList.add(userInfo2ScimUser(user));
|
||||
}
|
||||
ScimSearchResult<ScimUser> scimSearchResult =
|
||||
new ScimSearchResult<ScimUser>(
|
||||
resultList,
|
||||
orgResults.getRecords(),
|
||||
queryModel.getPageSize(),
|
||||
requestParameters.getStartIndex());
|
||||
return new MappingJacksonValue(scimSearchResult);
|
||||
}
|
||||
|
||||
public ScimUser userInfo2ScimUser(UserInfo userInfo) {
|
||||
ScimUser scimUser =new ScimUser();
|
||||
scimUser.setId(userInfo.getId());
|
||||
scimUser.setExternalId(userInfo.getId());
|
||||
scimUser.setDisplayName(userInfo.getDisplayName());
|
||||
scimUser.setUserName(userInfo.getUsername());
|
||||
scimUser.setName(new ScimFormattedName(
|
||||
userInfo.getFormattedName(),
|
||||
userInfo.getFamilyName(),
|
||||
userInfo.getGivenName(),
|
||||
userInfo.getMiddleName(),
|
||||
userInfo.getHonorificPrefix(),
|
||||
userInfo.getHonorificSuffix()
|
||||
)
|
||||
);
|
||||
scimUser.setNickName(userInfo.getNickName());
|
||||
scimUser.setTitle(userInfo.getJobTitle());
|
||||
scimUser.setUserType(userInfo.getUserType());
|
||||
|
||||
ScimEnterprise enterprise = new ScimEnterprise();
|
||||
enterprise.setDepartmentId(userInfo.getDepartmentId());
|
||||
enterprise.setDepartment(userInfo.getDepartment());
|
||||
enterprise.setCostCenter(userInfo.getCostCenter());
|
||||
enterprise.setManager(new ScimManager(userInfo.getManagerId(),userInfo.getManager()));
|
||||
enterprise.setDivision(userInfo.getDivision());
|
||||
enterprise.setEmployeeNumber(userInfo.getEmployeeNumber());
|
||||
scimUser.setEnterprise(enterprise);
|
||||
|
||||
List<String> organizationsList=new ArrayList<String>();
|
||||
organizationsList.add(userInfo.getDepartmentId());
|
||||
scimUser.setOrganization(organizationsList);
|
||||
|
||||
List<String> groupsList=new ArrayList<String>();
|
||||
List<ScimGroupRef> groups = new ArrayList<ScimGroupRef>();
|
||||
for(Roles role : rolesService.queryRolesByUserId(userInfo.getId())){
|
||||
groupsList.add(role.getId());
|
||||
groups.add(new ScimGroupRef(role.getId(),role.getRoleName()));
|
||||
|
||||
}
|
||||
scimUser.setGroup(groupsList);
|
||||
scimUser.setGroups(groups);
|
||||
|
||||
scimUser.setTimezone(userInfo.getTimeZone());
|
||||
scimUser.setLocale(userInfo.getLocale());
|
||||
scimUser.setPreferredLanguage(userInfo.getPreferredLanguage());
|
||||
scimUser.setActive(userInfo.getStatus() == ConstsStatus.ACTIVE);
|
||||
|
||||
List<ScimUserEmail> emails = new ArrayList<ScimUserEmail>();
|
||||
if(StringUtils.isNotBlank(userInfo.getEmail())){
|
||||
emails.add(new ScimUserEmail(userInfo.getEmail(),UserEmailType.OTHER,true));
|
||||
}
|
||||
if(StringUtils.isNotBlank(userInfo.getWorkEmail())){
|
||||
emails.add(new ScimUserEmail(userInfo.getEmail(),UserEmailType.WORK,false));
|
||||
}
|
||||
if(StringUtils.isNotBlank(userInfo.getHomeEmail())){
|
||||
emails.add(new ScimUserEmail(userInfo.getEmail(),UserEmailType.HOME,false));
|
||||
}
|
||||
|
||||
if(emails.size() > 0) {
|
||||
scimUser.setEmails(emails);
|
||||
}
|
||||
|
||||
List<ScimUserPhoneNumber> phoneNumbers = new ArrayList<ScimUserPhoneNumber>();
|
||||
if(StringUtils.isNotBlank(userInfo.getMobile())){
|
||||
phoneNumbers.add(new ScimUserPhoneNumber(userInfo.getMobile(),UserPhoneNumberType.MOBILE,true));
|
||||
}
|
||||
if(StringUtils.isNotBlank(userInfo.getWorkPhoneNumber())){
|
||||
phoneNumbers.add(new ScimUserPhoneNumber(userInfo.getWorkPhoneNumber(),UserPhoneNumberType.WORK,false));
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(userInfo.getHomePhoneNumber())){
|
||||
phoneNumbers.add(new ScimUserPhoneNumber(userInfo.getHomePhoneNumber(),UserPhoneNumberType.HOME,false));
|
||||
}
|
||||
|
||||
if(phoneNumbers.size() > 0) {
|
||||
scimUser.setPhoneNumbers(phoneNumbers);
|
||||
}
|
||||
|
||||
ScimMeta meta = new ScimMeta("User");
|
||||
if(StringUtils.isNotBlank(userInfo.getCreatedDate())){
|
||||
meta.setCreated(
|
||||
DateUtils.parse(userInfo.getCreatedDate(), DateUtils.FORMAT_DATE_YYYY_MM_DD_HH_MM_SS));
|
||||
}
|
||||
if(StringUtils.isNotBlank(userInfo.getModifiedDate())){
|
||||
meta.setLastModified(
|
||||
DateUtils.parse(userInfo.getModifiedDate(), DateUtils.FORMAT_DATE_YYYY_MM_DD_HH_MM_SS));
|
||||
}
|
||||
scimUser.setMeta(meta);
|
||||
return scimUser;
|
||||
}
|
||||
|
||||
public UserInfo scimUser2UserInfo(ScimUser scimUser) {
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setId(scimUser.getId());
|
||||
userInfo.setUsername(scimUser.getUserName());
|
||||
return userInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ScimEnterprise implements Serializable {
|
||||
private static final long serialVersionUID = -204619629148409697L;
|
||||
|
||||
private String employeeNumber;
|
||||
private String costCenter;
|
||||
private String organization;
|
||||
private String division;
|
||||
private String departmentId;
|
||||
private String department;
|
||||
private ScimManager manager;
|
||||
|
||||
public String getEmployeeNumber() {
|
||||
return employeeNumber;
|
||||
}
|
||||
public void setEmployeeNumber(String employeeNumber) {
|
||||
this.employeeNumber = employeeNumber;
|
||||
}
|
||||
public String getCostCenter() {
|
||||
return costCenter;
|
||||
}
|
||||
public void setCostCenter(String costCenter) {
|
||||
this.costCenter = costCenter;
|
||||
}
|
||||
public String getOrganization() {
|
||||
return organization;
|
||||
}
|
||||
public void setOrganization(String organization) {
|
||||
this.organization = organization;
|
||||
}
|
||||
public String getDivision() {
|
||||
return division;
|
||||
}
|
||||
public void setDivision(String division) {
|
||||
this.division = division;
|
||||
}
|
||||
|
||||
public String getDepartmentId() {
|
||||
return departmentId;
|
||||
}
|
||||
public void setDepartmentId(String departmentId) {
|
||||
this.departmentId = departmentId;
|
||||
}
|
||||
public String getDepartment() {
|
||||
return department;
|
||||
}
|
||||
public void setDepartment(String department) {
|
||||
this.department = department;
|
||||
}
|
||||
public ScimManager getManager() {
|
||||
return manager;
|
||||
}
|
||||
public void setManager(ScimManager manager) {
|
||||
this.manager = manager;
|
||||
}
|
||||
public ScimEnterprise() {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class ScimEnterpriseUser extends ScimUser {
|
||||
private static final long serialVersionUID = 3212312511630459427L;
|
||||
|
||||
public static final String SCHEMA = "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User";
|
||||
|
||||
@JsonProperty(SCHEMA)
|
||||
ScimEnterprise enterprise;
|
||||
|
||||
public ScimEnterpriseUser() {
|
||||
schemas =new HashSet<String>();
|
||||
schemas.add(ScimUser.SCHEMA);
|
||||
schemas.add(SCHEMA);
|
||||
}
|
||||
|
||||
public ScimEnterprise getEnterprise() {
|
||||
return enterprise;
|
||||
}
|
||||
|
||||
public void setEnterprise(ScimEnterprise enterprise) {
|
||||
this.enterprise = enterprise;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ScimFormattedName implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 2482724471550531523L;
|
||||
private String formatted;
|
||||
private String familyName;
|
||||
private String givenName;
|
||||
private String middleName;
|
||||
private String honorificPrefix;
|
||||
private String honorificSuffix;
|
||||
public String getFormatted() {
|
||||
return formatted;
|
||||
}
|
||||
public void setFormatted(String formatted) {
|
||||
this.formatted = formatted;
|
||||
}
|
||||
public String getFamilyName() {
|
||||
return familyName;
|
||||
}
|
||||
public void setFamilyName(String familyName) {
|
||||
this.familyName = familyName;
|
||||
}
|
||||
public String getGivenName() {
|
||||
return givenName;
|
||||
}
|
||||
public void setGivenName(String givenName) {
|
||||
this.givenName = givenName;
|
||||
}
|
||||
public String getMiddleName() {
|
||||
return middleName;
|
||||
}
|
||||
public void setMiddleName(String middleName) {
|
||||
this.middleName = middleName;
|
||||
}
|
||||
public String getHonorificPrefix() {
|
||||
return honorificPrefix;
|
||||
}
|
||||
public void setHonorificPrefix(String honorificPrefix) {
|
||||
this.honorificPrefix = honorificPrefix;
|
||||
}
|
||||
public String getHonorificSuffix() {
|
||||
return honorificSuffix;
|
||||
}
|
||||
public void setHonorificSuffix(String honorificSuffix) {
|
||||
this.honorificSuffix = honorificSuffix;
|
||||
}
|
||||
public ScimFormattedName(String formatted, String familyName, String givenName, String middleName, String honorificPrefix,
|
||||
String honorificSuffix) {
|
||||
super();
|
||||
this.formatted = formatted;
|
||||
this.familyName = familyName;
|
||||
this.givenName = givenName;
|
||||
this.middleName = middleName;
|
||||
this.honorificPrefix = honorificPrefix;
|
||||
this.honorificSuffix = honorificSuffix;
|
||||
}
|
||||
public ScimFormattedName() {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class ScimGroup extends ScimResource{
|
||||
private static final long serialVersionUID = 404613567384513866L;
|
||||
|
||||
public static final String SCHEMA = "urn:ietf:params:scim:schemas:core:2.0:Group";
|
||||
|
||||
private String displayName;
|
||||
private Set<ScimMemberRef> members;
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
public Set<ScimMemberRef> getMembers() {
|
||||
return members;
|
||||
}
|
||||
public void setMembers(Set<ScimMemberRef> members) {
|
||||
this.members = members;
|
||||
}
|
||||
|
||||
public ScimGroup() {
|
||||
schemas =new HashSet<String>();
|
||||
schemas.add(SCHEMA);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
public class ScimGroupRef extends ScimMultiValuedAttribute{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 7069453283024141999L;
|
||||
|
||||
public ScimGroupRef() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ScimGroupRef(String value,String display) {
|
||||
super();
|
||||
this.value = value;
|
||||
this.display = display;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
public class ScimManager {
|
||||
|
||||
private String managerId;
|
||||
private String displayName;
|
||||
public String getManagerId() {
|
||||
return managerId;
|
||||
}
|
||||
public void setManagerId(String managerId) {
|
||||
this.managerId = managerId;
|
||||
}
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
public ScimManager() {
|
||||
}
|
||||
public ScimManager(String managerId, String displayName) {
|
||||
super();
|
||||
this.managerId = managerId;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
public class ScimMemberRef extends ScimMultiValuedAttribute{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -6018893424394625889L;
|
||||
|
||||
public ScimMemberRef() {
|
||||
}
|
||||
|
||||
public ScimMemberRef(String display,String value) {
|
||||
this.display = display;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import org.maxkey.json.*;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
|
||||
public class ScimMeta implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -2244662962968933591L;
|
||||
|
||||
private String resourceType;
|
||||
|
||||
@JsonSerialize(using = JsonISODateSerializer.class)
|
||||
@JsonDeserialize(using = JsonISODateDeserializer.class)
|
||||
private Date created;
|
||||
|
||||
@JsonSerialize(using = JsonISODateSerializer.class)
|
||||
@JsonDeserialize(using = JsonISODateDeserializer.class)
|
||||
|
||||
private Date lastModified;
|
||||
|
||||
private String location;
|
||||
|
||||
private String version;
|
||||
|
||||
private Set<String> attributes;
|
||||
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
public Date getLastModified() {
|
||||
return lastModified;
|
||||
}
|
||||
public void setLastModified(Date lastModified) {
|
||||
this.lastModified = lastModified;
|
||||
}
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
public Set<String> getAttributes() {
|
||||
return attributes;
|
||||
}
|
||||
public void setAttributes(Set<String> attributes) {
|
||||
this.attributes = attributes;
|
||||
}
|
||||
public String getResourceType() {
|
||||
return resourceType;
|
||||
}
|
||||
public void setResourceType(String resourceType) {
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
public ScimMeta() {
|
||||
|
||||
}
|
||||
|
||||
public ScimMeta(String resourceType) {
|
||||
this.resourceType = resourceType;
|
||||
this.version = "1.0";
|
||||
}
|
||||
|
||||
public ScimMeta(String resourceType, Date created, Date lastModified, String location, String version,
|
||||
Set<String> attributes) {
|
||||
super();
|
||||
this.resourceType = resourceType;
|
||||
this.created = created;
|
||||
this.lastModified = lastModified;
|
||||
this.location = location;
|
||||
this.version = version;
|
||||
this.attributes = attributes;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class ScimMultiValuedAttribute implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6878912593878245947L;
|
||||
|
||||
String value;
|
||||
String display;
|
||||
boolean primary;
|
||||
@JsonProperty("$ref")
|
||||
String reference;
|
||||
String type;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
public String getDisplay() {
|
||||
return display;
|
||||
}
|
||||
public void setDisplay(String display) {
|
||||
this.display = display;
|
||||
}
|
||||
public boolean isPrimary() {
|
||||
return primary;
|
||||
}
|
||||
public void setPrimary(boolean primary) {
|
||||
this.primary = primary;
|
||||
}
|
||||
public String getReference() {
|
||||
return reference;
|
||||
}
|
||||
public void setReference(String reference) {
|
||||
this.reference = reference;
|
||||
}
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,229 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class ScimOrganization extends ScimResource{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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 int level;
|
||||
|
||||
private String division;
|
||||
|
||||
private List<ScimOrganizationAddress> addresses;
|
||||
|
||||
private List<ScimOrganizationEmail> emails;
|
||||
|
||||
private List<ScimOrganizationPhoneNumber> phoneNumbers;
|
||||
|
||||
|
||||
private String sortOrder;
|
||||
|
||||
private String description;
|
||||
|
||||
// T/IDAC 002—2021
|
||||
private String displayName; //name
|
||||
private long order; //sortOrder
|
||||
private String parent; //parentId
|
||||
private String parentCode; //parent code
|
||||
|
||||
|
||||
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 int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(int 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<ScimOrganizationAddress> getAddresses() {
|
||||
return addresses;
|
||||
}
|
||||
|
||||
public void setAddresses(List<ScimOrganizationAddress> addresses) {
|
||||
this.addresses = addresses;
|
||||
}
|
||||
|
||||
public List<ScimOrganizationEmail> getEmails() {
|
||||
return emails;
|
||||
}
|
||||
|
||||
public void setEmails(List<ScimOrganizationEmail> emails) {
|
||||
this.emails = emails;
|
||||
}
|
||||
|
||||
public List<ScimOrganizationPhoneNumber> getPhoneNumbers() {
|
||||
return phoneNumbers;
|
||||
}
|
||||
|
||||
public void setPhoneNumbers(List<ScimOrganizationPhoneNumber> phoneNumbers) {
|
||||
this.phoneNumbers = phoneNumbers;
|
||||
}
|
||||
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public long getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public void setOrder(long order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public String getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setParent(String parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public String getParentCode() {
|
||||
return parentCode;
|
||||
}
|
||||
|
||||
public void setParentCode(String parentCode) {
|
||||
this.parentCode = parentCode;
|
||||
}
|
||||
|
||||
public ScimOrganization() {
|
||||
schemas =new HashSet<String>();
|
||||
schemas.add(SCHEMA);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ScimOrganizationAddress extends ScimMultiValuedAttribute 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 ScimOrganizationAddress() {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ScimOrganizationEmail extends ScimMultiValuedAttribute 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 ScimOrganizationEmail() {
|
||||
}
|
||||
|
||||
public ScimOrganizationEmail(String value, String type, boolean primary) {
|
||||
super();
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
this.primary = primary;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ScimOrganizationPhoneNumber extends ScimMultiValuedAttribute 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";
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
import org.maxkey.mxapis.identity.scim.ScimServiceProviderConfigController;
|
||||
|
||||
public class ScimParameters {
|
||||
int startIndex = 1;
|
||||
int count = ScimServiceProviderConfigController.MAX_RESULTS;
|
||||
String filter;
|
||||
String sortBy;
|
||||
String sortOrder = "ascending";
|
||||
String attributes;
|
||||
|
||||
public ScimParameters() {
|
||||
}
|
||||
|
||||
public void parse() {
|
||||
if(startIndex == -1) {
|
||||
count = ScimServiceProviderConfigController.MAX_RESULTS_LIMIT;
|
||||
}
|
||||
|
||||
if(startIndex <= 0) {
|
||||
startIndex = 1;
|
||||
}
|
||||
|
||||
if(count > ScimServiceProviderConfigController.MAX_RESULTS
|
||||
&& count != ScimServiceProviderConfigController.MAX_RESULTS_LIMIT) {
|
||||
count = ScimServiceProviderConfigController.MAX_RESULTS;
|
||||
}
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public int getStartIndex() {
|
||||
return startIndex;
|
||||
}
|
||||
|
||||
public void setStartIndex(int startIndex) {
|
||||
this.startIndex = startIndex;
|
||||
}
|
||||
|
||||
public String getfilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
public void setfilter(String filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
public String getSortBy() {
|
||||
return sortBy;
|
||||
}
|
||||
|
||||
public void setSortBy(String sortBy) {
|
||||
this.sortBy = sortBy;
|
||||
}
|
||||
|
||||
public String getSortOrder() {
|
||||
return sortOrder;
|
||||
}
|
||||
|
||||
public void setSortOrder(String sortOrder) {
|
||||
this.sortOrder = sortOrder;
|
||||
}
|
||||
|
||||
public String getAttributes() {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
public void setAttributes(String attributes) {
|
||||
this.attributes = attributes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ScimParameters [count=" + count + ", startIndex=" + startIndex + ", filter=" + filter + ", sortBy="
|
||||
+ sortBy + ", sortOrder=" + sortOrder + ", attributes=" + attributes + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
|
||||
public class ScimResource implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -5159743553948621024L;
|
||||
protected Set<String> schemas;
|
||||
private String id;
|
||||
private String externalId;
|
||||
private ScimMeta meta;
|
||||
|
||||
public ScimResource() {
|
||||
|
||||
}
|
||||
public ScimResource(String id, String externalId, ScimMeta meta, Set<String> schemas) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.externalId = externalId;
|
||||
this.meta = meta;
|
||||
this.schemas = schemas;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getExternalId() {
|
||||
return externalId;
|
||||
}
|
||||
public void setExternalId(String externalId) {
|
||||
this.externalId = externalId;
|
||||
}
|
||||
public ScimMeta getMeta() {
|
||||
return meta;
|
||||
}
|
||||
public void setMeta(ScimMeta meta) {
|
||||
this.meta = meta;
|
||||
}
|
||||
public Set<String> getSchemas() {
|
||||
return schemas;
|
||||
}
|
||||
public void setSchemas(Set<String> schemas) {
|
||||
this.schemas = schemas;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class ScimSearchResult <T>{
|
||||
|
||||
public static class Constants{
|
||||
public static final String FILTER = "filter";
|
||||
public static final String SORTBY = "sortBy";
|
||||
public static final String COUNT = "count";
|
||||
public static final String STARTINDEX = "startIndex";
|
||||
|
||||
|
||||
}
|
||||
public static final String SCHEMA = "urn:ietf:params:scim:api:messages:2.0:ListResponse";
|
||||
public static final int MAX_RESULTS = 100;
|
||||
private long totalResults;
|
||||
private long itemsPerPage;
|
||||
private long startIndex;
|
||||
private Set<String> schemas = new HashSet<>(Collections.singletonList(SCHEMA));
|
||||
|
||||
@JsonProperty("Resources")
|
||||
private List<T> resources = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Default constructor for Jackson
|
||||
*/
|
||||
ScimSearchResult() {
|
||||
}
|
||||
|
||||
public ScimSearchResult(List<T> resources, long totalResults, long itemsPerPage, long startIndex) {
|
||||
this.resources = resources;
|
||||
this.totalResults = totalResults;
|
||||
this.itemsPerPage = itemsPerPage;
|
||||
this.startIndex = startIndex;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gets a list of found {@link ScimUser}s or {@link ScimGroup}s
|
||||
*
|
||||
* @return a list of found resources
|
||||
*/
|
||||
@JsonProperty("Resources")
|
||||
public List<T> getResources() {
|
||||
return resources;
|
||||
}
|
||||
|
||||
/**
|
||||
* The total number of results returned by the list or query operation. This may not be equal to the number of
|
||||
* elements in the Resources attribute of the list response if pagination is requested.
|
||||
*
|
||||
* @return the total result
|
||||
*/
|
||||
public long getTotalResults() {
|
||||
return totalResults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the schemas of the search result
|
||||
*
|
||||
* @return the search result schemas
|
||||
*/
|
||||
public Set<String> getSchemas() {
|
||||
return schemas;
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of Resources returned in a list response page.
|
||||
*
|
||||
* @return items per page
|
||||
*/
|
||||
public long getItemsPerPage() {
|
||||
return itemsPerPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* The 1-based index of the first result in the current set of list results.
|
||||
*
|
||||
* @return the start index of the actual page
|
||||
*/
|
||||
public long getStartIndex() {
|
||||
return startIndex;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class ScimUser extends ScimResource{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7478787809774041557L;
|
||||
|
||||
public static final String SCHEMA = "urn:ietf:params:scim:schemas:core:2.0:User";
|
||||
|
||||
public static final String SCHEMA_ENTERPRISE = "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User";
|
||||
|
||||
private String userName;
|
||||
private ScimFormattedName name;
|
||||
private String displayName;
|
||||
private String nickName;
|
||||
private String profileUrl;
|
||||
private String title;
|
||||
private String userType;
|
||||
private String preferredLanguage;
|
||||
private String locale;
|
||||
private String timezone;
|
||||
private Boolean active;
|
||||
private String password;
|
||||
|
||||
private List<ScimUserEmail> emails;
|
||||
|
||||
private List<ScimUserPhoneNumber> phoneNumbers;
|
||||
|
||||
@JsonProperty(SCHEMA_ENTERPRISE)
|
||||
ScimEnterprise enterprise;
|
||||
|
||||
private List<ScimUserIm> ims;
|
||||
|
||||
private List<ScimUserPhoto> photos;
|
||||
// Can't really validate that one. value is not acessible
|
||||
private List<ScimUserAddress> addresses;
|
||||
|
||||
private List<ScimGroupRef> groups;
|
||||
|
||||
private List<ScimUserEntitlement> entitlements;
|
||||
|
||||
private List<ScimUserRole> roles;
|
||||
|
||||
private List<ScimUserX509Certificate> x509Certificates;
|
||||
private Map<String, ScimUserExtension> extensions;
|
||||
|
||||
// T/IDAC 002—2021
|
||||
private List<String> organization;
|
||||
private List<String> group;
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
public ScimFormattedName getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(ScimFormattedName name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
public String getNickName() {
|
||||
return nickName;
|
||||
}
|
||||
public void setNickName(String nickName) {
|
||||
this.nickName = nickName;
|
||||
}
|
||||
public String getProfileUrl() {
|
||||
return profileUrl;
|
||||
}
|
||||
public void setProfileUrl(String profileUrl) {
|
||||
this.profileUrl = profileUrl;
|
||||
}
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
public String getUserType() {
|
||||
return userType;
|
||||
}
|
||||
public void setUserType(String userType) {
|
||||
this.userType = userType;
|
||||
}
|
||||
public String getPreferredLanguage() {
|
||||
return preferredLanguage;
|
||||
}
|
||||
public void setPreferredLanguage(String preferredLanguage) {
|
||||
this.preferredLanguage = preferredLanguage;
|
||||
}
|
||||
public String getLocale() {
|
||||
return locale;
|
||||
}
|
||||
public void setLocale(String locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
public String getTimezone() {
|
||||
return timezone;
|
||||
}
|
||||
public void setTimezone(String timezone) {
|
||||
this.timezone = timezone;
|
||||
}
|
||||
public Boolean getActive() {
|
||||
return active;
|
||||
}
|
||||
public void setActive(Boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
public List<ScimUserEmail> getEmails() {
|
||||
return emails;
|
||||
}
|
||||
public void setEmails(List<ScimUserEmail> emails) {
|
||||
this.emails = emails;
|
||||
}
|
||||
public List<ScimUserPhoneNumber> getPhoneNumbers() {
|
||||
return phoneNumbers;
|
||||
}
|
||||
public void setPhoneNumbers(List<ScimUserPhoneNumber> phoneNumbers) {
|
||||
this.phoneNumbers = phoneNumbers;
|
||||
}
|
||||
public List<ScimUserIm> getIms() {
|
||||
return ims;
|
||||
}
|
||||
public void setIms(List<ScimUserIm> ims) {
|
||||
this.ims = ims;
|
||||
}
|
||||
public List<ScimUserPhoto> getPhotos() {
|
||||
return photos;
|
||||
}
|
||||
public void setPhotos(List<ScimUserPhoto> photos) {
|
||||
this.photos = photos;
|
||||
}
|
||||
public List<ScimUserAddress> getAddresses() {
|
||||
return addresses;
|
||||
}
|
||||
public void setAddresses(List<ScimUserAddress> addresses) {
|
||||
this.addresses = addresses;
|
||||
}
|
||||
public List<ScimGroupRef> getGroups() {
|
||||
return groups;
|
||||
}
|
||||
public void setGroups(List<ScimGroupRef> groups) {
|
||||
this.groups = groups;
|
||||
}
|
||||
public List<ScimUserEntitlement> getEntitlements() {
|
||||
return entitlements;
|
||||
}
|
||||
public void setEntitlements(List<ScimUserEntitlement> entitlements) {
|
||||
this.entitlements = entitlements;
|
||||
}
|
||||
public List<ScimUserRole> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
public void setRoles(List<ScimUserRole> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
public List<ScimUserX509Certificate> getX509Certificates() {
|
||||
return x509Certificates;
|
||||
}
|
||||
public void setX509Certificates(List<ScimUserX509Certificate> x509Certificates) {
|
||||
this.x509Certificates = x509Certificates;
|
||||
}
|
||||
public Map<String, ScimUserExtension> getExtensions() {
|
||||
return extensions;
|
||||
}
|
||||
public void setExtensions(Map<String, ScimUserExtension> extensions) {
|
||||
this.extensions = extensions;
|
||||
}
|
||||
|
||||
|
||||
public ScimEnterprise getEnterprise() {
|
||||
return enterprise;
|
||||
}
|
||||
public void setEnterprise(ScimEnterprise enterprise) {
|
||||
this.enterprise = enterprise;
|
||||
}
|
||||
|
||||
public List<String> getOrganization() {
|
||||
return organization;
|
||||
}
|
||||
public void setOrganization(List<String> organization) {
|
||||
this.organization = organization;
|
||||
}
|
||||
public List<String> getGroup() {
|
||||
return group;
|
||||
}
|
||||
public void setGroup(List<String> group) {
|
||||
this.group = group;
|
||||
}
|
||||
public ScimUser() {
|
||||
schemas =new HashSet<String>();
|
||||
schemas.add(SCHEMA);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ScimUserAddress extends ScimMultiValuedAttribute 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 ScimUserAddress() {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ScimUserEmail extends ScimMultiValuedAttribute 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 ScimUserEmail() {
|
||||
}
|
||||
|
||||
public ScimUserEmail(String value, String type, boolean primary) {
|
||||
super();
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
this.primary = primary;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ScimUserEntitlement extends ScimMultiValuedAttribute implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -2401447261875608884L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ScimUserExtension extends ScimMultiValuedAttribute implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -451036186931007428L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ScimUserIm extends ScimMultiValuedAttribute implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -529297556948872883L;
|
||||
|
||||
public static class UserImType {
|
||||
public static final String AIM = "aim";
|
||||
public static final String GTALK = "gtalk";
|
||||
public static final String ICQ = "icq";
|
||||
public static final String XMPP = "xmpp";
|
||||
public static final String MSN = "msn";
|
||||
public static final String SKYPE = "skype";
|
||||
public static final String QQ = "qq";
|
||||
public static final String YAHOO = "yahoo";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ScimUserOrganization extends ScimMultiValuedAttribute implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 3201987266085144715L;
|
||||
|
||||
public ScimUserOrganization() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ScimUserOrganization(String value, String display, boolean primary) {
|
||||
super();
|
||||
this.value = value;
|
||||
this.display = display;
|
||||
this.primary = primary;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ScimUserPhoneNumber extends ScimMultiValuedAttribute 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";
|
||||
|
||||
}
|
||||
|
||||
public ScimUserPhoneNumber() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ScimUserPhoneNumber(String value, String type, boolean primary) {
|
||||
super();
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
this.primary = primary;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ScimUserPhoto extends ScimMultiValuedAttribute implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3796708555581889691L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ScimUserRole extends ScimMultiValuedAttribute implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 4482653235751625445L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.mxapis.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ScimUserX509Certificate extends ScimMultiValuedAttribute implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -5988790799054211553L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.identity.scim.resources;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
public class ReadJson2String {
|
||||
|
||||
public static String read(String jsonFileName) {
|
||||
try {
|
||||
List<String> list = FileUtils.readLines(new File(ReadJson2String.class.getResource(jsonFileName).getFile()),"UTF-8");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String ss : list) {
|
||||
sb.append(ss);
|
||||
}
|
||||
System.out.println(sb.toString());
|
||||
return sb.toString();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"schemas": [
|
||||
"urn:ietf:params:scim:schemas:core:2.0:User",
|
||||
"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"
|
||||
],
|
||||
"id": "1111111111111",
|
||||
"externalId": "UserName",
|
||||
"meta": {
|
||||
"resourceType": "User",
|
||||
"created": "2020-06-15T23:06:00.129Z",
|
||||
"lastModified": "2020-06-15T23:06:00.129Z",
|
||||
"location": "https://example.com/v2/Users/2819c223...",
|
||||
"version": "W\\/\"f250dd84f0671c3\""
|
||||
},
|
||||
"userName": "UserName",
|
||||
"name": {
|
||||
"formatted": "Ms. Barbara J Jensen, III",
|
||||
"familyName": "Jensen",
|
||||
"givenName": "Barbara",
|
||||
"middleName": "Jane",
|
||||
"honorificPrefix": "Ms.",
|
||||
"honorificSuffix": "III"
|
||||
},
|
||||
"emails": [
|
||||
{
|
||||
"value": "bjensen@example.com",
|
||||
"primary": false,
|
||||
"type": "work"
|
||||
}
|
||||
],
|
||||
"phoneNumbers": [
|
||||
{
|
||||
"value": "555-555-8377",
|
||||
"primary": false,
|
||||
"type": "home"
|
||||
},
|
||||
{
|
||||
"value": "555-555-8377",
|
||||
"primary": false,
|
||||
"type": "work"
|
||||
}
|
||||
],
|
||||
"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": {
|
||||
"employeeNumber": "k200908",
|
||||
"costCenter": "1111",
|
||||
"department": "de"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.identity.scim.resources;
|
||||
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimEnterpriseUser;
|
||||
import org.maxkey.pretty.impl.JsonPretty;
|
||||
import org.maxkey.util.JsonUtils;
|
||||
|
||||
public class ScimEnterpriseUserJsonString2ObjectTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
String userJsonString = ReadJson2String.read("ScimEnterpriseUserJsonString.json");
|
||||
ScimEnterpriseUser u = JsonUtils.stringToObject(userJsonString, ScimEnterpriseUser.class);
|
||||
|
||||
System.out.println(
|
||||
(new JsonPretty()).format(JsonUtils.toString(u)));
|
||||
System.out.println(u.getEnterprise().getCostCenter());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.identity.scim.resources;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimEnterprise;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimEnterpriseUser;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimFormattedName;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimMeta;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimUserEmail;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimUserPhoneNumber;
|
||||
import org.maxkey.pretty.impl.JsonPretty;
|
||||
import org.maxkey.util.JsonUtils;
|
||||
|
||||
public class ScimEnterpriseUserJsonTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
ScimEnterpriseUser u = new ScimEnterpriseUser();
|
||||
u.setUserName("UserName");
|
||||
u.setExternalId("UserName");
|
||||
u.setId("1111111111111");
|
||||
|
||||
ScimMeta meta = new ScimMeta();
|
||||
meta.setVersion("W\\/\"f250dd84f0671c3\"");
|
||||
meta.setCreated(new Date());
|
||||
meta.setLocation("https://example.com/v2/Users/2819c223...");
|
||||
meta.setResourceType("User");
|
||||
meta.setLastModified(new Date());
|
||||
u.setMeta(meta);
|
||||
|
||||
ScimFormattedName un=new ScimFormattedName();
|
||||
un.setFamilyName("Jensen");
|
||||
un.setFormatted("Ms. Barbara J Jensen, III");
|
||||
un.setGivenName("Barbara");
|
||||
un.setHonorificPrefix("Ms.");
|
||||
un.setHonorificSuffix("III");
|
||||
un.setMiddleName("Jane");
|
||||
u.setName(un);
|
||||
|
||||
List<ScimUserPhoneNumber> UserPhoneNumberList = new ArrayList<ScimUserPhoneNumber>();
|
||||
ScimUserPhoneNumber pn =new ScimUserPhoneNumber();
|
||||
pn.setValue("555-555-8377");
|
||||
pn.setType(ScimUserPhoneNumber.UserPhoneNumberType.WORK);
|
||||
|
||||
ScimUserPhoneNumber pnh =new ScimUserPhoneNumber();
|
||||
pnh.setValue("555-555-8377");
|
||||
pnh.setType(ScimUserPhoneNumber.UserPhoneNumberType.HOME);
|
||||
UserPhoneNumberList.add(pnh);
|
||||
|
||||
UserPhoneNumberList.add(pn);
|
||||
|
||||
u.setPhoneNumbers(UserPhoneNumberList);
|
||||
|
||||
List<ScimUserEmail> ueList = new ArrayList<ScimUserEmail>();
|
||||
ScimUserEmail ue =new ScimUserEmail();
|
||||
ue.setValue("bjensen@example.com");
|
||||
ue.setType(ScimUserEmail.UserEmailType.WORK);
|
||||
ueList.add(ue);
|
||||
u.setEmails(ueList);
|
||||
|
||||
ScimEnterprise ent =new ScimEnterprise();
|
||||
ent.setCostCenter("1111");
|
||||
ent.setDepartment("de");
|
||||
ent.setEmployeeNumber("k200908");
|
||||
u.setEnterprise(ent);
|
||||
|
||||
System.out.println(
|
||||
(new JsonPretty()).format(JsonUtils.toString(u)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"schemas": [
|
||||
"urn:ietf:params:scim:schemas:core:2.0:Group"
|
||||
],
|
||||
"meta": {
|
||||
"resourceType": "User",
|
||||
"created": "2020-06-15T23:08:50.698Z",
|
||||
"lastModified": "2020-06-15T23:08:50.698Z",
|
||||
"location": "https://example.com/v2/Users/2819c223...",
|
||||
"version": "W\\/\"f250dd84f0671c3\""
|
||||
},
|
||||
"displayName": "Tour Guides",
|
||||
"members": [
|
||||
{
|
||||
"value": "2819c223-7f76-453a-919d-413861904646",
|
||||
"display": "Babs Jensen",
|
||||
"primary": false,
|
||||
"$ref": "https://example.com/v2/Users/2819c223-7f76-453a-919d-413861904646"
|
||||
},
|
||||
{
|
||||
"value": "2819c223-7f76-453a-919d-413861904646",
|
||||
"display": "Babs Jensen",
|
||||
"primary": false,
|
||||
"$ref": "https://example.com/v2/Users/2819c223-7f76-453a-919d-413861904646"
|
||||
},
|
||||
{
|
||||
"value": "2819c223-7f76-453a-919d-413861904646",
|
||||
"display": "Babs Jensen",
|
||||
"primary": false,
|
||||
"$ref": "https://example.com/v2/Users/2819c223-7f76-453a-919d-413861904646"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.identity.scim.resources;
|
||||
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimGroup;
|
||||
import org.maxkey.pretty.impl.JsonPretty;
|
||||
import org.maxkey.util.JsonUtils;
|
||||
|
||||
public class ScimGroupJsonString2ObjectTest {
|
||||
public static void main(String[] args) {
|
||||
String userJsonString = ReadJson2String.read("ScimGroupJsonString.json");
|
||||
ScimGroup g = JsonUtils.stringToObject(userJsonString, ScimGroup.class);
|
||||
|
||||
|
||||
System.out.println(
|
||||
(new JsonPretty()).format(JsonUtils.toString(g)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.identity.scim.resources;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimGroup;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimMemberRef;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimMeta;
|
||||
import org.maxkey.pretty.impl.JsonPretty;
|
||||
import org.maxkey.util.JsonUtils;
|
||||
|
||||
public class ScimGroupJsonTest {
|
||||
public static void main(String[] args) {
|
||||
ScimGroup g= new ScimGroup();
|
||||
|
||||
ScimMeta meta = new ScimMeta();
|
||||
meta.setVersion("W\\/\"f250dd84f0671c3\"");
|
||||
meta.setCreated(new Date());
|
||||
meta.setLocation("https://example.com/v2/Users/2819c223...");
|
||||
meta.setResourceType("User");
|
||||
meta.setLastModified(new Date());
|
||||
g.setMeta(meta);
|
||||
|
||||
g.setDisplayName("Tour Guides");
|
||||
|
||||
Set<ScimMemberRef> mrSet =new HashSet<ScimMemberRef>();
|
||||
ScimMemberRef mr1 =new ScimMemberRef();
|
||||
mr1.setReference("https://example.com/v2/Users/2819c223-7f76-453a-919d-413861904646");
|
||||
mr1.setValue("2819c223-7f76-453a-919d-413861904646");
|
||||
mr1.setDisplay("Babs Jensen");
|
||||
ScimMemberRef mr2 =new ScimMemberRef();
|
||||
mr2.setReference("https://example.com/v2/Users/2819c223-7f76-453a-919d-413861904646");
|
||||
mr2.setValue("2819c223-7f76-453a-919d-413861904646");
|
||||
mr2.setDisplay("Babs Jensen");
|
||||
ScimMemberRef mr3 =new ScimMemberRef();
|
||||
mr3.setReference("https://example.com/v2/Users/2819c223-7f76-453a-919d-413861904646");
|
||||
mr3.setValue("2819c223-7f76-453a-919d-413861904646");
|
||||
mr3.setDisplay("Babs Jensen");
|
||||
mrSet.add(mr1);
|
||||
mrSet.add(mr2);
|
||||
mrSet.add(mr3);
|
||||
|
||||
g.setMembers(mrSet);
|
||||
|
||||
System.out.println(
|
||||
(new JsonPretty()).format(JsonUtils.toString(g)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"schemas": [
|
||||
"urn:ietf:params:scim:schemas:core:2.0:User"
|
||||
],
|
||||
"id": "1111111111111",
|
||||
"externalId": "UserName",
|
||||
"meta": {
|
||||
"resourceType": "User",
|
||||
"created": "2020-06-15T23:09:30.763Z",
|
||||
"lastModified": "2020-06-15T23:09:30.763Z",
|
||||
"location": "https://example.com/v2/Users/2819c223...",
|
||||
"version": "W\\/\"f250dd84f0671c3\""
|
||||
},
|
||||
"userName": "UserName",
|
||||
"name": {
|
||||
"formatted": "Ms. Barbara J Jensen, III",
|
||||
"familyName": "Jensen",
|
||||
"givenName": "Barbara",
|
||||
"middleName": "Jane",
|
||||
"honorificPrefix": "Ms.",
|
||||
"honorificSuffix": "III"
|
||||
},
|
||||
"emails": [
|
||||
{
|
||||
"value": "bjensen@example.com",
|
||||
"primary": false,
|
||||
"type": "work"
|
||||
}
|
||||
],
|
||||
"phoneNumbers": [
|
||||
{
|
||||
"value": "555-555-8377",
|
||||
"primary": false,
|
||||
"type": "home"
|
||||
},
|
||||
{
|
||||
"value": "555-555-8377",
|
||||
"primary": false,
|
||||
"type": "work"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.identity.scim.resources;
|
||||
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimUser;
|
||||
import org.maxkey.pretty.impl.JsonPretty;
|
||||
import org.maxkey.util.JsonUtils;
|
||||
|
||||
public class ScimUserJsonString2ObjectTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
String userJsonString = ReadJson2String.read("ScimUserJsonString.json");
|
||||
ScimUser u = JsonUtils.stringToObject(userJsonString, ScimUser.class);
|
||||
System.out.println(
|
||||
(new JsonPretty()).format(JsonUtils.toString(u)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed 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.maxkey.identity.scim.resources;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimFormattedName;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimMeta;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimUser;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimUserEmail;
|
||||
import org.maxkey.mxapis.identity.scim.resources.ScimUserPhoneNumber;
|
||||
import org.maxkey.pretty.impl.JsonPretty;
|
||||
import org.maxkey.util.JsonUtils;
|
||||
|
||||
public class ScimUserJsonTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ScimUser u = new ScimUser();
|
||||
u.setUserName("UserName");
|
||||
u.setExternalId("UserName");
|
||||
u.setId("1111111111111");
|
||||
|
||||
ScimMeta meta = new ScimMeta();
|
||||
meta.setVersion("W\\/\"f250dd84f0671c3\"");
|
||||
meta.setCreated(new Date());
|
||||
meta.setLocation("https://example.com/v2/Users/2819c223...");
|
||||
meta.setResourceType("User");
|
||||
meta.setLastModified(new Date());
|
||||
u.setMeta(meta);
|
||||
|
||||
ScimFormattedName un=new ScimFormattedName();
|
||||
un.setFamilyName("Jensen");
|
||||
un.setFormatted("Ms. Barbara J Jensen, III");
|
||||
un.setGivenName("Barbara");
|
||||
un.setHonorificPrefix("Ms.");
|
||||
un.setHonorificSuffix("III");
|
||||
un.setMiddleName("Jane");
|
||||
u.setName(un);
|
||||
|
||||
List<ScimUserPhoneNumber> UserPhoneNumberList = new ArrayList<ScimUserPhoneNumber>();
|
||||
ScimUserPhoneNumber pn =new ScimUserPhoneNumber();
|
||||
pn.setValue("555-555-8377");
|
||||
pn.setType(ScimUserPhoneNumber.UserPhoneNumberType.WORK);
|
||||
|
||||
ScimUserPhoneNumber pnh =new ScimUserPhoneNumber();
|
||||
pnh.setValue("555-555-8377");
|
||||
pnh.setType(ScimUserPhoneNumber.UserPhoneNumberType.HOME);
|
||||
UserPhoneNumberList.add(pnh);
|
||||
|
||||
UserPhoneNumberList.add(pn);
|
||||
|
||||
u.setPhoneNumbers(UserPhoneNumberList);
|
||||
|
||||
List<ScimUserEmail> ueList = new ArrayList<ScimUserEmail>();
|
||||
ScimUserEmail ue =new ScimUserEmail();
|
||||
ue.setValue("bjensen@example.com");
|
||||
ue.setType(ScimUserEmail.UserEmailType.WORK);
|
||||
ueList.add(ue);
|
||||
u.setEmails(ueList);
|
||||
|
||||
System.out.println(
|
||||
(new JsonPretty()).format(JsonUtils.toString(u)));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user