mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-07 01:18:27 +08:00
SCIM optimize
This commit is contained in:
parent
681906e02a
commit
2cd04e788f
@ -43,6 +43,7 @@ public class Organizations extends JpaBaseEntity implements Serializable {
|
||||
private String fullName;
|
||||
@Column
|
||||
private String parentId;
|
||||
private String parentCode;
|
||||
@Column
|
||||
private String parentName;
|
||||
@Column
|
||||
@ -85,6 +86,14 @@ public class Organizations extends JpaBaseEntity implements Serializable {
|
||||
private String description;
|
||||
@Column
|
||||
private int status;
|
||||
@Column
|
||||
String createdBy;
|
||||
@Column
|
||||
String createdDate;
|
||||
@Column
|
||||
String modifiedBy;
|
||||
@Column
|
||||
String modifiedDate;
|
||||
|
||||
private int isPrimary = 0;
|
||||
|
||||
@ -136,7 +145,15 @@ public class Organizations extends JpaBaseEntity implements Serializable {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public String getParentName() {
|
||||
public String getParentCode() {
|
||||
return parentCode;
|
||||
}
|
||||
|
||||
public void setParentCode(String parentCode) {
|
||||
this.parentCode = parentCode;
|
||||
}
|
||||
|
||||
public String getParentName() {
|
||||
return parentName;
|
||||
}
|
||||
|
||||
@ -322,7 +339,39 @@ public class Organizations extends JpaBaseEntity implements Serializable {
|
||||
this.reorgNamePath = reorgNamePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCreatedBy() {
|
||||
return createdBy;
|
||||
}
|
||||
|
||||
public void setCreatedBy(String createdBy) {
|
||||
this.createdBy = createdBy;
|
||||
}
|
||||
|
||||
public String getCreatedDate() {
|
||||
return createdDate;
|
||||
}
|
||||
|
||||
public void setCreatedDate(String createdDate) {
|
||||
this.createdDate = createdDate;
|
||||
}
|
||||
|
||||
public String getModifiedBy() {
|
||||
return modifiedBy;
|
||||
}
|
||||
|
||||
public void setModifiedBy(String modifiedBy) {
|
||||
this.modifiedBy = modifiedBy;
|
||||
}
|
||||
|
||||
public String getModifiedDate() {
|
||||
return modifiedDate;
|
||||
}
|
||||
|
||||
public void setModifiedDate(String modifiedDate) {
|
||||
this.modifiedDate = modifiedDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("Organizations [id=");
|
||||
|
||||
@ -34,7 +34,7 @@ import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(value={"/im/api/Organization"})
|
||||
@RequestMapping(value={"/api/idm/Organization"})
|
||||
public class RestOrganizationController {
|
||||
|
||||
@Autowired
|
||||
|
||||
@ -35,7 +35,7 @@ import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(value={"/im/api/Users"})
|
||||
@RequestMapping(value={"/api/idm/Users"})
|
||||
public class RestUserInfoController {
|
||||
|
||||
@Autowired
|
||||
|
||||
@ -17,9 +17,142 @@
|
||||
|
||||
package org.maxkey.identity.scim.controller;
|
||||
|
||||
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.Groups;
|
||||
import org.maxkey.entity.UserInfo;
|
||||
import org.maxkey.identity.scim.resources.ScimGroup;
|
||||
import org.maxkey.identity.scim.resources.ScimMemberRef;
|
||||
import org.maxkey.identity.scim.resources.ScimMeta;
|
||||
import org.maxkey.identity.scim.resources.ScimParameters;
|
||||
import org.maxkey.identity.scim.resources.ScimSearchResult;
|
||||
import org.maxkey.persistence.service.GroupMemberService;
|
||||
import org.maxkey.persistence.service.GroupsService;
|
||||
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;
|
||||
|
||||
@RequestMapping(value = "/im/scim/v2/Groups")
|
||||
@RestController
|
||||
@RequestMapping(value = "/api/idm/SCIM/v2/Groups")
|
||||
public class ScimGroupController {
|
||||
final static Logger _logger = LoggerFactory.getLogger(ScimGroupController.class);
|
||||
|
||||
@Autowired
|
||||
GroupsService groupsService;
|
||||
|
||||
@Autowired
|
||||
GroupMemberService groupMemberService;
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
public MappingJacksonValue get(@PathVariable String id,
|
||||
@RequestParam(required = false) String attributes) {
|
||||
Groups groups = groupsService.get(id);
|
||||
ScimGroup scimGroup = group2ScimGroup(groups);
|
||||
List<UserInfo> userList = groupMemberService.queryMemberByGroupId(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 {
|
||||
Groups group =scimGroup2Group(scimGroup);
|
||||
groupsService.insert(group);
|
||||
return get(group.getId(),attributes);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
|
||||
public MappingJacksonValue replace(@PathVariable String id,
|
||||
@RequestBody ScimGroup scimGroup,
|
||||
@RequestParam(required = false) String attributes)
|
||||
throws IOException {
|
||||
Groups group =scimGroup2Group(scimGroup);
|
||||
groupsService.update(group);
|
||||
return get(group.getId(),attributes);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public void delete(@PathVariable final String id) {
|
||||
groupsService.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);
|
||||
Groups queryModel = new Groups();
|
||||
queryModel.setPageSize(requestParameters.getCount());
|
||||
queryModel.calculate(requestParameters.getStartIndex());
|
||||
|
||||
JpaPageResults<Groups> orgResults = groupsService.queryPageResults(queryModel);
|
||||
List<ScimGroup> resultList = new ArrayList<ScimGroup>();
|
||||
for(Groups group : orgResults.getRows()) {
|
||||
resultList.add(group2ScimGroup(group));
|
||||
}
|
||||
ScimSearchResult<ScimGroup> scimSearchResult =
|
||||
new ScimSearchResult<ScimGroup>(
|
||||
resultList,
|
||||
orgResults.getRecords(),
|
||||
requestParameters.getCount(),
|
||||
requestParameters.getStartIndex());
|
||||
return new MappingJacksonValue(scimSearchResult);
|
||||
}
|
||||
|
||||
public ScimGroup group2ScimGroup(Groups group) {
|
||||
ScimGroup scimGroup = new ScimGroup();
|
||||
scimGroup.setId(group.getId());
|
||||
scimGroup.setExternalId(group.getId());
|
||||
scimGroup.setDisplayName(group.getName());
|
||||
|
||||
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 Groups scimGroup2Group(ScimGroup scimGroup) {
|
||||
Groups group = new Groups();
|
||||
group.setId(scimGroup.getId());
|
||||
group.setName(scimGroup.getDisplayName());
|
||||
return group;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,14 +18,24 @@
|
||||
package org.maxkey.identity.scim.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.maxkey.identity.scim.resources.Organization;
|
||||
import org.apache.mybatis.jpa.persistence.JpaPageResults;
|
||||
import org.maxkey.entity.Organizations;
|
||||
import org.maxkey.identity.scim.resources.ScimMeta;
|
||||
import org.maxkey.identity.scim.resources.ScimOrganization;
|
||||
import org.maxkey.identity.scim.resources.ScimParameters;
|
||||
import org.maxkey.identity.scim.resources.ScimSearchResult;
|
||||
import org.maxkey.identity.scim.resources.User;
|
||||
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.ResponseEntity;
|
||||
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;
|
||||
@ -45,57 +55,130 @@ import org.springframework.web.util.UriComponentsBuilder;
|
||||
* http://tools.ietf.org/html/draft-ietf-scim-api-00#section-3
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/im/scim/v2/Organization")
|
||||
@RequestMapping(value = "/api/idm/SCIM/v2/Organization")
|
||||
public class ScimOrganizationController {
|
||||
|
||||
final static Logger _logger = LoggerFactory.getLogger(ScimOrganizationController.class);
|
||||
|
||||
@Autowired
|
||||
OrganizationsService organizationsService;
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
public MappingJacksonValue getOrganization(@PathVariable String id,
|
||||
public MappingJacksonValue get(@PathVariable String id,
|
||||
@RequestParam(required = false) String attributes) {
|
||||
//Organization user = null;
|
||||
return null;
|
||||
Organizations org = organizationsService.get(id);
|
||||
ScimOrganization scimOrg = org2ScimOrg(org);
|
||||
|
||||
return new MappingJacksonValue(scimOrg);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
public ResponseEntity<MappingJacksonValue> create(@RequestBody Organization user,
|
||||
@RequestParam(required = false) String attributes,
|
||||
UriComponentsBuilder builder) throws IOException {
|
||||
//Organization createdUser = null;
|
||||
return null;
|
||||
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 ResponseEntity<MappingJacksonValue> replace(@PathVariable String id,
|
||||
@RequestBody Organization user,
|
||||
@RequestParam(required = false) String attributes)
|
||||
throws IOException {
|
||||
//Organization createdUser = null;
|
||||
return null;
|
||||
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) {
|
||||
//tokenService.revokeAllTokensOfUser(id);
|
||||
|
||||
organizationsService.remove(id);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public MappingJacksonValue searchWithGet(@RequestParam Map<String, String> requestParameters) {
|
||||
public MappingJacksonValue searchWithGet(@ModelAttribute ScimParameters requestParameters) {
|
||||
return searchWithPost(requestParameters);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/.search", method = RequestMethod.POST)
|
||||
public MappingJacksonValue searchWithPost(@RequestParam Map<String, String> requestParameters) {
|
||||
//ScimSearchResult<User> scimSearchResult = null;
|
||||
/*
|
||||
requestParameters.get("filter"),
|
||||
requestParameters.get("sortBy"),
|
||||
requestParameters.getOrDefault("sortOrder", "ascending"), // scim default
|
||||
Integer.parseInt(requestParameters.getOrDefault("count", "" + ScimServiceProviderConfigController.MAX_RESULTS)),
|
||||
Integer.parseInt(requestParameters.getOrDefault("startIndex", "1")); // scim default
|
||||
*/
|
||||
//String attributes = (requestParameters.containsKey("attributes") ? requestParameters.get("attributes") : "");
|
||||
public MappingJacksonValue searchWithPost(@ModelAttribute ScimParameters requestParameters) {
|
||||
requestParameters.parse();
|
||||
_logger.debug("requestParameters {} ",requestParameters);
|
||||
Organizations queryModel = new Organizations();
|
||||
queryModel.setPageSize(requestParameters.getCount());
|
||||
queryModel.calculate(requestParameters.getStartIndex());
|
||||
|
||||
return null;
|
||||
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(),
|
||||
requestParameters.getCount(),
|
||||
requestParameters.getStartIndex());
|
||||
|
||||
return new MappingJacksonValue(scimSearchResult);
|
||||
}
|
||||
|
||||
public ScimOrganization org2ScimOrg(Organizations org) {
|
||||
ScimOrganization scimOrg = new ScimOrganization();
|
||||
scimOrg.setId(org.getId());
|
||||
scimOrg.setCode(org.getCode());
|
||||
scimOrg.setName(org.getName());
|
||||
scimOrg.setDisplayName(org.getName());
|
||||
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.setCode(scimOrg.getCode());
|
||||
org.setFullName(scimOrg.getFullName());
|
||||
org.setName(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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,10 +26,11 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/im/scim/v2/ServiceProviderConfig")
|
||||
@RequestMapping(value = "/api/idm/SCIM/v2/ServiceProviderConfig")
|
||||
public class ScimServiceProviderConfigController {
|
||||
|
||||
public static final int MAX_RESULTS = 100;
|
||||
public static final int MAX_RESULTS = 500;
|
||||
public static final int MAX_RESULTS_LIMIT = 5000;
|
||||
|
||||
@RequestMapping
|
||||
@ResponseBody
|
||||
|
||||
@ -18,13 +18,34 @@
|
||||
package org.maxkey.identity.scim.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.mybatis.jpa.persistence.JpaPageResults;
|
||||
import org.maxkey.constants.ConstantsStatus;
|
||||
import org.maxkey.entity.Groups;
|
||||
import org.maxkey.entity.UserInfo;
|
||||
import org.maxkey.identity.scim.resources.ScimEnterprise;
|
||||
import org.maxkey.identity.scim.resources.ScimGroupRef;
|
||||
import org.maxkey.identity.scim.resources.ScimManager;
|
||||
import org.maxkey.identity.scim.resources.ScimMeta;
|
||||
import org.maxkey.identity.scim.resources.ScimParameters;
|
||||
import org.maxkey.identity.scim.resources.ScimSearchResult;
|
||||
import org.maxkey.identity.scim.resources.User;
|
||||
import org.maxkey.identity.scim.resources.ScimOrganizationEmail.UserEmailType;
|
||||
import org.maxkey.identity.scim.resources.ScimOrganizationPhoneNumber.UserPhoneNumberType;
|
||||
import org.maxkey.identity.scim.resources.ScimUser;
|
||||
import org.maxkey.identity.scim.resources.ScimUserEmail;
|
||||
import org.maxkey.identity.scim.resources.ScimFormattedName;
|
||||
import org.maxkey.identity.scim.resources.ScimUserPhoneNumber;
|
||||
import org.maxkey.persistence.service.GroupsService;
|
||||
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.ResponseEntity;
|
||||
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;
|
||||
@ -44,56 +65,170 @@ import org.springframework.web.util.UriComponentsBuilder;
|
||||
* http://tools.ietf.org/html/draft-ietf-scim-api-00#section-3
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/im/scim/v2/Users")
|
||||
@RequestMapping(value = "/api/idm/SCIM/v2/Users")
|
||||
public class ScimUserController {
|
||||
|
||||
final static Logger _logger = LoggerFactory.getLogger(ScimUserController.class);
|
||||
@Autowired
|
||||
private UserInfoService userInfoService;
|
||||
|
||||
@Autowired
|
||||
GroupsService groupsService;
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
public MappingJacksonValue getUser(@PathVariable String id,
|
||||
public MappingJacksonValue get(@PathVariable String id,
|
||||
@RequestParam(required = false) String attributes) {
|
||||
//User user = null;
|
||||
return null;
|
||||
UserInfo userInfo = userInfoService.get(id);
|
||||
ScimUser scimUser = userInfo2ScimUser(userInfo);
|
||||
return new MappingJacksonValue(scimUser);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
public ResponseEntity<MappingJacksonValue> create(@RequestBody User user,
|
||||
@RequestParam(required = false) String attributes,
|
||||
UriComponentsBuilder builder) throws IOException {
|
||||
//User createdUser = null;
|
||||
return null;
|
||||
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 ResponseEntity<MappingJacksonValue> replace(@PathVariable String id,
|
||||
@RequestBody User user,
|
||||
@RequestParam(required = false) String attributes)
|
||||
public MappingJacksonValue replace(@PathVariable String id,
|
||||
@RequestBody ScimUser user,
|
||||
@RequestParam(required = false) String attributes)
|
||||
throws IOException {
|
||||
//User createdUser = null;
|
||||
return null;
|
||||
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) {
|
||||
//tokenService.revokeAllTokensOfUser(id);
|
||||
|
||||
userInfoService.remove(id);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public MappingJacksonValue searchWithGet(@RequestParam Map<String, String> requestParameters) {
|
||||
public MappingJacksonValue searchWithGet(@ModelAttribute ScimParameters requestParameters) {
|
||||
return searchWithPost(requestParameters);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/.search", method = RequestMethod.POST)
|
||||
public MappingJacksonValue searchWithPost(@RequestParam Map<String, String> requestParameters) {
|
||||
//ScimSearchResult<User> scimSearchResult = null;
|
||||
/*
|
||||
requestParameters.get("filter"),
|
||||
requestParameters.get("sortBy"),
|
||||
requestParameters.getOrDefault("sortOrder", "ascending"), // scim default
|
||||
Integer.parseInt(requestParameters.getOrDefault("count", "" + ScimServiceProviderConfigController.MAX_RESULTS)),
|
||||
Integer.parseInt(requestParameters.getOrDefault("startIndex", "1")); // scim default
|
||||
*/
|
||||
//String attributes = (requestParameters.containsKey("attributes") ? requestParameters.get("attributes") : "");
|
||||
return null;
|
||||
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(),
|
||||
requestParameters.getCount(),
|
||||
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(Groups group : groupsService.queryGroupByUserId(userInfo.getId())){
|
||||
groupsList.add(group.getId());
|
||||
groups.add(new ScimGroupRef(group.getId(),group.getName()));
|
||||
|
||||
}
|
||||
scimUser.setGroup(groupsList);
|
||||
scimUser.setGroups(groups);
|
||||
|
||||
scimUser.setTimezone(userInfo.getTimeZone());
|
||||
scimUser.setLocale(userInfo.getLocale());
|
||||
scimUser.setPreferredLanguage(userInfo.getPreferredLanguage());
|
||||
scimUser.setActive(userInfo.getStatus() == ConstantsStatus.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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,15 +19,16 @@ package org.maxkey.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Enterprise implements 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 Manager manager;
|
||||
private ScimManager manager;
|
||||
|
||||
public String getEmployeeNumber() {
|
||||
return employeeNumber;
|
||||
@ -53,19 +54,26 @@ public class Enterprise implements Serializable {
|
||||
public void setDivision(String division) {
|
||||
this.division = division;
|
||||
}
|
||||
public String getDepartment() {
|
||||
|
||||
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 Manager getManager() {
|
||||
public ScimManager getManager() {
|
||||
return manager;
|
||||
}
|
||||
public void setManager(Manager manager) {
|
||||
public void setManager(ScimManager manager) {
|
||||
this.manager = manager;
|
||||
}
|
||||
public Enterprise() {
|
||||
public ScimEnterprise() {
|
||||
}
|
||||
|
||||
|
||||
@ -21,25 +21,25 @@ import java.util.HashSet;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class EnterpriseUser extends User {
|
||||
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)
|
||||
Enterprise enterprise;
|
||||
ScimEnterprise enterprise;
|
||||
|
||||
public EnterpriseUser() {
|
||||
public ScimEnterpriseUser() {
|
||||
schemas =new HashSet<String>();
|
||||
schemas.add(User.SCHEMA);
|
||||
schemas.add(ScimUser.SCHEMA);
|
||||
schemas.add(SCHEMA);
|
||||
}
|
||||
|
||||
public Enterprise getEnterprise() {
|
||||
public ScimEnterprise getEnterprise() {
|
||||
return enterprise;
|
||||
}
|
||||
|
||||
public void setEnterprise(Enterprise enterprise) {
|
||||
public void setEnterprise(ScimEnterprise enterprise) {
|
||||
this.enterprise = enterprise;
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ package org.maxkey.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class UserName implements Serializable {
|
||||
public class ScimFormattedName implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
@ -67,7 +67,7 @@ public class UserName implements Serializable {
|
||||
public void setHonorificSuffix(String honorificSuffix) {
|
||||
this.honorificSuffix = honorificSuffix;
|
||||
}
|
||||
public UserName(String formatted, String familyName, String givenName, String middleName, String honorificPrefix,
|
||||
public ScimFormattedName(String formatted, String familyName, String givenName, String middleName, String honorificPrefix,
|
||||
String honorificSuffix) {
|
||||
super();
|
||||
this.formatted = formatted;
|
||||
@ -77,7 +77,7 @@ public class UserName implements Serializable {
|
||||
this.honorificPrefix = honorificPrefix;
|
||||
this.honorificSuffix = honorificSuffix;
|
||||
}
|
||||
public UserName() {
|
||||
public ScimFormattedName() {
|
||||
}
|
||||
|
||||
|
||||
@ -20,13 +20,13 @@ package org.maxkey.identity.scim.resources;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class Group extends Resource{
|
||||
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<MemberRef> members;
|
||||
private Set<ScimMemberRef> members;
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
@ -34,14 +34,14 @@ public class Group extends Resource{
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
public Set<MemberRef> getMembers() {
|
||||
public Set<ScimMemberRef> getMembers() {
|
||||
return members;
|
||||
}
|
||||
public void setMembers(Set<MemberRef> members) {
|
||||
public void setMembers(Set<ScimMemberRef> members) {
|
||||
this.members = members;
|
||||
}
|
||||
|
||||
public Group() {
|
||||
public ScimGroup() {
|
||||
schemas =new HashSet<String>();
|
||||
schemas.add(SCHEMA);
|
||||
}
|
||||
@ -17,11 +17,20 @@
|
||||
|
||||
package org.maxkey.identity.scim.resources;
|
||||
|
||||
public class GroupRef extends MultiValuedAttribute{
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
package org.maxkey.identity.scim.resources;
|
||||
|
||||
public class Manager {
|
||||
public class ScimManager {
|
||||
|
||||
private String managerId;
|
||||
private String displayName;
|
||||
@ -33,9 +33,9 @@ public class Manager {
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
public Manager() {
|
||||
public ScimManager() {
|
||||
}
|
||||
public Manager(String managerId, String displayName) {
|
||||
public ScimManager(String managerId, String displayName) {
|
||||
super();
|
||||
this.managerId = managerId;
|
||||
this.displayName = displayName;
|
||||
@ -17,11 +17,18 @@
|
||||
|
||||
package org.maxkey.identity.scim.resources;
|
||||
|
||||
public class MemberRef extends MultiValuedAttribute{
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -26,7 +26,7 @@ import org.maxkey.json.*;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
|
||||
public class Meta implements Serializable {
|
||||
public class ScimMeta implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
@ -87,10 +87,16 @@ public class Meta implements Serializable {
|
||||
public void setResourceType(String resourceType) {
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
public Meta() {
|
||||
public ScimMeta() {
|
||||
|
||||
}
|
||||
public Meta(String resourceType, Date created, Date lastModified, String location, String version,
|
||||
|
||||
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;
|
||||
@ -21,7 +21,7 @@ import java.io.Serializable;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class MultiValuedAttribute implements Serializable {
|
||||
public class ScimMultiValuedAttribute implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6878912593878245947L;
|
||||
|
||||
@ -20,7 +20,7 @@ package org.maxkey.identity.scim.resources;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class Organization extends Resource{
|
||||
public class ScimOrganization extends ScimResource{
|
||||
|
||||
/**
|
||||
*
|
||||
@ -48,16 +48,24 @@ public class Organization extends Resource{
|
||||
|
||||
private String division;
|
||||
|
||||
private List<OrganizationAddress> addresses;
|
||||
private List<ScimOrganizationAddress> addresses;
|
||||
|
||||
private List<OrganizationEmail> emails;
|
||||
private List<ScimOrganizationEmail> emails;
|
||||
|
||||
private List<OrganizationPhoneNumber> phoneNumbers;
|
||||
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;
|
||||
}
|
||||
@ -154,33 +162,67 @@ public class Organization extends Resource{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public List<OrganizationAddress> getAddresses() {
|
||||
public List<ScimOrganizationAddress> getAddresses() {
|
||||
return addresses;
|
||||
}
|
||||
|
||||
public void setAddresses(List<OrganizationAddress> addresses) {
|
||||
public void setAddresses(List<ScimOrganizationAddress> addresses) {
|
||||
this.addresses = addresses;
|
||||
}
|
||||
|
||||
public List<OrganizationEmail> getEmails() {
|
||||
public List<ScimOrganizationEmail> getEmails() {
|
||||
return emails;
|
||||
}
|
||||
|
||||
public void setEmails(List<OrganizationEmail> emails) {
|
||||
public void setEmails(List<ScimOrganizationEmail> emails) {
|
||||
this.emails = emails;
|
||||
}
|
||||
|
||||
public List<OrganizationPhoneNumber> getPhoneNumbers() {
|
||||
public List<ScimOrganizationPhoneNumber> getPhoneNumbers() {
|
||||
return phoneNumbers;
|
||||
}
|
||||
|
||||
public void setPhoneNumbers(List<OrganizationPhoneNumber> phoneNumbers) {
|
||||
public void setPhoneNumbers(List<ScimOrganizationPhoneNumber> phoneNumbers) {
|
||||
this.phoneNumbers = phoneNumbers;
|
||||
}
|
||||
|
||||
public Organization() {
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ package org.maxkey.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class UserAddress extends MultiValuedAttribute implements Serializable {
|
||||
public class ScimOrganizationAddress extends ScimMultiValuedAttribute implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
@ -81,7 +81,7 @@ public class UserAddress extends MultiValuedAttribute implements Serializable {
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
public UserAddress() {
|
||||
public ScimOrganizationAddress() {
|
||||
}
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ package org.maxkey.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class UserEmail extends MultiValuedAttribute implements Serializable {
|
||||
public class ScimOrganizationEmail extends ScimMultiValuedAttribute implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
@ -57,10 +57,10 @@ public class UserEmail extends MultiValuedAttribute implements Serializable {
|
||||
this.primary = primary;
|
||||
}
|
||||
|
||||
public UserEmail() {
|
||||
public ScimOrganizationEmail() {
|
||||
}
|
||||
|
||||
public UserEmail(String value, String type, boolean primary) {
|
||||
public ScimOrganizationEmail(String value, String type, boolean primary) {
|
||||
super();
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
@ -19,7 +19,7 @@ package org.maxkey.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class OrganizationPhoneNumber extends MultiValuedAttribute implements Serializable {
|
||||
public class ScimOrganizationPhoneNumber extends ScimMultiValuedAttribute implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
@ -0,0 +1,85 @@
|
||||
package org.maxkey.identity.scim.resources;
|
||||
|
||||
import org.maxkey.identity.scim.controller.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 + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@ -20,7 +20,7 @@ package org.maxkey.identity.scim.resources;
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
|
||||
public class Resource implements Serializable {
|
||||
public class ScimResource implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
@ -29,12 +29,12 @@ public class Resource implements Serializable {
|
||||
protected Set<String> schemas;
|
||||
private String id;
|
||||
private String externalId;
|
||||
private Meta meta;
|
||||
private ScimMeta meta;
|
||||
|
||||
public Resource() {
|
||||
public ScimResource() {
|
||||
|
||||
}
|
||||
public Resource(String id, String externalId, Meta meta, Set<String> schemas) {
|
||||
public ScimResource(String id, String externalId, ScimMeta meta, Set<String> schemas) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.externalId = externalId;
|
||||
@ -54,10 +54,10 @@ public class Resource implements Serializable {
|
||||
public void setExternalId(String externalId) {
|
||||
this.externalId = externalId;
|
||||
}
|
||||
public Meta getMeta() {
|
||||
public ScimMeta getMeta() {
|
||||
return meta;
|
||||
}
|
||||
public void setMeta(Meta meta) {
|
||||
public void setMeta(ScimMeta meta) {
|
||||
this.meta = meta;
|
||||
}
|
||||
public Set<String> getSchemas() {
|
||||
@ -27,12 +27,22 @@ 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<>();
|
||||
|
||||
/**
|
||||
@ -50,7 +60,7 @@ public class ScimSearchResult <T>{
|
||||
|
||||
|
||||
/**
|
||||
* gets a list of found {@link User}s or {@link Group}s
|
||||
* gets a list of found {@link ScimUser}s or {@link ScimGroup}s
|
||||
*
|
||||
* @return a list of found resources
|
||||
*/
|
||||
|
||||
@ -21,17 +21,21 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class User extends Resource{
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class ScimUser extends ScimResource{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7478787809774041557L;
|
||||
|
||||
public static String SCHEMA = "urn:ietf:params:scim:schemas:core:2.0:User";
|
||||
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 UserName name;
|
||||
private ScimFormattedName name;
|
||||
private String displayName;
|
||||
private String nickName;
|
||||
private String profileUrl;
|
||||
@ -43,34 +47,42 @@ public class User extends Resource{
|
||||
private Boolean active;
|
||||
private String password;
|
||||
|
||||
private List<UserEmail> emails;
|
||||
private List<ScimUserEmail> emails;
|
||||
|
||||
private List<UserPhoneNumber> phoneNumbers;
|
||||
private List<ScimUserPhoneNumber> phoneNumbers;
|
||||
|
||||
@JsonProperty(SCHEMA_ENTERPRISE)
|
||||
ScimEnterprise enterprise;
|
||||
|
||||
private List<ScimUserIm> ims;
|
||||
|
||||
private List<UserIm> ims;
|
||||
|
||||
private List<UserPhoto> photos;
|
||||
private List<ScimUserPhoto> photos;
|
||||
// Can't really validate that one. value is not acessible
|
||||
private List<UserAddress> addresses;
|
||||
private List<ScimUserAddress> addresses;
|
||||
|
||||
private List<GroupRef> groups;
|
||||
private List<ScimGroupRef> groups;
|
||||
|
||||
private List<UserEntitlement> entitlements;
|
||||
private List<ScimUserEntitlement> entitlements;
|
||||
|
||||
private List<UserRole> roles;
|
||||
private List<ScimUserRole> roles;
|
||||
|
||||
private List<UserX509Certificate> x509Certificates;
|
||||
private Map<String, UserExtension> extensions;
|
||||
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 UserName getName() {
|
||||
public ScimFormattedName getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(UserName name) {
|
||||
public void setName(ScimFormattedName name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getDisplayName() {
|
||||
@ -133,67 +145,88 @@ public class User extends Resource{
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
public List<UserEmail> getEmails() {
|
||||
public List<ScimUserEmail> getEmails() {
|
||||
return emails;
|
||||
}
|
||||
public void setEmails(List<UserEmail> emails) {
|
||||
public void setEmails(List<ScimUserEmail> emails) {
|
||||
this.emails = emails;
|
||||
}
|
||||
public List<UserPhoneNumber> getPhoneNumbers() {
|
||||
public List<ScimUserPhoneNumber> getPhoneNumbers() {
|
||||
return phoneNumbers;
|
||||
}
|
||||
public void setPhoneNumbers(List<UserPhoneNumber> phoneNumbers) {
|
||||
public void setPhoneNumbers(List<ScimUserPhoneNumber> phoneNumbers) {
|
||||
this.phoneNumbers = phoneNumbers;
|
||||
}
|
||||
public List<UserIm> getIms() {
|
||||
public List<ScimUserIm> getIms() {
|
||||
return ims;
|
||||
}
|
||||
public void setIms(List<UserIm> ims) {
|
||||
public void setIms(List<ScimUserIm> ims) {
|
||||
this.ims = ims;
|
||||
}
|
||||
public List<UserPhoto> getPhotos() {
|
||||
public List<ScimUserPhoto> getPhotos() {
|
||||
return photos;
|
||||
}
|
||||
public void setPhotos(List<UserPhoto> photos) {
|
||||
public void setPhotos(List<ScimUserPhoto> photos) {
|
||||
this.photos = photos;
|
||||
}
|
||||
public List<UserAddress> getAddresses() {
|
||||
public List<ScimUserAddress> getAddresses() {
|
||||
return addresses;
|
||||
}
|
||||
public void setAddresses(List<UserAddress> addresses) {
|
||||
public void setAddresses(List<ScimUserAddress> addresses) {
|
||||
this.addresses = addresses;
|
||||
}
|
||||
public List<GroupRef> getGroups() {
|
||||
public List<ScimGroupRef> getGroups() {
|
||||
return groups;
|
||||
}
|
||||
public void setGroups(List<GroupRef> groups) {
|
||||
public void setGroups(List<ScimGroupRef> groups) {
|
||||
this.groups = groups;
|
||||
}
|
||||
public List<UserEntitlement> getEntitlements() {
|
||||
public List<ScimUserEntitlement> getEntitlements() {
|
||||
return entitlements;
|
||||
}
|
||||
public void setEntitlements(List<UserEntitlement> entitlements) {
|
||||
public void setEntitlements(List<ScimUserEntitlement> entitlements) {
|
||||
this.entitlements = entitlements;
|
||||
}
|
||||
public List<UserRole> getRoles() {
|
||||
public List<ScimUserRole> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
public void setRoles(List<UserRole> roles) {
|
||||
public void setRoles(List<ScimUserRole> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
public List<UserX509Certificate> getX509Certificates() {
|
||||
public List<ScimUserX509Certificate> getX509Certificates() {
|
||||
return x509Certificates;
|
||||
}
|
||||
public void setX509Certificates(List<UserX509Certificate> x509Certificates) {
|
||||
public void setX509Certificates(List<ScimUserX509Certificate> x509Certificates) {
|
||||
this.x509Certificates = x509Certificates;
|
||||
}
|
||||
public Map<String, UserExtension> getExtensions() {
|
||||
public Map<String, ScimUserExtension> getExtensions() {
|
||||
return extensions;
|
||||
}
|
||||
public void setExtensions(Map<String, UserExtension> extensions) {
|
||||
public void setExtensions(Map<String, ScimUserExtension> extensions) {
|
||||
this.extensions = extensions;
|
||||
}
|
||||
public User() {
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
@ -19,7 +19,7 @@ package org.maxkey.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class OrganizationAddress extends MultiValuedAttribute implements Serializable {
|
||||
public class ScimUserAddress extends ScimMultiValuedAttribute implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
@ -81,7 +81,7 @@ public class OrganizationAddress extends MultiValuedAttribute implements Seriali
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
public OrganizationAddress() {
|
||||
public ScimUserAddress() {
|
||||
}
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ package org.maxkey.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class OrganizationEmail extends MultiValuedAttribute implements Serializable {
|
||||
public class ScimUserEmail extends ScimMultiValuedAttribute implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
@ -57,10 +57,10 @@ public class OrganizationEmail extends MultiValuedAttribute implements Serializa
|
||||
this.primary = primary;
|
||||
}
|
||||
|
||||
public OrganizationEmail() {
|
||||
public ScimUserEmail() {
|
||||
}
|
||||
|
||||
public OrganizationEmail(String value, String type, boolean primary) {
|
||||
public ScimUserEmail(String value, String type, boolean primary) {
|
||||
super();
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
@ -19,7 +19,7 @@ package org.maxkey.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class UserEntitlement extends MultiValuedAttribute implements Serializable {
|
||||
public class ScimUserEntitlement extends ScimMultiValuedAttribute implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
@ -19,7 +19,7 @@ package org.maxkey.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class UserExtension extends MultiValuedAttribute implements Serializable {
|
||||
public class ScimUserExtension extends ScimMultiValuedAttribute implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
@ -19,7 +19,7 @@ package org.maxkey.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class UserIm extends MultiValuedAttribute implements Serializable {
|
||||
public class ScimUserIm extends ScimMultiValuedAttribute implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
@ -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.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;
|
||||
}
|
||||
}
|
||||
@ -19,7 +19,7 @@ package org.maxkey.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class UserPhoneNumber extends MultiValuedAttribute implements Serializable {
|
||||
public class ScimUserPhoneNumber extends ScimMultiValuedAttribute implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
@ -35,4 +35,15 @@ public class UserPhoneNumber extends MultiValuedAttribute implements Serializabl
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -19,7 +19,7 @@ package org.maxkey.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class UserPhoto extends MultiValuedAttribute implements Serializable {
|
||||
public class ScimUserPhoto extends ScimMultiValuedAttribute implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
@ -19,7 +19,7 @@ package org.maxkey.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class UserRole extends MultiValuedAttribute implements Serializable {
|
||||
public class ScimUserRole extends ScimMultiValuedAttribute implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
@ -19,7 +19,7 @@ package org.maxkey.identity.scim.resources;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class UserX509Certificate extends MultiValuedAttribute implements Serializable {
|
||||
public class ScimUserX509Certificate extends ScimMultiValuedAttribute implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
@ -25,7 +25,7 @@ public class ScimEnterpriseUserJsonString2ObjectTest {
|
||||
public static void main(String[] args) {
|
||||
|
||||
String userJsonString = ReadJson2String.read("ScimEnterpriseUserJsonString.json");
|
||||
EnterpriseUser u = JsonUtils.json2Object(userJsonString, EnterpriseUser.class);
|
||||
ScimEnterpriseUser u = JsonUtils.json2Object(userJsonString, ScimEnterpriseUser.class);
|
||||
|
||||
System.out.println(
|
||||
(new JsonPretty()).format(JsonUtils.object2Json(u)));
|
||||
|
||||
@ -27,12 +27,12 @@ public class ScimEnterpriseUserJsonTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
EnterpriseUser u = new EnterpriseUser();
|
||||
ScimEnterpriseUser u = new ScimEnterpriseUser();
|
||||
u.setUserName("UserName");
|
||||
u.setExternalId("UserName");
|
||||
u.setId("1111111111111");
|
||||
|
||||
Meta meta = new Meta();
|
||||
ScimMeta meta = new ScimMeta();
|
||||
meta.setVersion("W\\/\"f250dd84f0671c3\"");
|
||||
meta.setCreated(new Date());
|
||||
meta.setLocation("https://example.com/v2/Users/2819c223...");
|
||||
@ -40,7 +40,7 @@ public class ScimEnterpriseUserJsonTest {
|
||||
meta.setLastModified(new Date());
|
||||
u.setMeta(meta);
|
||||
|
||||
UserName un=new UserName();
|
||||
ScimFormattedName un=new ScimFormattedName();
|
||||
un.setFamilyName("Jensen");
|
||||
un.setFormatted("Ms. Barbara J Jensen, III");
|
||||
un.setGivenName("Barbara");
|
||||
@ -49,28 +49,28 @@ public class ScimEnterpriseUserJsonTest {
|
||||
un.setMiddleName("Jane");
|
||||
u.setName(un);
|
||||
|
||||
List<UserPhoneNumber> UserPhoneNumberList = new ArrayList<UserPhoneNumber>();
|
||||
UserPhoneNumber pn =new UserPhoneNumber();
|
||||
List<ScimUserPhoneNumber> UserPhoneNumberList = new ArrayList<ScimUserPhoneNumber>();
|
||||
ScimUserPhoneNumber pn =new ScimUserPhoneNumber();
|
||||
pn.setValue("555-555-8377");
|
||||
pn.setType(UserPhoneNumber.UserPhoneNumberType.WORK);
|
||||
pn.setType(ScimUserPhoneNumber.UserPhoneNumberType.WORK);
|
||||
|
||||
UserPhoneNumber pnh =new UserPhoneNumber();
|
||||
ScimUserPhoneNumber pnh =new ScimUserPhoneNumber();
|
||||
pnh.setValue("555-555-8377");
|
||||
pnh.setType(UserPhoneNumber.UserPhoneNumberType.HOME);
|
||||
pnh.setType(ScimUserPhoneNumber.UserPhoneNumberType.HOME);
|
||||
UserPhoneNumberList.add(pnh);
|
||||
|
||||
UserPhoneNumberList.add(pn);
|
||||
|
||||
u.setPhoneNumbers(UserPhoneNumberList);
|
||||
|
||||
List<UserEmail> ueList = new ArrayList<UserEmail>();
|
||||
UserEmail ue =new UserEmail();
|
||||
List<ScimUserEmail> ueList = new ArrayList<ScimUserEmail>();
|
||||
ScimUserEmail ue =new ScimUserEmail();
|
||||
ue.setValue("bjensen@example.com");
|
||||
ue.setType(UserEmail.UserEmailType.WORK);
|
||||
ue.setType(ScimUserEmail.UserEmailType.WORK);
|
||||
ueList.add(ue);
|
||||
u.setEmails(ueList);
|
||||
|
||||
Enterprise ent =new Enterprise();
|
||||
ScimEnterprise ent =new ScimEnterprise();
|
||||
ent.setCostCenter("1111");
|
||||
ent.setDepartment("de");
|
||||
ent.setEmployeeNumber("k200908");
|
||||
|
||||
@ -23,7 +23,7 @@ import org.maxkey.util.JsonUtils;
|
||||
public class ScimGroupJsonString2ObjectTest {
|
||||
public static void main(String[] args) {
|
||||
String userJsonString = ReadJson2String.read("ScimGroupJsonString.json");
|
||||
Group g = JsonUtils.json2Object(userJsonString, Group.class);
|
||||
ScimGroup g = JsonUtils.json2Object(userJsonString, ScimGroup.class);
|
||||
|
||||
|
||||
System.out.println(
|
||||
|
||||
@ -26,9 +26,9 @@ import org.maxkey.util.JsonUtils;
|
||||
|
||||
public class ScimGroupJsonTest {
|
||||
public static void main(String[] args) {
|
||||
Group g= new Group();
|
||||
ScimGroup g= new ScimGroup();
|
||||
|
||||
Meta meta = new Meta();
|
||||
ScimMeta meta = new ScimMeta();
|
||||
meta.setVersion("W\\/\"f250dd84f0671c3\"");
|
||||
meta.setCreated(new Date());
|
||||
meta.setLocation("https://example.com/v2/Users/2819c223...");
|
||||
@ -38,16 +38,16 @@ public class ScimGroupJsonTest {
|
||||
|
||||
g.setDisplayName("Tour Guides");
|
||||
|
||||
Set<MemberRef> mrSet =new HashSet<MemberRef>();
|
||||
MemberRef mr1 =new MemberRef();
|
||||
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");
|
||||
MemberRef mr2 =new MemberRef();
|
||||
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");
|
||||
MemberRef mr3 =new MemberRef();
|
||||
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");
|
||||
|
||||
@ -25,7 +25,7 @@ public class ScimUserJsonString2ObjectTest {
|
||||
public static void main(String[] args) {
|
||||
|
||||
String userJsonString = ReadJson2String.read("ScimUserJsonString.json");
|
||||
User u = JsonUtils.json2Object(userJsonString, User.class);
|
||||
ScimUser u = JsonUtils.json2Object(userJsonString, ScimUser.class);
|
||||
System.out.println(
|
||||
(new JsonPretty()).format(JsonUtils.object2Json(u)));
|
||||
}
|
||||
|
||||
@ -26,12 +26,12 @@ import org.maxkey.util.JsonUtils;
|
||||
public class ScimUserJsonTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
User u = new User();
|
||||
ScimUser u = new ScimUser();
|
||||
u.setUserName("UserName");
|
||||
u.setExternalId("UserName");
|
||||
u.setId("1111111111111");
|
||||
|
||||
Meta meta = new Meta();
|
||||
ScimMeta meta = new ScimMeta();
|
||||
meta.setVersion("W\\/\"f250dd84f0671c3\"");
|
||||
meta.setCreated(new Date());
|
||||
meta.setLocation("https://example.com/v2/Users/2819c223...");
|
||||
@ -39,7 +39,7 @@ public class ScimUserJsonTest {
|
||||
meta.setLastModified(new Date());
|
||||
u.setMeta(meta);
|
||||
|
||||
UserName un=new UserName();
|
||||
ScimFormattedName un=new ScimFormattedName();
|
||||
un.setFamilyName("Jensen");
|
||||
un.setFormatted("Ms. Barbara J Jensen, III");
|
||||
un.setGivenName("Barbara");
|
||||
@ -48,24 +48,24 @@ public class ScimUserJsonTest {
|
||||
un.setMiddleName("Jane");
|
||||
u.setName(un);
|
||||
|
||||
List<UserPhoneNumber> UserPhoneNumberList = new ArrayList<UserPhoneNumber>();
|
||||
UserPhoneNumber pn =new UserPhoneNumber();
|
||||
List<ScimUserPhoneNumber> UserPhoneNumberList = new ArrayList<ScimUserPhoneNumber>();
|
||||
ScimUserPhoneNumber pn =new ScimUserPhoneNumber();
|
||||
pn.setValue("555-555-8377");
|
||||
pn.setType(UserPhoneNumber.UserPhoneNumberType.WORK);
|
||||
pn.setType(ScimUserPhoneNumber.UserPhoneNumberType.WORK);
|
||||
|
||||
UserPhoneNumber pnh =new UserPhoneNumber();
|
||||
ScimUserPhoneNumber pnh =new ScimUserPhoneNumber();
|
||||
pnh.setValue("555-555-8377");
|
||||
pnh.setType(UserPhoneNumber.UserPhoneNumberType.HOME);
|
||||
pnh.setType(ScimUserPhoneNumber.UserPhoneNumberType.HOME);
|
||||
UserPhoneNumberList.add(pnh);
|
||||
|
||||
UserPhoneNumberList.add(pn);
|
||||
|
||||
u.setPhoneNumbers(UserPhoneNumberList);
|
||||
|
||||
List<UserEmail> ueList = new ArrayList<UserEmail>();
|
||||
UserEmail ue =new UserEmail();
|
||||
List<ScimUserEmail> ueList = new ArrayList<ScimUserEmail>();
|
||||
ScimUserEmail ue =new ScimUserEmail();
|
||||
ue.setValue("bjensen@example.com");
|
||||
ue.setType(UserEmail.UserEmailType.WORK);
|
||||
ue.setType(ScimUserEmail.UserEmailType.WORK);
|
||||
ueList.add(ue);
|
||||
u.setEmails(ueList);
|
||||
|
||||
|
||||
Binary file not shown.
@ -25,6 +25,7 @@ import java.util.List;
|
||||
import org.apache.mybatis.jpa.persistence.IJpaBaseMapper;
|
||||
import org.maxkey.entity.GroupMember;
|
||||
import org.maxkey.entity.Groups;
|
||||
import org.maxkey.entity.UserInfo;
|
||||
|
||||
/**
|
||||
* @author Crystal.sea
|
||||
@ -44,6 +45,8 @@ public interface GroupMemberMapper extends IJpaBaseMapper<GroupMember> {
|
||||
|
||||
public int deleteByGroupId(String groupId);
|
||||
|
||||
public List<UserInfo> queryMemberByGroupId(String groupId);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -33,4 +33,6 @@ import org.maxkey.entity.Groups;
|
||||
public interface GroupsMapper extends IJpaBaseMapper<Groups> {
|
||||
|
||||
public List<Groups> queryDynamicGroups(Groups groups);
|
||||
|
||||
public List<Groups> queryGroupByUserId(String userId);
|
||||
}
|
||||
|
||||
@ -17,9 +17,12 @@
|
||||
|
||||
package org.maxkey.persistence.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.mybatis.jpa.persistence.JpaBaseService;
|
||||
import org.maxkey.entity.GroupMember;
|
||||
import org.maxkey.entity.Groups;
|
||||
import org.maxkey.entity.UserInfo;
|
||||
import org.maxkey.persistence.mapper.GroupMemberMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@ -45,8 +48,13 @@ public class GroupMemberService extends JpaBaseService<GroupMember>{
|
||||
public int deleteDynamicGroupMember(Groups dynamicGroup) {
|
||||
return getMapper().deleteDynamicGroupMember(dynamicGroup);
|
||||
}
|
||||
|
||||
public int deleteByGroupId(String groupId) {
|
||||
return getMapper().deleteByGroupId(groupId);
|
||||
}
|
||||
|
||||
public List<UserInfo> queryMemberByGroupId(String groupId){
|
||||
return getMapper().queryMemberByGroupId(groupId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -71,6 +71,10 @@ public class GroupsService extends JpaBaseService<Groups> implements Serializab
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<Groups> queryGroupByUserId(String userId){
|
||||
return this.getMapper().queryGroupByUserId(userId);
|
||||
}
|
||||
|
||||
public void refreshDynamicGroups(Groups dynamicGroup){
|
||||
if(dynamicGroup.getDynamic().equals(ConstantsStatus.ACTIVE+"")) {
|
||||
boolean isDynamicTimeSupport = false;
|
||||
|
||||
@ -244,6 +244,52 @@
|
||||
)
|
||||
</delete>
|
||||
|
||||
<select id="queryMemberByGroupId" parameterType="string" resultType="UserInfo">
|
||||
select distinct
|
||||
u.id,
|
||||
u.username,
|
||||
u.usertype,
|
||||
u.windowsaccount,
|
||||
|
||||
u.displayname ,
|
||||
u.nickname ,
|
||||
u.namezhspell,
|
||||
u.namezhshortspell,
|
||||
u.givenname ,
|
||||
u.middlename ,
|
||||
u.familyname ,
|
||||
|
||||
u.gender,
|
||||
|
||||
u.authntype,
|
||||
u.mobile,
|
||||
u.email,
|
||||
u.workemail,
|
||||
u.workphonenumber,
|
||||
|
||||
u.employeenumber,
|
||||
u.division,
|
||||
u.costcenter,
|
||||
u.organization,
|
||||
u.departmentid,
|
||||
u.department,
|
||||
u.jobtitle,
|
||||
u.joblevel,
|
||||
gm.createddate,
|
||||
u.status
|
||||
from
|
||||
mxk_userinfo u,
|
||||
mxk_groups g,
|
||||
mxk_group_member gm
|
||||
where 1 = 1
|
||||
and gm.groupid = #{value}
|
||||
and g.id = #{value}
|
||||
and gm.type in( 'USER','USER-DYNAMIC')
|
||||
and gm.groupid = g.id
|
||||
and gm.memberid = u.id
|
||||
</select>
|
||||
|
||||
|
||||
<delete id="deleteByGroupId" parameterType="string" >
|
||||
delete from mxk_group_member gm
|
||||
where gm.groupid=#{value}
|
||||
|
||||
@ -54,5 +54,21 @@
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
|
||||
<select id="queryGroupByUserId" parameterType="string" resultType="Groups">
|
||||
select distinct
|
||||
g.*
|
||||
from
|
||||
mxk_userinfo u,
|
||||
mxk_groups g,
|
||||
mxk_group_member gm
|
||||
where 1 = 1
|
||||
and gm.memberid = #{value}
|
||||
and u.id = #{value}
|
||||
and gm.type in( 'USER','USER-DYNAMIC')
|
||||
and gm.groupid = g.id
|
||||
and gm.memberid = u.id
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@ -94,7 +94,7 @@ public class MaxKeyMgtJobs implements InitializingBean {
|
||||
.build();
|
||||
|
||||
JobDataMap jobDataMap = new JobDataMap();
|
||||
jobDataMap.put("groupsService", groupsService);
|
||||
jobDataMap.put("service", groupsService);
|
||||
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(cronSchedule);
|
||||
|
||||
CronTrigger cronTrigger =
|
||||
@ -121,7 +121,7 @@ public class MaxKeyMgtJobs implements InitializingBean {
|
||||
.build();
|
||||
|
||||
JobDataMap jobDataMap = new JobDataMap();
|
||||
jobDataMap.put("accountsService", accountsService);
|
||||
jobDataMap.put("service", accountsService);
|
||||
|
||||
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(cronSchedule);
|
||||
CronTrigger cronTrigger =
|
||||
|
||||
@ -151,11 +151,17 @@ public class MaxKeyMgtMvcConfig implements WebMvcConfigurer {
|
||||
_logger.debug("add LocaleChangeInterceptor");
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* api
|
||||
* idm
|
||||
* scim
|
||||
* */
|
||||
registry.addInterceptor(restApiPermissionAdapter)
|
||||
.addPathPatterns("/im/api/**")
|
||||
.addPathPatterns("/api/**")
|
||||
.addPathPatterns("/api/idm/**")
|
||||
.addPathPatterns("/api/idm/scim/**")
|
||||
;
|
||||
|
||||
|
||||
_logger.debug("add RestApiPermissionAdapter");
|
||||
|
||||
}
|
||||
|
||||
@ -54,12 +54,14 @@ public class AccountsStrategyJob implements Job , Serializable {
|
||||
jobStatus = JOBSTATUS.RUNNING;
|
||||
try {
|
||||
if(accountsService == null) {
|
||||
accountsService = (AccountsService) context.getMergedJobDataMap().get("accountsService");
|
||||
}
|
||||
accountsService =
|
||||
(AccountsService) context.getMergedJobDataMap().get("service");
|
||||
}else {
|
||||
|
||||
accountsService.refreshAllByStrategy();
|
||||
accountsService.refreshAllByStrategy();
|
||||
|
||||
Thread.sleep(10 *1000);
|
||||
Thread.sleep(10 *1000);
|
||||
}
|
||||
_logger.debug("DynamicGroupsJob is success " );
|
||||
}catch(Exception e) {
|
||||
_logger.error("Exception " ,e);
|
||||
|
||||
@ -53,12 +53,14 @@ public class DynamicGroupsJob implements Job , Serializable {
|
||||
jobStatus = JOBSTATUS.RUNNING;
|
||||
try {
|
||||
if(groupsService == null) {
|
||||
groupsService = (GroupsService) context.getMergedJobDataMap().get("service");
|
||||
}
|
||||
groupsService =
|
||||
(GroupsService) context.getMergedJobDataMap().get("service");
|
||||
}else {
|
||||
|
||||
groupsService.refreshAllDynamicGroups();
|
||||
groupsService.refreshAllDynamicGroups();
|
||||
|
||||
Thread.sleep(10 *1000);
|
||||
Thread.sleep(10 *1000);
|
||||
}
|
||||
_logger.debug("DynamicGroupsJob is success " );
|
||||
}catch(Exception e) {
|
||||
_logger.error("Exception " ,e);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user