@@ -105,7 +105,7 @@ protected void processAction( final PwmRequest pwmRequest )
105
105
pwmRequest .getPwmResponse ().sendRedirect ( nextUrl );
106
106
return ;
107
107
}
108
- final String errorMsg = "oauth consumer reached, but oauth authentication has not yet been initiated. " ;
108
+ final String errorMsg = "oauth consumer reached, but oauth authentication has not yet been initiated" ;
109
109
final ErrorInformation errorInformation = new ErrorInformation ( PwmError .ERROR_OAUTH_ERROR , errorMsg );
110
110
pwmRequest .respondWithError ( errorInformation );
111
111
LOGGER .error ( pwmRequest , () -> errorMsg );
@@ -118,9 +118,9 @@ protected void processAction( final PwmRequest pwmRequest )
118
118
final String oauthRequestError = pwmRequest .readParameterAsString ( "error" );
119
119
if ( oauthRequestError != null && !oauthRequestError .isEmpty () )
120
120
{
121
- final String errorMsg = "incoming request from remote oauth server is indicating an error: " + oauthRequestError ;
122
- final ErrorInformation errorInformation = new ErrorInformation ( PwmError .ERROR_OAUTH_ERROR , errorMsg , "Remote Error: " + oauthRequestError , null );
123
- LOGGER .error ( pwmRequest , () -> errorMsg );
121
+ final String errorMsg = "incoming request from remote oauth server has indicated an error" ;
122
+ final ErrorInformation errorInformation = new ErrorInformation ( PwmError .ERROR_OAUTH_ERROR , errorMsg );
123
+ LOGGER .error ( pwmRequest , () -> errorMsg + ": " + oauthRequestError );
124
124
pwmRequest .respondWithError ( errorInformation );
125
125
return ;
126
126
}
@@ -131,19 +131,18 @@ protected void processAction( final PwmRequest pwmRequest )
131
131
{
132
132
switch ( oAuthUseCaseCase )
133
133
{
134
- case Authentication :
135
- LOGGER .debug ( pwmRequest , () -> "oauth consumer reached, but user is already authenticated; will proceed and verify authcode matches current user identity." );
136
- break ;
137
-
138
- case ForgottenPassword :
134
+ case Authentication ->
135
+ LOGGER .debug ( pwmRequest , () -> "oauth consumer reached, but user is already authenticated; "
136
+ + "will proceed and verify authcode matches current user identity." ) ;
137
+ case ForgottenPassword ->
138
+ {
139
139
final String errorMsg = "oauth consumer reached via " + OAuthUseCase .ForgottenPassword + ", but user is already authenticated" ;
140
140
final ErrorInformation errorInformation = new ErrorInformation ( PwmError .ERROR_OAUTH_ERROR , errorMsg );
141
141
pwmRequest .respondWithError ( errorInformation );
142
142
LOGGER .error ( pwmRequest , () -> errorMsg );
143
143
return ;
144
-
145
- default :
146
- PwmUtil .unhandledSwitchStatement ( oAuthUseCaseCase );
144
+ }
145
+ default -> PwmUtil .unhandledSwitchStatement ( oAuthUseCaseCase );
147
146
}
148
147
149
148
}
@@ -276,9 +275,9 @@ protected void processAction( final PwmRequest pwmRequest )
276
275
}
277
276
catch ( final PwmOperationalException e )
278
277
{
279
- final String errorMsg = "error while examining incoming oauth code for already authenticated session: " + e . getMessage () ;
278
+ final String errorMsg = "error while examining incoming oauth code for already authenticated session" ;
280
279
final ErrorInformation errorInformation = new ErrorInformation ( PwmError .ERROR_OAUTH_ERROR , errorMsg );
281
- LOGGER .error ( pwmRequest , () -> errorMsg );
280
+ LOGGER .error ( pwmRequest , () -> errorMsg + ": " + e . getMessage () );
282
281
pwmRequest .respondWithError ( errorInformation );
283
282
return ;
284
283
}
@@ -302,8 +301,9 @@ protected void processAction( final PwmRequest pwmRequest )
302
301
}
303
302
catch ( final PwmException e )
304
303
{
305
- LOGGER .error ( pwmRequest , () -> "error during OAuth authentication attempt: " + e .getMessage () );
306
- final ErrorInformation errorInformation = new ErrorInformation ( PwmError .ERROR_OAUTH_ERROR , e .getMessage () );
304
+ final String errorMsg = "error during OAuth authentication attempt" ;
305
+ LOGGER .error ( pwmRequest , () -> errorMsg + ": " + e .getMessage () );
306
+ final ErrorInformation errorInformation = new ErrorInformation ( PwmError .ERROR_OAUTH_ERROR , errorMsg );
307
307
pwmRequest .respondWithError ( errorInformation );
308
308
return ;
309
309
}
@@ -316,17 +316,17 @@ private static OAuthSettings makeOAuthSettings( final PwmRequest pwmRequest, fin
316
316
final OAuthUseCase oAuthUseCase = oAuthState .getUseCase ();
317
317
switch ( oAuthUseCase )
318
318
{
319
- case Authentication :
319
+ case Authentication ->
320
+ {
320
321
return OAuthSettings .forSSOAuthentication ( pwmRequest .getDomainConfig () );
321
-
322
- case ForgottenPassword :
322
+ }
323
+ case ForgottenPassword ->
324
+ {
323
325
final ProfileID profileId = oAuthState .getForgottenProfileId ();
324
326
final ForgottenPasswordProfile profile = pwmRequest .getDomainConfig ().getForgottenPasswordProfiles ().get ( profileId );
325
327
return OAuthSettings .forForgottenPassword ( profile );
326
-
327
- default :
328
- PwmUtil .unhandledSwitchStatement ( oAuthUseCase );
329
-
328
+ }
329
+ default -> PwmUtil .unhandledSwitchStatement ( oAuthUseCase );
330
330
}
331
331
332
332
final String errorMsg = "unable to calculate oauth settings for incoming request state" ;
@@ -335,7 +335,8 @@ private static OAuthSettings makeOAuthSettings( final PwmRequest pwmRequest, fin
335
335
throw new PwmUnrecoverableException ( errorInformation );
336
336
}
337
337
338
- private void redirectToForgottenPasswordServlet ( final PwmRequest pwmRequest , final String oauthSuppliedUsername ) throws IOException , PwmUnrecoverableException
338
+ private void redirectToForgottenPasswordServlet ( final PwmRequest pwmRequest , final String oauthSuppliedUsername )
339
+ throws IOException , PwmUnrecoverableException
339
340
{
340
341
final OAuthForgottenPasswordResults results = new OAuthForgottenPasswordResults ( true , oauthSuppliedUsername );
341
342
final String encryptedResults = pwmRequest .getPwmDomain ().getSecureService ().encryptObjectToString ( results );
0 commit comments