Skip to content
This repository was archived by the owner on Dec 12, 2018. It is now read-only.

Commit bedafdd

Browse files
authored
Merge pull request #1131 from stormpath/Issue-1126-1.2.x
issue 1126 - improved AccessTokenController error handling to elimina…
2 parents 49c13a5 + 26a6bd9 commit bedafdd

3 files changed

Lines changed: 32 additions & 4 deletions

File tree

extensions/servlet/src/main/java/com/stormpath/sdk/servlet/mvc/AccessTokenController.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ private AccessTokenResult refreshTokenAuthenticationRequest(HttpServletRequest r
244244
* @since 1.0.0
245245
*/
246246
private AccessTokenResult clientCredentialsAuthenticationRequest(HttpServletRequest request, HttpServletResponse response) {
247-
DefaultBasicApiAuthenticationRequest authenticationRequest = new DefaultBasicApiAuthenticationRequest(new DefaultHttpServletRequestWrapper(request));
248-
249247
OAuthGrantRequestAuthenticationResult authenticationResult;
250248

251249
try {
250+
DefaultBasicApiAuthenticationRequest authenticationRequest = new DefaultBasicApiAuthenticationRequest(new DefaultHttpServletRequestWrapper(request));
251+
252252
Application app = getApplication(request);
253253
OAuthClientCredentialsGrantRequestAuthentication clientCredentialsGrantRequestAuthentication =
254254
OAuthRequests.OAUTH_CLIENT_CREDENTIALS_GRANT_REQUEST.builder()
@@ -287,6 +287,8 @@ private AccessTokenResult stormpathSocialAuthenticationRequest(HttpServletReques
287287
} catch (ResourceException e) {
288288
log.debug("Unable to authenticate stormpath social grant request: {}", e.getMessage(), e);
289289
throw convertToOAuthException(e, OAuthErrorCode.INVALID_CLIENT);
290+
} catch (IllegalArgumentException ex) {
291+
throw new OAuthException(OAuthErrorCode.INVALID_REQUEST);
290292
}
291293

292294
return createAccessTokenResult(request, response, authenticationResult);

extensions/spring/boot/stormpath-webmvc-spring-boot-starter/src/main/java/com/stormpath/spring/boot/autoconfigure/StormpathWebMvcAutoConfiguration.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
import com.stormpath.sdk.servlet.filter.account.JwtSigningKeyResolver;
4545
import com.stormpath.sdk.servlet.filter.oauth.AccessTokenAuthenticationRequestFactory;
4646
import com.stormpath.sdk.servlet.filter.oauth.AccessTokenResultFactory;
47+
import com.stormpath.sdk.servlet.filter.oauth.RefreshTokenAuthenticationRequestFactory;
48+
import com.stormpath.sdk.servlet.filter.oauth.RefreshTokenResultFactory;
4749
import com.stormpath.sdk.servlet.http.MediaType;
4850
import com.stormpath.sdk.servlet.http.Resolver;
4951
import com.stormpath.sdk.servlet.http.Saver;
@@ -291,6 +293,12 @@ public AccessTokenResultFactory stormpathAccessTokenResultFactory() {
291293
return super.stormpathAccessTokenResultFactory();
292294
}
293295

296+
@Bean
297+
@ConditionalOnMissingBean
298+
public RefreshTokenResultFactory stormpathRefreshTokenResultFactory() {
299+
return super.stormpathRefreshTokenResultFactory();
300+
}
301+
294302
@Bean
295303
@ConditionalOnMissingBean
296304
public WrappedServletRequestFactory stormpathWrappedServletRequestFactory() {
@@ -487,6 +495,12 @@ public AccessTokenAuthenticationRequestFactory stormpathAccessTokenAuthenticatio
487495
return super.stormpathAccessTokenAuthenticationRequestFactory();
488496
}
489497

498+
@Bean
499+
@ConditionalOnMissingBean
500+
public RefreshTokenAuthenticationRequestFactory stormpathRefreshTokenAuthenticationRequestFactory() {
501+
return super.stormpathRefreshTokenAuthenticationRequestFactory();
502+
}
503+
490504
@Bean
491505
@ConditionalOnMissingBean(name = "stormpathAccessTokenRequestAuthorizer")
492506
public RequestAuthorizer stormpathAccessTokenRequestAuthorizer() {
@@ -526,7 +540,7 @@ public Controller stormpathMeController() {
526540

527541
@Bean
528542
@ConditionalOnMissingBean
529-
public ExpandsResolver stormpathMeExpandsResolver(){
543+
public ExpandsResolver stormpathMeExpandsResolver() {
530544
return super.stormpathMeExpandsResolver();
531545
}
532546

@@ -654,7 +668,7 @@ public ControllerConfig stormpathVerifyConfig() {
654668
*/
655669
@Bean
656670
@ConditionalOnMissingBean(name = "stormpathAccessTokenConfig")
657-
public AccessTokenControllerConfig stormpathAccessTokenConfig(){
671+
public AccessTokenControllerConfig stormpathAccessTokenConfig() {
658672
return super.stormpathAccessTokenConfig();
659673
}
660674

extensions/spring/stormpath-spring-webmvc/src/main/java/com/stormpath/spring/config/StormpathWebMvcConfiguration.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
import com.stormpath.sdk.servlet.filter.account.JwtSigningKeyResolver;
4444
import com.stormpath.sdk.servlet.filter.oauth.AccessTokenAuthenticationRequestFactory;
4545
import com.stormpath.sdk.servlet.filter.oauth.AccessTokenResultFactory;
46+
import com.stormpath.sdk.servlet.filter.oauth.RefreshTokenAuthenticationRequestFactory;
47+
import com.stormpath.sdk.servlet.filter.oauth.RefreshTokenResultFactory;
4648
import com.stormpath.sdk.servlet.http.MediaType;
4749
import com.stormpath.sdk.servlet.http.Resolver;
4850
import com.stormpath.sdk.servlet.http.Saver;
@@ -246,6 +248,11 @@ public AccessTokenResultFactory stormpathAccessTokenResultFactory() {
246248
return super.stormpathAccessTokenResultFactory();
247249
}
248250

251+
@Bean
252+
public RefreshTokenResultFactory stormpathRefreshTokenResultFactory(){
253+
return super.stormpathRefreshTokenResultFactory();
254+
}
255+
249256
@Bean
250257
public WrappedServletRequestFactory stormpathWrappedServletRequestFactory() {
251258
return super.stormpathWrappedServletRequestFactory();
@@ -422,6 +429,11 @@ public AccessTokenAuthenticationRequestFactory stormpathAccessTokenAuthenticatio
422429
return super.stormpathAccessTokenAuthenticationRequestFactory();
423430
}
424431

432+
@Bean
433+
public RefreshTokenAuthenticationRequestFactory stormpathRefreshTokenAuthenticationRequestFactory(){
434+
return super.stormpathRefreshTokenAuthenticationRequestFactory();
435+
}
436+
425437
@Bean
426438
public RequestAuthorizer stormpathAccessTokenRequestAuthorizer() {
427439
return super.stormpathAccessTokenRequestAuthorizer();

0 commit comments

Comments
 (0)