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

Examples of org.springframework.security.oauth2.provider.client.JdbcClientDetailsService$Jackson2Mapper


  private static final String USERNAME = "username";

  public String extractKey(OAuth2Authentication authentication) {
    Map<String, String> values = new LinkedHashMap<String, String>();
    OAuth2Request authorizationRequest = authentication.getOAuth2Request();
    if (!authentication.isClientOnly()) {
      values.put(USERNAME, authentication.getName());
    }
    values.put(CLIENT_ID, authorizationRequest.getClientId());
    if (authorizationRequest.getScope() != null) {
      values.put(SCOPE, OAuth2Utils.formatParameterList(authorizationRequest.getScope()));
    }
    MessageDigest digest;
    try {
      digest = MessageDigest.getInstance("MD5");
    }
View Full Code Here


    refreshToken = Mockito.mock(OAuth2RefreshTokenEntity.class);
    Mockito.when(tokenRepository.getRefreshTokenByValue(refreshTokenValue)).thenReturn(refreshToken);
    Mockito.when(refreshToken.getClient()).thenReturn(client);
    Mockito.when(refreshToken.isExpired()).thenReturn(false);

    tokenRequest = new TokenRequest(null, clientId, null, null);

    storedAuthentication = authentication;
    storedAuthRequest = clientAuth;
    storedAuthHolder = Mockito.mock(AuthenticationHolderEntity.class);
    storedScope = Sets.newHashSet(scope);
View Full Code Here

    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

    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

  public void setUp() throws Exception {
    // creates a HSQL in-memory db populated from default scripts
    // classpath:schema.sql and classpath:data.sql
    db = new EmbeddedDatabaseBuilder().addDefaultScripts().build();
    jdbcTemplate = new JdbcTemplate(db);
    service = new JdbcClientDetailsService(db);
  }
View Full Code Here

  public void testLoadingClientIdWithSingleDetailsInCustomTable() {
    jdbcTemplate.update(CUSTOM_INSERT_SQL, "clientIdWithSingleDetails",
        "mySecret", "myResource", "myScope", "myAuthorizedGrantType",
        "myRedirectUri", "myAuthority");

    JdbcClientDetailsService customService = new JdbcClientDetailsService(
        db);
    customService
        .setSelectClientDetailsSql("select appId, appSecret, resourceIds, scope, "
            + "grantTypes, redirectUrl, authorities, access_token_validity, refresh_token_validity, additionalInformation, autoApproveScopes from ClientDetails where appId = ?");

    ClientDetails clientDetails = customService
        .loadClientByClientId("clientIdWithSingleDetails");

    assertEquals("clientIdWithSingleDetails", clientDetails.getClientId());
    assertTrue(clientDetails.isSecretRequired());
    assertEquals("mySecret", clientDetails.getClientSecret());
View Full Code Here

    @Autowired
    private DataSource dataSource;

    @Bean
    public JdbcClientDetailsService clientDetailsService() {
      return new JdbcClientDetailsService(dataSource);
    }
View Full Code Here

  }

  @Override
  protected ClientDetailsService performBuild() {
    Assert.state(dataSource!=null, "You need to provide a DataSource");
    JdbcClientDetailsService clientDetailsService = new JdbcClientDetailsService(dataSource);
    for (ClientDetails client : clientDetails) {
      clientDetailsService.addClientDetails(client);
    }
    return clientDetailsService;
  }
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

  private OAuth2RequestFactory defaultOAuth2RequestFactory;

  public void afterPropertiesSet() throws Exception {
    Assert.state(tokenGranter != null, "TokenGranter must be provided");
    Assert.state(clientDetailsService != null, "ClientDetailsService must be provided");
    defaultOAuth2RequestFactory = new DefaultOAuth2RequestFactory(getClientDetailsService());
    if (oAuth2RequestFactory == null) {
      oAuth2RequestFactory = defaultOAuth2RequestFactory;
    }
  }
View Full Code Here

TOP

Related Classes of org.springframework.security.oauth2.provider.client.JdbcClientDetailsService$Jackson2Mapper

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.