Search in sources :

Example 1 with NoSuchClientException

use of org.springframework.security.oauth2.provider.NoSuchClientException in project dhis2-core by dhis2.

the class DefaultClientDetailsUserDetailsService method loadUserByUsername.

public UserDetails loadUserByUsername(String username) {
    ClientDetails clientDetails;
    try {
        clientDetails = clientDetailsService.loadClientByClientId(username);
    } catch (NoSuchClientException e) {
        throw new UsernameNotFoundException(e.getMessage(), e);
    }
    String clientSecret = clientDetails.getClientSecret();
    if (clientSecret == null || clientSecret.trim().length() == 0) {
        clientSecret = emptyPassword;
    }
    return new User(username, clientSecret, clientDetails.getAuthorities());
}
Also used : UsernameNotFoundException(org.springframework.security.core.userdetails.UsernameNotFoundException) ClientDetails(org.springframework.security.oauth2.provider.ClientDetails) User(org.springframework.security.core.userdetails.User) NoSuchClientException(org.springframework.security.oauth2.provider.NoSuchClientException)

Example 2 with NoSuchClientException

use of org.springframework.security.oauth2.provider.NoSuchClientException in project spring-security-oauth by spring-projects.

the class ClientDetailsUserDetailsService method loadUserByUsername.

public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
    ClientDetails clientDetails;
    try {
        clientDetails = clientDetailsService.loadClientByClientId(username);
    } catch (NoSuchClientException e) {
        throw new UsernameNotFoundException(e.getMessage(), e);
    }
    String clientSecret = clientDetails.getClientSecret();
    if (clientSecret == null || clientSecret.trim().length() == 0) {
        clientSecret = emptyPassword;
    }
    return new User(username, clientSecret, clientDetails.getAuthorities());
}
Also used : UsernameNotFoundException(org.springframework.security.core.userdetails.UsernameNotFoundException) ClientDetails(org.springframework.security.oauth2.provider.ClientDetails) User(org.springframework.security.core.userdetails.User) NoSuchClientException(org.springframework.security.oauth2.provider.NoSuchClientException)

Aggregations

User (org.springframework.security.core.userdetails.User)2 UsernameNotFoundException (org.springframework.security.core.userdetails.UsernameNotFoundException)2 ClientDetails (org.springframework.security.oauth2.provider.ClientDetails)2 NoSuchClientException (org.springframework.security.oauth2.provider.NoSuchClientException)2