Skip to content
This repository was archived by the owner on May 31, 2022. It is now read-only.

Commit e96d2c7

Browse files
jzheauxjgrandja
authored andcommitted
Polish logs
Closes gh-1941
1 parent e525a0e commit e96d2c7

File tree

8 files changed

+21
-21
lines changed

8 files changed

+21
-21
lines changed

spring-security-oauth2/src/main/java/org/springframework/security/oauth2/provider/client/InMemoryClientDetailsService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class InMemoryClientDetailsService implements ClientDetailsService {
4040
public ClientDetails loadClientByClientId(String clientId) throws ClientRegistrationException {
4141
ClientDetails details = clientDetailsStore.get(clientId);
4242
if (details == null) {
43-
throw new NoSuchClientException("No client with requested id: " + clientId);
43+
throw new NoSuchClientException("No client with requested id");
4444
}
4545
return details;
4646
}

spring-security-oauth2/src/main/java/org/springframework/security/oauth2/provider/client/JdbcClientDetailsService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public ClientDetails loadClientByClientId(String clientId) throws InvalidClientE
125125
details = jdbcTemplate.queryForObject(selectClientDetailsSql, new ClientDetailsRowMapper(), clientId);
126126
}
127127
catch (EmptyResultDataAccessException e) {
128-
throw new NoSuchClientException("No client with requested id: " + clientId);
128+
throw new NoSuchClientException("No client with requested id");
129129
}
130130

131131
return details;
@@ -143,21 +143,21 @@ public void addClientDetails(ClientDetails clientDetails) throws ClientAlreadyEx
143143
public void updateClientDetails(ClientDetails clientDetails) throws NoSuchClientException {
144144
int count = jdbcTemplate.update(updateClientDetailsSql, getFieldsForUpdate(clientDetails));
145145
if (count != 1) {
146-
throw new NoSuchClientException("No client found with id = " + clientDetails.getClientId());
146+
throw new NoSuchClientException("No client found requested id");
147147
}
148148
}
149149

150150
public void updateClientSecret(String clientId, String secret) throws NoSuchClientException {
151151
int count = jdbcTemplate.update(updateClientSecretSql, passwordEncoder.encode(secret), clientId);
152152
if (count != 1) {
153-
throw new NoSuchClientException("No client found with id = " + clientId);
153+
throw new NoSuchClientException("No client found requested id");
154154
}
155155
}
156156

157157
public void removeClientDetails(String clientId) throws NoSuchClientException {
158158
int count = jdbcTemplate.update(deleteClientDetailsSql, clientId);
159159
if (count != 1) {
160-
throw new NoSuchClientException("No client found with id = " + clientId);
160+
throw new NoSuchClientException("No client found requested id");
161161
}
162162
}
163163

spring-security-oauth2/src/main/java/org/springframework/security/oauth2/provider/code/AuthorizationCodeTokenGranter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ protected OAuth2Authentication getOAuth2Authentication(ClientDetails client, Tok
7474

7575
OAuth2Authentication storedAuth = authorizationCodeServices.consumeAuthorizationCode(authorizationCode);
7676
if (storedAuth == null) {
77-
throw new InvalidGrantException("Invalid authorization code: " + authorizationCode);
77+
throw new InvalidGrantException("Invalid authorization code");
7878
}
7979

8080
OAuth2Request pendingOAuth2Request = storedAuth.getOAuth2Request();

spring-security-oauth2/src/main/java/org/springframework/security/oauth2/provider/code/RandomValueAuthorizationCodeServices.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public OAuth2Authentication consumeAuthorizationCode(String code)
3232
throws InvalidGrantException {
3333
OAuth2Authentication auth = this.remove(code);
3434
if (auth == null) {
35-
throw new InvalidGrantException("Invalid authorization code: " + code);
35+
throw new InvalidGrantException("Invalid authorization code");
3636
}
3737
return auth;
3838
}

spring-security-oauth2/src/main/java/org/springframework/security/oauth2/provider/password/ResourceOwnerPasswordTokenGranter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ protected OAuth2Authentication getOAuth2Authentication(ClientDetails client, Tok
8585
}
8686
catch (UsernameNotFoundException e) {
8787
// If the user is not found, report a generic error message
88-
throw new InvalidGrantException(e.getMessage());
88+
throw new InvalidGrantException("username not found");
8989
}
9090
if (userAuth == null || !userAuth.isAuthenticated()) {
91-
throw new InvalidGrantException("Could not authenticate user: " + username);
91+
throw new InvalidGrantException("Could not authenticate user");
9292
}
9393

9494
OAuth2Request storedOAuth2Request = getRequestFactory().createOAuth2Request(client, tokenRequest);

spring-security-oauth2/src/main/java/org/springframework/security/oauth2/provider/refresh/RefreshTokenGranter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected OAuth2AccessToken getAccessToken(ClientDetails client, TokenRequest to
5959
throw new InvalidGrantException(ase.getMessage());
6060
} catch (UsernameNotFoundException e) {
6161
// If the user is not found, report a generic error message
62-
throw new InvalidGrantException(e.getMessage());
62+
throw new InvalidGrantException("user not found");
6363
}
6464
}
6565
}

spring-security-oauth2/src/main/java/org/springframework/security/oauth2/provider/token/AbstractTokenGranter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ protected void validateGrantType(String grantType, ClientDetails clientDetails)
8585
Collection<String> authorizedGrantTypes = clientDetails.getAuthorizedGrantTypes();
8686
if (authorizedGrantTypes != null && !authorizedGrantTypes.isEmpty()
8787
&& !authorizedGrantTypes.contains(grantType)) {
88-
throw new InvalidClientException("Unauthorized grant type: " + grantType);
88+
throw new InvalidClientException("Unauthorized grant type");
8989
}
9090
}
9191

spring-security-oauth2/src/main/java/org/springframework/security/oauth2/provider/token/DefaultTokenServices.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ public OAuth2AccessToken refreshAccessToken(String refreshTokenValue, TokenReque
146146
throws AuthenticationException {
147147

148148
if (!supportRefreshToken) {
149-
throw new InvalidGrantException("Invalid refresh token: " + refreshTokenValue);
149+
throw new InvalidGrantException("Invalid refresh token");
150150
}
151151

152152
OAuth2RefreshToken refreshToken = tokenStore.readRefreshToken(refreshTokenValue);
153153
if (refreshToken == null) {
154-
throw new InvalidGrantException("Invalid refresh token: " + refreshTokenValue);
154+
throw new InvalidGrantException("Invalid refresh token");
155155
}
156156

157157
OAuth2Authentication authentication = tokenStore.readAuthenticationForRefreshToken(refreshToken);
@@ -174,7 +174,7 @@ public OAuth2AccessToken refreshAccessToken(String refreshTokenValue, TokenReque
174174
}
175175
String clientId = authentication.getOAuth2Request().getClientId();
176176
if (clientId == null || !clientId.equals(tokenRequest.getClientId())) {
177-
throw new InvalidGrantException("Wrong client for this refresh token: " + refreshTokenValue);
177+
throw new InvalidGrantException("Wrong client for this refresh token");
178178
}
179179

180180
// clear out any access tokens already associated with the refresh
@@ -183,7 +183,7 @@ public OAuth2AccessToken refreshAccessToken(String refreshTokenValue, TokenReque
183183

184184
if (isExpired(refreshToken)) {
185185
tokenStore.removeRefreshToken(refreshToken);
186-
throw new InvalidTokenException("Invalid refresh token (expired): " + refreshToken);
186+
throw new InvalidTokenException("Invalid refresh token (expired)");
187187
}
188188

189189
authentication = createRefreshedAuthentication(authentication, tokenRequest);
@@ -248,25 +248,25 @@ public OAuth2Authentication loadAuthentication(String accessTokenValue) throws A
248248
InvalidTokenException {
249249
OAuth2AccessToken accessToken = tokenStore.readAccessToken(accessTokenValue);
250250
if (accessToken == null) {
251-
throw new InvalidTokenException("Invalid access token: " + accessTokenValue);
251+
throw new InvalidTokenException("Invalid access token");
252252
}
253253
else if (accessToken.isExpired()) {
254254
tokenStore.removeAccessToken(accessToken);
255-
throw new InvalidTokenException("Access token expired: " + accessTokenValue);
255+
throw new InvalidTokenException("Access token expired");
256256
}
257257

258258
OAuth2Authentication result = tokenStore.readAuthentication(accessToken);
259259
if (result == null) {
260260
// in case of race condition
261-
throw new InvalidTokenException("Invalid access token: " + accessTokenValue);
261+
throw new InvalidTokenException("Invalid access token");
262262
}
263263
if (clientDetailsService != null) {
264264
String clientId = result.getOAuth2Request().getClientId();
265265
try {
266266
clientDetailsService.loadClientByClientId(clientId);
267267
}
268268
catch (ClientRegistrationException e) {
269-
throw new InvalidTokenException("Client not valid: " + clientId, e);
269+
throw new InvalidTokenException("Client not valid", e);
270270
}
271271
}
272272
return result;
@@ -275,11 +275,11 @@ else if (accessToken.isExpired()) {
275275
public String getClientId(String tokenValue) {
276276
OAuth2Authentication authentication = tokenStore.readAuthentication(tokenValue);
277277
if (authentication == null) {
278-
throw new InvalidTokenException("Invalid access token: " + tokenValue);
278+
throw new InvalidTokenException("Invalid access token");
279279
}
280280
OAuth2Request clientAuth = authentication.getOAuth2Request();
281281
if (clientAuth == null) {
282-
throw new InvalidTokenException("Invalid access token (no client id): " + tokenValue);
282+
throw new InvalidTokenException("Invalid access token (no client id)");
283283
}
284284
return clientAuth.getClientId();
285285
}

0 commit comments

Comments
 (0)