本文整理汇总了Java中org.osiam.resources.scim.User类的典型用法代码示例。如果您正苦于以下问题:Java User类的具体用法?Java User怎么用?Java User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
User类属于org.osiam.resources.scim包,在下文中一共展示了User类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: validateToken
import org.osiam.resources.scim.User; //导入依赖的package包/类
@RequestMapping(value = "/validation", method = RequestMethod.POST)
@ResponseBody
public AccessToken validateToken(@RequestHeader("Authorization") final String authorization) {
String token = getToken(authorization);
OAuth2Authentication auth = tokenStore.readAuthentication(token);
OAuth2AccessToken accessToken = tokenStore.getAccessToken(auth);
OAuth2Request authReq = auth.getOAuth2Request();
AccessToken.Builder tokenBuilder = new AccessToken.Builder(token).setClientId(authReq.getClientId());
if (auth.getUserAuthentication() != null && auth.getPrincipal() instanceof User) {
User user = (User) auth.getPrincipal();
tokenBuilder.setUserName(user.getUserName());
tokenBuilder.setUserId(user.getId());
}
tokenBuilder.setExpiresAt(accessToken.getExpiration());
for (String scopeString : authReq.getScope()) {
tokenBuilder.addScope(new Scope(scopeString));
}
return tokenBuilder.build();
}
开发者ID:osiam,项目名称:auth-server,代码行数:24,代码来源:TokenController.java
示例2: revokeAllTokensOfUser
import org.osiam.resources.scim.User; //导入依赖的package包/类
@RequestMapping(value = "/revocation/{userId}", method = RequestMethod.POST)
@ResponseBody
public void revokeAllTokensOfUser(@PathVariable("userId") final String userId) {
User user = resourceServerConnector.getUserById(userId);
// the token store maps the tokens of a user to the string representation of the principal
String searchKey = new User.Builder(user.getUserName())
.setId(userId)
.build()
.toString();
List<String> clientIds = clientRepository.findAllClientIds();
List<OAuth2AccessToken> tokens = new LinkedList<>();
for (String clientId : clientIds) {
Collection<OAuth2AccessToken> tokenForClient = tokenStore.findTokensByClientIdAndUserName(
clientId, searchKey
);
tokens.addAll(tokenForClient);
}
for (OAuth2AccessToken token : tokens) {
tokenStore.removeAccessToken(token);
}
}
开发者ID:osiam,项目名称:auth-server,代码行数:22,代码来源:TokenController.java
示例3: extractUserName
import org.osiam.resources.scim.User; //导入依赖的package包/类
private String extractUserName(AbstractAuthenticationEvent appEvent) {
if (appEvent.getSource() != null && appEvent.getSource() instanceof InternalAuthentication) {
InternalAuthentication internalAuth = (InternalAuthentication) appEvent.getSource();
if (internalAuth.getPrincipal() != null) {
if (internalAuth.getPrincipal() instanceof User) {
User user = (User) internalAuth.getPrincipal();
return user.getUserName();
}
if (internalAuth.getPrincipal() instanceof String) {
return (String) internalAuth.getPrincipal();
}
}
}
return null;
}
开发者ID:osiam,项目名称:auth-server,代码行数:19,代码来源:InternalAuthenticationProvider.java
示例4: filterUserSchemas
import org.osiam.resources.scim.User; //导入依赖的package包/类
private List<User> filterUserSchemas(List<User> resourceList, String[] fieldsToReturn) {
if (resourceList.size() == 0) {
return resourceList;
}
List<User> modifiedResourceList = new ArrayList<>();
Set<String> newSchema = new HashSet<>();
List<String> returnFields = Arrays.asList(fieldsToReturn);
for (User resource : resourceList) {
for (String schema : resource.getSchemas()) {
if (schema.equals(User.SCHEMA) || returnFields.contains(schema)) {
newSchema.add(schema);
}
}
User modifiedUser = new User.Builder(resource).setSchemas(newSchema).build();
modifiedResourceList.add(modifiedUser);
}
return modifiedResourceList;
}
开发者ID:osiam,项目名称:resource-server,代码行数:20,代码来源:AttributesRemovalHelper.java
示例5: create
import org.osiam.resources.scim.User; //导入依赖的package包/类
@Override
public User create(User user) {
if (userDao.isUserNameAlreadyTaken(user.getUserName())) {
throw new ResourceExistsException(String.format(
"Can't create a user. The username \"%s\" is already taken.", user.getUserName()));
}
if (userDao.isExternalIdAlreadyTaken(user.getExternalId())) {
throw new ResourceExistsException(String.format(
"Can't create a user. The externalId \"%s\" is already taken.", user.getExternalId()));
}
UserEntity userEntity = userConverter.fromScim(user);
userEntity.setId(UUID.randomUUID());
String hashedPassword = bCryptPasswordEncoder.encode(user.getPassword());
userEntity.setPassword(hashedPassword);
userDao.create(userEntity);
return removePassword(userConverter.toScim(userEntity));
}
开发者ID:osiam,项目名称:osiam,代码行数:21,代码来源:SCIMUserProvisioning.java
示例6: search
import org.osiam.resources.scim.User; //导入依赖的package包/类
@Override
public SCIMSearchResult<User> search(String filter, String sortBy, String sortOrder, int count, int startIndex) {
QueryFilterParser queryFilterParser = new QueryFilterParser();
List<User> users = new ArrayList<>();
ParseTree filterTree = queryFilterParser.getParseTree(filter);
SearchResult<UserEntity> result = userDao.search(filterTree, sortBy, sortOrder, count, startIndex - 1);
for (UserEntity userEntity : result.results) {
User scimResultUser = userConverter.toScim(userEntity);
users.add(removePassword(scimResultUser));
}
return new SCIMSearchResult<>(users, result.totalResults, count, startIndex);
}
开发者ID:osiam,项目名称:osiam,代码行数:17,代码来源:SCIMUserProvisioning.java
示例7: update
import org.osiam.resources.scim.User; //导入依赖的package包/类
@Override
public User update(String id, User user) {
UserEntity userEntity = userDao.getById(id);
if (userDao.isUserNameAlreadyTaken(user.getUserName(), id)) {
throw new ResourceExistsException(String.format(
"Can't update the user with the id \"%s\". The username \"%s\" is already taken.", id,
user.getUserName()));
}
if (userDao.isExternalIdAlreadyTaken(user.getExternalId(), id)) {
throw new ResourceExistsException(String.format(
"Can't update the user with the id \"%s\". The externalId \"%s\" is already taken.", id,
user.getExternalId()));
}
userUpdater.update(user, userEntity);
userEntity.touch();
return removePassword(userConverter.toScim(userEntity));
}
开发者ID:osiam,项目名称:osiam,代码行数:22,代码来源:SCIMUserProvisioning.java
示例8: revokeAllTokensOfUser
import org.osiam.resources.scim.User; //导入依赖的package包/类
public void revokeAllTokensOfUser(final String userId) {
User user = userProvisioning.getById(userId);
// the token store maps the tokens of a user to the string representation of the principal
String searchKey = new User.Builder(user.getUserName())
.setId(userId)
.build()
.toString();
List<String> clientIds = clientRepository.findAllClientIds();
List<OAuth2AccessToken> tokens = new LinkedList<>();
for (String clientId : clientIds) {
Collection<OAuth2AccessToken> tokenForClient = tokenStore.findTokensByClientIdAndUserName(
clientId, searchKey
);
tokens.addAll(tokenForClient);
}
for (OAuth2AccessToken token : tokens) {
tokenStore.removeAccessToken(token);
}
}
开发者ID:osiam,项目名称:osiam,代码行数:20,代码来源:TokenService.java
示例9: enhance
import org.osiam.resources.scim.User; //导入依赖的package包/类
@Override
public OAuth2AccessToken enhance(final OAuth2AccessToken accessToken, final OAuth2Authentication authentication) {
DefaultOAuth2AccessToken token = (DefaultOAuth2AccessToken) accessToken;
Map<String, Object> additionalInformation = new HashMap<>();
additionalInformation.put("expires_at", token.getExpiration());
if (token.getRefreshToken() != null) {
DefaultExpiringOAuth2RefreshToken refreshToken =
(DefaultExpiringOAuth2RefreshToken) token.getRefreshToken();
additionalInformation.put("refresh_token_expires_at", refreshToken.getExpiration());
}
additionalInformation.put("client_id", authentication.getOAuth2Request().getClientId());
if (authentication.getUserAuthentication() != null && authentication.getPrincipal() instanceof User) {
User user = (User) authentication.getPrincipal();
additionalInformation.put("user_name", user.getUserName());
additionalInformation.put("user_id", user.getId());
}
token.setAdditionalInformation(additionalInformation);
return accessToken;
}
开发者ID:osiam,项目名称:osiam,代码行数:25,代码来源:OsiamTokenEnhancer.java
示例10: getById
import org.osiam.resources.scim.User; //导入依赖的package包/类
@Override
public User getById(String id) {
try {
UserEntity userEntity = userDao.getById(id);
User user = userConverter.toScim(userEntity);
return getUserWithoutPassword(user);
} catch (NoResultException nre) {
LOGGER.info(nre.getMessage(), nre);
throw new ResourceNotFoundException(String.format("User with id '%s' not found", id), nre);
} catch (PersistenceException pe) {
LOGGER.warn(pe.getMessage(), pe);
throw new ResourceNotFoundException(String.format("User with id '%s' not found", id), pe);
}
}
开发者ID:osiam,项目名称:resource-server,代码行数:17,代码来源:SCIMUserProvisioning.java
示例11: create
import org.osiam.resources.scim.User; //导入依赖的package包/类
@Override
public User create(User user) {
if (userDao.isUserNameAlreadyTaken(user.getUserName())) {
throw new ResourceExistsException(String.format(
"Can't create a user. The username \"%s\" is already taken.", user.getUserName()));
}
if (userDao.isExternalIdAlreadyTaken(user.getExternalId())) {
throw new ResourceExistsException(String.format(
"Can't create a user. The externalId \"%s\" is already taken.", user.getExternalId()));
}
UserEntity userEntity = userConverter.fromScim(user);
userEntity.setId(UUID.randomUUID());
String hashedPassword = passwordEncoder.encodePassword(user.getPassword(), userEntity.getId());
userEntity.setPassword(hashedPassword);
userDao.create(userEntity);
return getUserWithoutPassword(userConverter.toScim(userEntity));
}
开发者ID:osiam,项目名称:resource-server,代码行数:21,代码来源:SCIMUserProvisioning.java
示例12: search
import org.osiam.resources.scim.User; //导入依赖的package包/类
@Override
public SCIMSearchResult<User> search(String filter, String sortBy, String sortOrder, int count, int startIndex) {
QueryFilterParser queryFilterParser = new QueryFilterParser();
List<User> users = new ArrayList<>();
ParseTree filterTree = queryFilterParser.getParseTree(filter);
SearchResult<UserEntity> result = userDao.search(filterTree, sortBy, sortOrder, count, startIndex - 1);
if (searchedForPasswordAndNoResult(result, filter)) {
sleepIfForPasswordWasSearched(filterTree);
}
for (UserEntity userEntity : result.results) {
User scimResultUser = userConverter.toScim(userEntity);
users.add(getUserWithoutPassword(scimResultUser));
}
return new SCIMSearchResult<>(users, result.totalResults, count, startIndex);
}
开发者ID:osiam,项目名称:resource-server,代码行数:20,代码来源:SCIMUserProvisioning.java
示例13: update
import org.osiam.resources.scim.User; //导入依赖的package包/类
@Override
public User update(String id, User user) {
UserEntity userEntity = userDao.getById(id);
if (userDao.isUserNameAlreadyTaken(user.getUserName(), id)) {
throw new ResourceExistsException(String.format(
"Can't update the user with the id \"%s\". The username \"%s\" is already taken.", id,
user.getUserName()));
}
if (userDao.isExternalIdAlreadyTaken(user.getExternalId(), id)) {
throw new ResourceExistsException(String.format(
"Can't update the user with the id \"%s\". The externalId \"%s\" is already taken.", id,
user.getExternalId()));
}
userUpdater.update(user, userEntity);
userEntity.touch();
return getUserWithoutPassword(userConverter.toScim(userEntity));
}
开发者ID:osiam,项目名称:resource-server,代码行数:22,代码来源:SCIMUserProvisioning.java
示例14: validateJsonUser
import org.osiam.resources.scim.User; //导入依赖的package包/类
public User validateJsonUser(HttpServletRequest request) throws IOException {
String jsonInput = getRequestBody(request);
Validator validator = validators.get(RequestMethod.valueOf(request.getMethod()));
User user;
try {
user = validator.validateJsonUser(jsonInput);
} catch (JsonParseException ex) {
throw new IllegalArgumentException("The JSON structure is invalid", ex);
}
if (user.getSchemas() == null || user.getSchemas().isEmpty()
|| !user.getSchemas().contains(User.SCHEMA)) {
throw new SchemaUnknownException();
}
if (user.getId() != null && !user.getId().isEmpty()) {
user = new User.Builder(user).setId(null).build();
}
return user;
}
开发者ID:osiam,项目名称:resource-server,代码行数:19,代码来源:JsonInputValidator.java
示例15: isOwnerOfResource
import org.osiam.resources.scim.User; //导入依赖的package包/类
public boolean isOwnerOfResource() {
if (!(authentication.getPrincipal() instanceof User)) {
return false;
}
final String userId = ((User) authentication.getPrincipal()).getId();
final String requestUrl = filterInvocation.getRequestUrl();
if (!requestUrl.startsWith("/token/revocation")) {
return false;
}
try {
String path = new URI(requestUrl).getPath();
List<String> pathSegments = Splitter.on('/')
.omitEmptyStrings()
.trimResults()
.splitToList(path);
if (pathSegments.size() < 3) {
return false;
}
String resourceId = pathSegments.get(2);
if (userId.equals(resourceId)) {
return true;
}
} catch (URISyntaxException e) {
return false;
}
return false;
}
开发者ID:osiam,项目名称:auth-server,代码行数:36,代码来源:OsiamSecurityExpressionMethods.java
示例16: getUserByUsername
import org.osiam.resources.scim.User; //导入依赖的package包/类
public User getUserByUsername(final String userName) {
Query query = new QueryBuilder().filter("userName eq \"" + userName + "\"").build();
SCIMSearchResult<User> result = createOsiamConnector().searchUsers(query,
osiamAccessTokenProvider.createAccessToken());
if (result.getTotalResults() != 1) {
return null;
} else {
return result.getResources().get(0);
}
}
开发者ID:osiam,项目名称:auth-server,代码行数:13,代码来源:ResourceServerConnector.java
示例17: searchUserByUserNameAndPassword
import org.osiam.resources.scim.User; //导入依赖的package包/类
public User searchUserByUserNameAndPassword(String userName, String hashedPassword) {
Query query = new QueryBuilder().filter("userName eq \"" + userName + "\""
+ " and password eq \"" + hashedPassword + "\"").build();
SCIMSearchResult<User> result = createOsiamConnector().searchUsers(
query, osiamAccessTokenProvider.createAccessToken()
);
if (result.getTotalResults() != 1) {
return null;
} else {
return result.getResources().get(0);
}
}
开发者ID:osiam,项目名称:auth-server,代码行数:15,代码来源:ResourceServerConnector.java
示例18: checkMapping
import org.osiam.resources.scim.User; //导入依赖的package包/类
private void checkMapping() {
DirContextOperations ldapUserData = new DirContextAdapter();
for (String scimAttribute : scimToLdapAttributes.keySet()) {
if (scimAttribute.equalsIgnoreCase("password")) {
throw new LdapConfigurationException(
"The password can not be mapped to the SCIM user. Please delete the password mapping from"
+ "the configuration!"
);
}
ldapUserData.setAttributeValue(scimToLdapAttributes.get(scimAttribute), "[email protected]");
}
OsiamLdapUserContextMapper contextMapper = new OsiamLdapUserContextMapper(this);
User user = contextMapper.mapUser(ldapUserData);
contextMapper.mapUpdateUser(user, ldapUserData);
}
开发者ID:osiam,项目名称:auth-server,代码行数:16,代码来源:ScimToLdapAttributeMapping.java
示例19: synchronizeLdapData
import org.osiam.resources.scim.User; //导入依赖的package包/类
private User synchronizeLdapData(DirContextOperations ldapUserData, User user) {
User userToReturn = user;
if (userToReturn == null) {
User newUser = osiamLdapUserContextMapper.mapUser(ldapUserData);
userToReturn = resourceServerConnector.createUser(newUser);
} else if (syncUserData) {
UpdateUser updateUser = osiamLdapUserContextMapper.mapUpdateUser(user, ldapUserData);
userToReturn = resourceServerConnector.updateUser(user.getId(), updateUser);
}
return userToReturn;
}
开发者ID:osiam,项目名称:auth-server,代码行数:14,代码来源:OsiamLdapAuthenticationProvider.java
示例20: getUserJsonResponseWithAdditionalFields
import org.osiam.resources.scim.User; //导入依赖的package包/类
private SCIMSearchResult<User> getUserJsonResponseWithAdditionalFields(
SCIMSearchResult<User> scimSearchResult, Map<String, Object> parameterMap) {
ObjectMapper mapper = new ObjectMapper();
String[] fieldsToReturn = (String[]) parameterMap.get("attributes");
if (fieldsToReturn.length == 0) {
return scimSearchResult;
}
for (int i = 0; i < fieldsToReturn.length; i++) {
fieldsToReturn[i] = fieldsToReturn[i].trim();
}
ObjectWriter writer = getObjectWriter(mapper, fieldsToReturn);
try {
List<User> users = scimSearchResult.getResources();
users = filterUserSchemas(users, fieldsToReturn);
String resourcesString = writer.writeValueAsString(users);
JsonNode resourcesNode = mapper.readTree(resourcesString);
String schemasString = writer.writeValueAsString(scimSearchResult.getSchemas());
JsonNode schemasNode = mapper.readTree(schemasString);
ObjectNode rootNode = mapper.createObjectNode();
rootNode.put("totalResults", scimSearchResult.getTotalResults());
rootNode.put("itemsPerPage", scimSearchResult.getItemsPerPage());
rootNode.put("startIndex", scimSearchResult.getStartIndex());
rootNode.put("schemas", schemasNode);
rootNode.put("Resources", resourcesNode);
return mapper.readValue(rootNode.toString(), SCIMSearchResult.class);
} catch (IOException e) {
LOGGER.warn("Unable to serialize search result", e);
throw new OsiamBackendFailureException();
}
}
开发者ID:osiam,项目名称:resource-server,代码行数:39,代码来源:AttributesRemovalHelper.java
注:本文中的org.osiam.resources.scim.User类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论