Commit 6e829eb5 authored by Matija Obreza's avatar Matija Obreza
Browse files

New signature of OAuthService#addClient method

- OAuthClient addClient(OAuthClient client);
- Deprecated old version
parent 543342bd
......@@ -116,7 +116,7 @@
<target>${jdk.target}</target>
<optimize>true</optimize>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
<showDeprecation>false</showDeprecation>
<failOnWarning>true</failOnWarning>
</configuration>
</plugin>
......
......@@ -48,10 +48,20 @@ public interface OAuthClientDetailsService extends ClientDetailsService {
* @param redirectUris the redirect uris
* @param accessTokenValiditySeconds the access token validity seconds
* @param refreshTokenValiditySeconds the refresh token validity seconds
* @return the o auth client
* @return the OAuth client
* @deprecated Use {@link #addClient(OAuthClient)} instead
*/
OAuthClient addClient(String title, String description, String redirectUris, Integer accessTokenValiditySeconds, Integer refreshTokenValiditySeconds);
/**
* Register a new OAuth client.
*
* @param client the client
* @return the OAuth client
* @since 1.3
*/
OAuthClient addClient(OAuthClient client);
/**
* Update client.
*
......
......@@ -638,6 +638,23 @@ public class OAuthServiceImpl implements OAuthClientDetailsService, OAuthTokenSt
return oauthClientRepository.save(client);
}
/* (non-Javadoc)
* @see org.genesys.blocks.oauth.service.OAuthClientDetailsService#addClient(org.genesys.blocks.oauth.model.OAuthClient)
*/
@Override
@Transactional
public OAuthClient addClient(OAuthClient client) {
final String clientId = RandomStringUtils.randomAlphanumeric(5) + "." + RandomStringUtils.randomAlphanumeric(20) + "@" + hostname;
final String clientSecret = RandomStringUtils.randomAlphanumeric(32);
final OAuthClient newClient = new OAuthClient();
newClient.apply(client);
newClient.setClientId(clientId);
newClient.setClientSecret(clientSecret);
return lazyLoad(oauthClientRepository.save(newClient));
}
/*
* (non-Javadoc)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment