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

Commit 2b58aaf

Browse files
committed
Polish gh-1941
1 parent e96d2c7 commit 2b58aaf

File tree

19 files changed

+28
-31
lines changed

19 files changed

+28
-31
lines changed

samples/oauth2/sparklr/src/main/java/org/springframework/security/oauth/examples/sparklr/mvc/AdminController.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ private void checkResourceOwner(String user, Principal principal) {
9797
if (principal instanceof OAuth2Authentication) {
9898
OAuth2Authentication authentication = (OAuth2Authentication) principal;
9999
if (!authentication.isClientOnly() && !user.equals(principal.getName())) {
100-
throw new AccessDeniedException(String.format("User '%s' cannot obtain tokens for user '%s'",
101-
principal.getName(), user));
100+
throw new AccessDeniedException("User cannot obtain tokens for user");
102101
}
103102
}
104103
}

spring-security-oauth/src/main/java/org/springframework/security/oauth/config/ConsumerDetailsFactoryBean.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ public ConsumerDetails getObject() throws Exception {
9696
consumer.setSignatureSecret(new RSAKeySecret(cert.getPublicKey()));
9797
}
9898
catch (IOException e) {
99-
throw new BeanCreationException("RSA certificate not found at " + secret + ".",
99+
throw new BeanCreationException("RSA certificate not found",
100100
e);
101101
}
102102
catch (CertificateException e) {
103-
throw new BeanCreationException("Invalid RSA certificate at " + secret + ".", e);
103+
throw new BeanCreationException("Invalid RSA certificate", e);
104104
}
105105
catch (NullPointerException e) {
106-
throw new BeanCreationException("Could not load RSA certificate at " + secret + ".", e);
106+
throw new BeanCreationException("Could not load RSA certificate", e);
107107
}
108108
finally {
109109
try {

spring-security-oauth/src/main/java/org/springframework/security/oauth/consumer/client/CoreOAuthConsumerSupport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public OAuthConsumerToken getAccessToken(ProtectedResourceDetails details, OAuth
138138
Map<String, String> additionalParameters = new TreeMap<String, String>();
139139
if (details.isUse10a()) {
140140
if (verifier == null) {
141-
throw new UnverifiedRequestTokenException("Unverified request token: " + requestToken);
141+
throw new UnverifiedRequestTokenException("Unverified request token");
142142
}
143143
additionalParameters.put(OAuthConsumerParameter.oauth_verifier.toString(), verifier);
144144
}

spring-security-oauth/src/main/java/org/springframework/security/oauth/provider/InMemoryConsumerDetailsService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class InMemoryConsumerDetailsService implements ConsumerDetailsService {
3737
public ConsumerDetails loadConsumerByConsumerKey(String consumerKey) throws OAuthException {
3838
ConsumerDetails details = consumerDetailsStore.get(consumerKey);
3939
if (details == null) {
40-
throw new InvalidOAuthParametersException("Consumer not found: " + consumerKey);
40+
throw new InvalidOAuthParametersException("Consumer not found");
4141
}
4242
return details;
4343
}

spring-security-oauth/src/main/java/org/springframework/security/oauth/provider/filter/UserAuthorizationProcessingFilter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ public Authentication attemptAuthentication(HttpServletRequest request, HttpServ
8080

8181
OAuthProviderToken token = getTokenServices().getToken(requestToken);
8282
if (token == null) {
83-
throw new InvalidOAuthTokenException("No callback value has been provided for request token " + requestToken + ".");
83+
throw new InvalidOAuthTokenException("No callback value has been provided for request token");
8484
}
8585

8686
String callbackURL = token.getCallbackUrl();
8787
if (isRequire10a() && callbackURL == null) {
88-
throw new InvalidOAuthTokenException("No callback value has been provided for request token " + requestToken + ".");
88+
throw new InvalidOAuthTokenException("No callback value has been provided for request token");
8989
}
9090

9191
if (callbackURL != null) {

spring-security-oauth/src/main/java/org/springframework/security/oauth/provider/nonce/InMemoryNonceServices.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void validateNonce(ConsumerDetails consumerDetails, long timestamp, Strin
6565

6666
synchronized (NONCES) {
6767
if (NONCES.contains(entry)) {
68-
throw new NonceAlreadyUsedException("Nonce already used: " + nonce);
68+
throw new NonceAlreadyUsedException("Nonce already used");
6969
}
7070
else {
7171
NONCES.add(entry);

spring-security-oauth/src/main/java/org/springframework/security/oauth/provider/token/RandomValueProviderTokenServices.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public OAuthProviderToken getToken(String token) throws AuthenticationException
8484
OAuthProviderTokenImpl tokenImpl = readToken(token);
8585

8686
if (tokenImpl == null) {
87-
throw new InvalidOAuthTokenException("Invalid token: " + token);
87+
throw new InvalidOAuthTokenException("Invalid token");
8888
}
8989
else if (isExpired(tokenImpl)) {
9090
removeToken(token);
@@ -138,7 +138,7 @@ public void authorizeRequestToken(String requestToken, String verifier, Authenti
138138
OAuthProviderTokenImpl tokenImpl = readToken(requestToken);
139139

140140
if (tokenImpl == null) {
141-
throw new InvalidOAuthTokenException("Invalid token: " + requestToken);
141+
throw new InvalidOAuthTokenException("Invalid token");
142142
}
143143
else if (isExpired(tokenImpl)) {
144144
removeToken(requestToken);
@@ -159,7 +159,7 @@ public OAuthAccessProviderToken createAccessToken(String requestToken) throws Au
159159
OAuthProviderTokenImpl tokenImpl = readToken(requestToken);
160160

161161
if (tokenImpl == null) {
162-
throw new InvalidOAuthTokenException("Invalid token: " + requestToken);
162+
throw new InvalidOAuthTokenException("Invalid token");
163163
}
164164
else if (isExpired(tokenImpl)) {
165165
removeToken(requestToken);

spring-security-oauth2/src/main/java/org/springframework/security/oauth2/http/converter/jaxb/AbstractJaxbMessageConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected final void writeToResult(E accessToken, HttpHeaders headers, Result re
8484
createMarshaller().marshal(convertedAccessToken, result);
8585
}
8686
catch (MarshalException ex) {
87-
throw new HttpMessageNotWritableException("Could not marshal [" + accessToken + "]: " + ex.getMessage(), ex);
87+
throw new HttpMessageNotWritableException("Could not marshal accessToken: " + ex.getMessage(), ex);
8888
}
8989
catch (JAXBException ex) {
9090
throw new HttpMessageConversionException("Could not instantiate JAXBContext: " + ex.getMessage(), ex);

spring-security-oauth2/src/main/java/org/springframework/security/oauth2/provider/approval/ApprovalStoreUserApprovalHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public AuthorizationRequest checkForPreApproval(AuthorizationRequest authorizati
135135
}
136136
}
137137
catch (ClientRegistrationException e) {
138-
logger.warn("Client registration problem prevent autoapproval check for client=" + clientId);
138+
logger.warn("Client registration problem prevent autoapproval check for client");
139139
}
140140
}
141141

spring-security-oauth2/src/main/java/org/springframework/security/oauth2/provider/authentication/OAuth2AuthenticationManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public Authentication authenticate(Authentication authentication) throws Authent
8686
String token = (String) authentication.getPrincipal();
8787
OAuth2Authentication auth = tokenServices.loadAuthentication(token);
8888
if (auth == null) {
89-
throw new InvalidTokenException("Invalid token: " + token);
89+
throw new InvalidTokenException("Invalid token");
9090
}
9191

9292
Collection<String> resourceIds = auth.getOAuth2Request().getResourceIds();
@@ -123,7 +123,7 @@ private void checkClientDetails(OAuth2Authentication auth) {
123123
for (String scope : auth.getOAuth2Request().getScope()) {
124124
if (!allowed.contains(scope)) {
125125
throw new OAuth2AccessDeniedException(
126-
"Invalid token contains disallowed scope (" + scope + ") for this client");
126+
"Invalid token contains disallowed scope for this client");
127127
}
128128
}
129129
}

0 commit comments

Comments
 (0)