Examples of ClientDetails


Examples of org.springframework.security.oauth2.provider.ClientDetails

   
    String clientId = authorizationRequest.getClientId();
    Set<String> scopes = authorizationRequest.getScope();
    if (clientDetailsService!=null) {
      try {
        ClientDetails client = clientDetailsService.loadClientByClientId(clientId);
        approved = true;
        for (String scope : scopes) {
          if (!client.isAutoApprove(scope)) {
            approved = false;
          }
        }
        if (approved) {
          authorizationRequest.setApproved(true);
View Full Code Here

Examples of org.springframework.security.oauth2.provider.ClientDetails

      throw new InsufficientAuthenticationException(
          "There is no client authentication. Try adding an appropriate authentication filter.");
    }

    String clientId = getClientId(principal);
    ClientDetails authenticatedClient = getClientDetailsService().loadClientByClientId(clientId);

    TokenRequest tokenRequest = getOAuth2RequestFactory().createTokenRequest(parameters, authenticatedClient);

    if (clientId != null && !clientId.equals("")) {
      // Only validate the client details if a client authenticated during this
View Full Code Here

Examples of org.springframework.security.oauth2.provider.ClientDetails

    Set<String> approvedScopes = new HashSet<String>();
    Set<String> validUserApprovedScopes = new HashSet<String>();

    if (clientDetailsService != null) {
      try {
        ClientDetails client = clientDetailsService.loadClientByClientId(clientId);
        for (String scope : requestedScopes) {
          if (client.isAutoApprove(scope) || client.isAutoApprove("all")) {
            approvedScopes.add(scope);
          }
        }
        if (approvedScopes.containsAll(requestedScopes)) {
          authorizationRequest.setApproved(true);
View Full Code Here

Examples of org.springframework.security.oauth2.provider.ClientDetails

      return result;
    }

    OAuth2Authentication oauth2Authentication = (OAuth2Authentication) authentication;
    OAuth2Request clientAuthentication = oauth2Authentication.getOAuth2Request();
    ClientDetails client = clientDetailsService.loadClientByClientId(clientAuthentication.getClientId());
    Set<String> scopes = clientAuthentication.getScope();
    if (oauth2Authentication.isClientOnly() && clientAuthoritiesAreScopes) {
      scopes = AuthorityUtils.authorityListToSet(clientAuthentication.getAuthorities());
    }

    for (ConfigAttribute attribute : attributes) {
      if (this.supports(attribute)) {

        result = ACCESS_GRANTED;

        for (String scope : scopes) {
          if (!client.getScope().contains(scope)) {
            result = ACCESS_DENIED;
            break;
          }
        }

        if (result == ACCESS_DENIED && throwException) {
          InsufficientScopeException failure = new InsufficientScopeException(
              "Insufficient scope for this resource", client.getScope());
          throw new AccessDeniedException(failure.getMessage(), failure);
        }

        return result;
      }
View Full Code Here

Examples of org.springframework.security.oauth2.provider.ClientDetails

   
    AuthorizationRequest request = new AuthorizationRequest(authorizationParameters,
        Collections.<String, String> emptyMap(), clientId, scopes, null, null, false, state, redirectUri,
        responseTypes);

    ClientDetails clientDetails = clientDetailsService.loadClientByClientId(clientId);   
    request.setResourceIdsAndAuthoritiesFromClientDetails(clientDetails);

    return request;

  }
View Full Code Here

Examples of org.springframework.security.oauth2.provider.ClientDetails

    return tokenRequest.createOAuth2Request(client);
  }

  private Set<String> extractScopes(Map<String, String> requestParameters, String clientId) {
    Set<String> scopes = OAuth2Utils.parseParameterList(requestParameters.get(OAuth2Utils.SCOPE));
    ClientDetails clientDetails = clientDetailsService.loadClientByClientId(clientId);

    if ((scopes == null || scopes.isEmpty())) {
      // If no scopes are specified in the incoming data, use the default values registered with the client
      // (the spec allows us to choose between this option and rejecting the request completely, so we'll take the
      // least obnoxious choice as a default).
      scopes = clientDetails.getScope();
    }

    if (checkUserScopes) {
      scopes = checkUserScopes(scopes, clientDetails);
    }
View Full Code Here

Examples of org.springframework.security.oauth2.provider.ClientDetails

    if (!this.grantType.equals(grantType)) {
      return null;
    }
   
    String clientId = tokenRequest.getClientId();
    ClientDetails client = clientDetailsService.loadClientByClientId(clientId);
    validateGrantType(grantType, client);
   
    logger.debug("Getting access token for: " + clientId);

    return getAccessToken(client, tokenRequest);
View Full Code Here

Examples of org.springframework.security.oauth2.provider.ClientDetails

public class InMemoryClientDetailsService implements ClientDetailsService {

  private Map<String, ClientDetails> clientDetailsStore = new HashMap<String, ClientDetails>();

  public ClientDetails loadClientByClientId(String clientId) throws ClientRegistrationException {
    ClientDetails details = clientDetailsStore.get(clientId);
    if (details == null) {
      throw new NoSuchClientException("No client with requested id: " + clientId);
    }
    return details;
  }
View Full Code Here

Examples of org.springframework.security.oauth2.provider.ClientDetails

  public void setPasswordEncoder(PasswordEncoder passwordEncoder) {
    this.passwordEncoder = passwordEncoder;
  }

  public ClientDetails loadClientByClientId(String clientId) throws InvalidClientException {
    ClientDetails details;
    try {
      details = jdbcTemplate.queryForObject(selectClientDetailsSql, new ClientDetailsRowMapper(), clientId);
    }
    catch (EmptyResultDataAccessException e) {
      throw new NoSuchClientException("No client with requested id: " + clientId);
View Full Code Here

Examples of org.springframework.security.oauth2.provider.ClientDetails

  public void setPasswordEncoder(PasswordEncoder passwordEncoder) {
    this.emptyPassword = passwordEncoder.encode("");
  }

  public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
    ClientDetails clientDetails = clientDetailsService.loadClientByClientId(username);
    String clientSecret = clientDetails.getClientSecret();
    if (clientSecret== null || clientSecret.trim().length()==0) {
      clientSecret = emptyPassword;
    }
    return new User(username, clientSecret, clientDetails.getAuthorities());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.