当前位置: 首页>>代码示例>>Java>>正文


Java User类代码示例

本文整理汇总了Java中org.osiam.resources.scim.User的典型用法代码示例。如果您正苦于以下问题:Java User类的具体用法?Java User怎么用?Java User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


User类属于org.osiam.resources.scim包,在下文中一共展示了User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的org.osiam.resources.scim.User类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。