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

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


    return newClient;
  }
 
  private OAuth2AccessTokenEntity fetchValidRegistrationToken(OAuth2Authentication auth, ClientDetailsEntity client) {
   
    OAuth2AuthenticationDetails details = (OAuth2AuthenticationDetails) auth.getDetails();
    OAuth2AccessTokenEntity token = tokenService.readAccessToken(details.getTokenValue());
   
    if (config.getRegTokenLifeTime() != null) {
   
      try {
        // Re-issue the token if it has been issued before [currentTime - validity]
View Full Code Here


    assertTrue(value.contains("[\"ROLE_USER\"]"));
  }

  @Test
  public void testJsonSerializeAdditionalInformation() throws Exception {
    BaseClientDetails details = new BaseClientDetails("foo", "", "foo,bar", "authorization_code", "ROLE_USER");
    details.setClientId("foo");
    details.setAdditionalInformation(Collections.singletonMap("foo", "bar"));
    String value = new ObjectMapper().writeValueAsString(details);
    assertTrue(value.contains("\"foo\":\"bar\""));
  }
View Full Code Here

  @Test
  public void testOauthClient() throws Exception {
    AuthorizationRequest request = new AuthorizationRequest("foo",
        Collections.singleton("read"));
    request
        .setResourceIdsAndAuthoritiesFromClientDetails(new BaseClientDetails("foo", "", "", "client_credentials", "ROLE_CLIENT"));
    Authentication userAuthentication = null;
   
    OAuth2Request clientAuthentication = RequestTokenFactory.createOAuth2Request(request.getRequestParameters(), request.getClientId(), request.getAuthorities(), request.isApproved(), request.getScope(), request.getResourceIds(),
        request.getRedirectUri(), request.getResponseTypes(), request.getExtensions());
   
View Full Code Here

  }

  @Test
  public void testJsonDeserialize() throws Exception {
    String value = "{\"foo\":\"bar\",\"client_id\":\"foo\",\"scope\":[\"bar\",\"foo\"],\"authorized_grant_types\":[\"authorization_code\"],\"authorities\":[\"ROLE_USER\"]}";
    BaseClientDetails details = new ObjectMapper().readValue(value, BaseClientDetails.class);
    BaseClientDetails expected = new BaseClientDetails("foo", "", "foo,bar", "authorization_code", "ROLE_USER");
    expected.setAdditionalInformation(Collections.singletonMap("foo", (Object)"bar"));
    assertEquals(expected, details);
  }
View Full Code Here

  @Test
  public void testJsonDeserializeWithArraysAsStrings() throws Exception {
    // Collection values can be deserialized from space or comma-separated lists
    String value = "{\"foo\":\"bar\",\"client_id\":\"foo\",\"scope\":\"bar  foo\",\"authorized_grant_types\":\"authorization_code\",\"authorities\":\"ROLE_USER,ROLE_ADMIN\"}";
    BaseClientDetails details = new ObjectMapper().readValue(value, BaseClientDetails.class);
    BaseClientDetails expected = new BaseClientDetails("foo", "", "foo,bar", "authorization_code", "ROLE_USER,ROLE_ADMIN");
    expected.setAdditionalInformation(Collections.singletonMap("foo", (Object)"bar"));
    assertEquals(expected, details);
  }
View Full Code Here

  @Test
  public void testClientSpecificRefreshTokenExpiry() throws Exception {
    getTokenServices().setRefreshTokenValiditySeconds(1000);
    getTokenServices().setClientDetailsService(new ClientDetailsService() {
      public ClientDetails loadClientByClientId(String clientId) throws OAuth2Exception {
        BaseClientDetails client = new BaseClientDetails();
        client.setRefreshTokenValiditySeconds(100);
        client.setAuthorizedGrantTypes(Arrays.asList("authorization_code", "refresh_token"));
        return client;
      }
    });
    OAuth2AccessToken accessToken = getTokenServices().createAccessToken(createAuthentication());
    DefaultExpiringOAuth2RefreshToken refreshToken = (DefaultExpiringOAuth2RefreshToken) accessToken
View Full Code Here

    getTokenServices().setClientDetailsService(new ClientDetailsService() {
      public ClientDetails loadClientByClientId(String clientId) throws OAuth2Exception {
        if (deleted.get()) {
          throw new ClientRegistrationException("No such client: " + clientId);
        }
        BaseClientDetails client = new BaseClientDetails();
        client.setRefreshTokenValiditySeconds(100);
        client.setAuthorizedGrantTypes(Arrays.asList("authorization_code", "refresh_token"));
        return client;
      }
    });
    OAuth2AccessToken token = getTokenServices()
        .createAccessToken(createAuthentication());
View Full Code Here

  @Test
  public void testClientSpecificTokenExpiry() throws Exception {
    getTokenServices().setAccessTokenValiditySeconds(1000);
    getTokenServices().setClientDetailsService(new ClientDetailsService() {
      public ClientDetails loadClientByClientId(String clientId) throws OAuth2Exception {
        BaseClientDetails client = new BaseClientDetails();
        client.setAccessTokenValiditySeconds(100);
        return client;
      }
    });
    OAuth2AccessToken accessToken = getTokenServices().createAccessToken(createAuthentication());
    assertTrue(100 >= accessToken.getExpiresIn());
View Full Code Here

  }

  @Test
  public void testAddClientWithNoDetails() {

    BaseClientDetails clientDetails = new BaseClientDetails();
    clientDetails.setClientId("addedClientIdWithNoDetails");

    service.addClientDetails(clientDetails);

    Map<String, Object> map = jdbcTemplate.queryForMap(SELECT_SQL,
        "addedClientIdWithNoDetails");
View Full Code Here

  }

  @Test(expected = ClientAlreadyExistsException.class)
  public void testInsertDuplicateClient() {

    BaseClientDetails clientDetails = new BaseClientDetails();
    clientDetails.setClientId("duplicateClientIdWithNoDetails");

    service.addClientDetails(clientDetails);
    service.addClientDetails(clientDetails);
  }
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.