Package org.springframework.security.oauth2.provider.client

Examples of org.springframework.security.oauth2.provider.client.BaseClientDetails


    assertTrue(details.isAutoApprove("read"));
  }

  @Test
  public void testBaseClientDetailsImplicitAutoApprove() {
    BaseClientDetails details = new BaseClientDetails("foo", "", "foo,bar", "authorization_code", "ROLE_USER");
    details.setAutoApproveScopes(StringUtils.commaDelimitedListToSet("true"));
    assertTrue(details.isAutoApprove("read"));
  }
View Full Code Here


    assertTrue(details.isAutoApprove("read"));
  }

  @Test
  public void testBaseClientDetailsNoAutoApprove() {
    BaseClientDetails details = new BaseClientDetails("foo", "", "foo,bar", "authorization_code", "ROLE_USER");
    details.setAutoApproveScopes(StringUtils.commaDelimitedListToSet("none"));
    assertFalse(details.isAutoApprove("read"));
  }
View Full Code Here

    assertFalse(details.isAutoApprove("read"));
  }

  @Test
  public void testJsonSerialize() throws Exception {
    BaseClientDetails details = new BaseClientDetails("foo", "", "foo,bar", "authorization_code", "ROLE_USER");
    details.setClientId("foo");
    details.setClientSecret("bar");
    String value = new ObjectMapper().writeValueAsString(details);
    assertTrue(value.contains("client_id"));
    assertTrue(value.contains("client_secret"));
    assertTrue(value.contains("authorized_grant_types"));
    assertTrue(value.contains("[\"ROLE_USER\"]"));
View Full Code Here

        OAuth2Utils.parseParameterList(parameters.get(OAuth2Utils.RESPONSE_TYPE)));
  }

  @Before
  public void init() throws Exception {
    client = new BaseClientDetails();
    client.setRegisteredRedirectUri(Collections.singleton("http://anywhere.com"));
    client.setAuthorizedGrantTypes(Arrays.asList("authorization_code", "implicit"));
    endpoint.setClientDetailsService(new ClientDetailsService() {
      public ClientDetails loadClientByClientId(String clientId) throws OAuth2Exception {
        return client;
View Full Code Here

  }

  @Test
  public void testAutoapprovedScopes() {
    handler.setClientDetailsService(clientDetailsService);
    BaseClientDetails client = new BaseClientDetails("client", null, "read", "authorization_code", null);
    client.setAutoApproveScopes(new HashSet<String>(Arrays.asList("read")));
    clientDetailsService.setClientDetailsStore(Collections.singletonMap("client", client));
    AuthorizationRequest authorizationRequest = new AuthorizationRequest("client", Arrays.asList("read"));
    AuthorizationRequest result = handler.checkForPreApproval(authorizationRequest, userAuthentication);
    assertTrue(result.isApproved());
  }
View Full Code Here

  }

  @Test
  public void testAutoapprovedWildcardScopes() {
    handler.setClientDetailsService(clientDetailsService);
    BaseClientDetails client = new BaseClientDetails("client", null, "read", "authorization_code", null);
    client.setAutoApproveScopes(new HashSet<String>(Arrays.asList(".*")));
    clientDetailsService.setClientDetailsStore(Collections.singletonMap("client", client));
    AuthorizationRequest authorizationRequest = new AuthorizationRequest("client", Arrays.asList("read"));
    AuthorizationRequest result = handler.checkForPreApproval(authorizationRequest, userAuthentication);
    assertTrue(result.isApproved());
  }
View Full Code Here

  }

  @Test
  public void testAutoapprovedAllScopes() {
    handler.setClientDetailsService(clientDetailsService);
    BaseClientDetails client = new BaseClientDetails("client", null, "read", "authorization_code", null);
    client.setAutoApproveScopes(new HashSet<String>(Arrays.asList("true")));
    clientDetailsService.setClientDetailsStore(Collections.singletonMap("client", client));
    AuthorizationRequest authorizationRequest = new AuthorizationRequest("client", Arrays.asList("read"));
    AuthorizationRequest result = handler.checkForPreApproval(authorizationRequest, userAuthentication);
    assertTrue(result.isApproved());
  }
View Full Code Here

  @Before
  public void init() {
    handler.setApprovalStore(store);
    InMemoryClientDetailsService clientDetailsService = new InMemoryClientDetailsService();
    Map<String, ClientDetails> map = new HashMap<String, ClientDetails>();
    map.put("client", new BaseClientDetails("client", null, "read,write", "authorization_code", null));
    clientDetailsService.setClientDetailsStore(map);
    handler.setRequestFactory(new DefaultOAuth2RequestFactory(clientDetailsService));
    userAuthentication = new UsernamePasswordAuthenticationToken("user", "N/A",
        AuthorityUtils.commaSeparatedStringToAuthorityList("USER"));
  }
View Full Code Here

    private boolean autoApprove;

    private Map<String, Object> additionalInformation = new LinkedHashMap<String, Object>();

    private ClientDetails build() {
      BaseClientDetails result = new BaseClientDetails();
      result.setClientId(clientId);
      result.setAuthorizedGrantTypes(authorizedGrantTypes);
      result.setAccessTokenValiditySeconds(accessTokenValiditySeconds);
      result.setRefreshTokenValiditySeconds(refreshTokenValiditySeconds);
      result.setRegisteredRedirectUri(registeredRedirectUris);
      result.setClientSecret(secret);
      result.setScope(scopes);
      result.setAuthorities(AuthorityUtils.createAuthorityList(authorities.toArray(new String[authorities.size()])));
      result.setResourceIds(resourceIds);
      result.setAdditionalInformation(additionalInformation);
      if (autoApprove) {
        result.setAutoApproveScopes(scopes);
      }
      else {
        result.setAutoApproveScopes(autoApproveScopes);
      }
      return result;
    }
View Full Code Here

    @EnableGlobalMethodSecurity(prePostEnabled = true, jsr250Enabled = true)
    private static class GlobalSecurityConfiguration extends GlobalMethodSecurityConfiguration {<% if (authenticationType == 'token') { %>

        @Override
        protected MethodSecurityExpressionHandler createExpressionHandler() {
            return new OAuth2MethodSecurityExpressionHandler();
        }<% } %>
View Full Code Here

TOP

Related Classes of org.springframework.security.oauth2.provider.client.BaseClientDetails

Copyright © 2018 www.massapicom. 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.