21
21
package password .pwm .http .servlet .oauth ;
22
22
23
23
import org .apache .http .HttpStatus ;
24
- import password .pwm .AppProperty ;
24
+ import password .pwm .DomainProperty ;
25
25
import password .pwm .bean .LoginInfoBean ;
26
26
import password .pwm .bean .ProfileID ;
27
27
import password .pwm .bean .SessionLabel ;
37
37
import password .pwm .http .HttpMethod ;
38
38
import password .pwm .http .PwmRequest ;
39
39
import password .pwm .http .PwmURL ;
40
+ import password .pwm .http .servlet .PwmServletDefinition ;
40
41
import password .pwm .svc .httpclient .PwmHttpClient ;
41
42
import password .pwm .svc .httpclient .PwmHttpClientConfiguration ;
42
43
import password .pwm .svc .httpclient .PwmHttpClientRequest ;
43
44
import password .pwm .svc .httpclient .PwmHttpClientResponse ;
44
- import password .pwm .http .servlet .PwmServletDefinition ;
45
45
import password .pwm .util .BasicAuthInfo ;
46
46
import password .pwm .util .java .CollectionUtil ;
47
47
import password .pwm .util .java .JavaHelper ;
48
- import password .pwm .util .json .JsonFactory ;
49
48
import password .pwm .util .java .StringUtil ;
49
+ import password .pwm .util .json .JsonFactory ;
50
50
import password .pwm .util .logging .PwmLogger ;
51
51
import password .pwm .util .macro .MacroRequest ;
52
52
@@ -84,7 +84,7 @@ static Optional<OAuthRequestState> readOAuthRequestState(
84
84
)
85
85
throws PwmUnrecoverableException
86
86
{
87
- final String requestStateStr = pwmRequest .readParameterAsString ( pwmRequest .getDomainConfig ().readAppProperty ( AppProperty .HTTP_PARAM_OAUTH_STATE ) );
87
+ final String requestStateStr = pwmRequest .readParameterAsString ( pwmRequest .getDomainConfig ().readDomainProperty ( DomainProperty .HTTP_PARAM_OAUTH_STATE ) );
88
88
if ( requestStateStr != null )
89
89
{
90
90
final OAuthState oAuthState = pwmRequest .decryptObject ( requestStateStr , OAuthState .class );
@@ -116,17 +116,17 @@ public void redirectUserToOAuthServer(
116
116
final DomainConfig config = pwmRequest .getDomainConfig ();
117
117
final String state = makeStateStringForRequest ( pwmRequest , nextUrl , forgottenPasswordProfile );
118
118
final String redirectUri = figureOauthSelfEndPointUrl ( pwmRequest );
119
- final String code = config .readAppProperty ( AppProperty .OAUTH_ID_REQUEST_TYPE );
119
+ final String code = config .readDomainProperty ( DomainProperty .OAUTH_ID_REQUEST_TYPE );
120
120
121
121
final Map <String , String > urlParams = new LinkedHashMap <>();
122
- urlParams .put ( config .readAppProperty ( AppProperty .HTTP_PARAM_OAUTH_CLIENT_ID ), settings .getClientID () );
123
- urlParams .put ( config .readAppProperty ( AppProperty .HTTP_PARAM_OAUTH_RESPONSE_TYPE ), code );
124
- urlParams .put ( config .readAppProperty ( AppProperty .HTTP_PARAM_OAUTH_STATE ), state );
125
- urlParams .put ( config .readAppProperty ( AppProperty .HTTP_PARAM_OAUTH_REDIRECT_URI ), redirectUri );
122
+ urlParams .put ( config .readDomainProperty ( DomainProperty .HTTP_PARAM_OAUTH_CLIENT_ID ), settings .getClientID () );
123
+ urlParams .put ( config .readDomainProperty ( DomainProperty .HTTP_PARAM_OAUTH_RESPONSE_TYPE ), code );
124
+ urlParams .put ( config .readDomainProperty ( DomainProperty .HTTP_PARAM_OAUTH_STATE ), state );
125
+ urlParams .put ( config .readDomainProperty ( DomainProperty .HTTP_PARAM_OAUTH_REDIRECT_URI ), redirectUri );
126
126
127
127
if ( StringUtil .notEmpty ( settings .getScope () ) )
128
128
{
129
- urlParams .put ( config .readAppProperty ( AppProperty .HTTP_PARAM_OAUTH_SCOPE ), settings .getScope () );
129
+ urlParams .put ( config .readDomainProperty ( DomainProperty .HTTP_PARAM_OAUTH_SCOPE ), settings .getScope () );
130
130
}
131
131
132
132
if ( userIdentity != null )
@@ -150,16 +150,16 @@ OAuthResolveResults makeOAuthResolveRequest(
150
150
{
151
151
final DomainConfig config = pwmRequest .getDomainConfig ();
152
152
final String requestUrl = settings .getCodeResolveUrl ();
153
- final String grantType = config .readAppProperty ( AppProperty .OAUTH_ID_ACCESS_GRANT_TYPE );
153
+ final String grantType = config .readDomainProperty ( DomainProperty .OAUTH_ID_ACCESS_GRANT_TYPE );
154
154
final String redirectUri = figureOauthSelfEndPointUrl ( pwmRequest );
155
155
final String clientID = settings .getClientID ();
156
156
157
157
final Map <String , String > requestParams = new HashMap <>();
158
- requestParams .put ( config .readAppProperty ( AppProperty .HTTP_PARAM_OAUTH_CODE ), requestCode );
159
- requestParams .put ( config .readAppProperty ( AppProperty .HTTP_PARAM_OAUTH_GRANT_TYPE ), grantType );
160
- requestParams .put ( config .readAppProperty ( AppProperty .HTTP_PARAM_OAUTH_REDIRECT_URI ), redirectUri );
161
- requestParams .put ( config .readAppProperty ( AppProperty .HTTP_PARAM_OAUTH_CLIENT_ID ), clientID );
162
- requestParams .put ( config .readAppProperty ( AppProperty .HTTP_PARAM_OAUTH_CLIENT_SECRET ), settings .getSecret ().getStringValue () );
158
+ requestParams .put ( config .readDomainProperty ( DomainProperty .HTTP_PARAM_OAUTH_CODE ), requestCode );
159
+ requestParams .put ( config .readDomainProperty ( DomainProperty .HTTP_PARAM_OAUTH_GRANT_TYPE ), grantType );
160
+ requestParams .put ( config .readDomainProperty ( DomainProperty .HTTP_PARAM_OAUTH_REDIRECT_URI ), redirectUri );
161
+ requestParams .put ( config .readDomainProperty ( DomainProperty .HTTP_PARAM_OAUTH_CLIENT_ID ), clientID );
162
+ requestParams .put ( config .readDomainProperty ( DomainProperty .HTTP_PARAM_OAUTH_CLIENT_SECRET ), settings .getSecret ().getStringValue () );
163
163
164
164
final PwmHttpClientResponse restResults = makeHttpRequest ( pwmRequest , "oauth code resolver" , settings , requestUrl , requestParams , null );
165
165
@@ -176,9 +176,9 @@ private OAuthResolveResults resolveResultsFromResponseBody(
176
176
)
177
177
{
178
178
final DomainConfig config = pwmRequest .getDomainConfig ();
179
- final String oauthExpiresParam = config .readAppProperty ( AppProperty .HTTP_PARAM_OAUTH_EXPIRES );
180
- final String oauthAccessTokenParam = config .readAppProperty ( AppProperty .HTTP_PARAM_OAUTH_ACCESS_TOKEN );
181
- final String refreshTokenParam = config .readAppProperty ( AppProperty .HTTP_PARAM_OAUTH_REFRESH_TOKEN );
179
+ final String oauthExpiresParam = config .readDomainProperty ( DomainProperty .HTTP_PARAM_OAUTH_EXPIRES );
180
+ final String oauthAccessTokenParam = config .readDomainProperty ( DomainProperty .HTTP_PARAM_OAUTH_ACCESS_TOKEN );
181
+ final String refreshTokenParam = config .readDomainProperty ( DomainProperty .HTTP_PARAM_OAUTH_REFRESH_TOKEN );
182
182
183
183
final long expireSeconds = JavaHelper .silentParseLong ( readAttributeFromBodyMap ( resolveResponseBodyStr , oauthExpiresParam ), 0 );
184
184
final String accessToken = readAttributeFromBodyMap ( resolveResponseBodyStr , oauthAccessTokenParam );
@@ -199,11 +199,11 @@ private OAuthResolveResults makeOAuthRefreshRequest(
199
199
{
200
200
final DomainConfig config = pwmRequest .getDomainConfig ();
201
201
final String requestUrl = settings .getCodeResolveUrl ();
202
- final String grantType = config .readAppProperty ( AppProperty .OAUTH_ID_REFRESH_GRANT_TYPE );
202
+ final String grantType = config .readDomainProperty ( DomainProperty .OAUTH_ID_REFRESH_GRANT_TYPE );
203
203
204
204
final Map <String , String > requestParams = new HashMap <>();
205
- requestParams .put ( config .readAppProperty ( AppProperty .HTTP_PARAM_OAUTH_REFRESH_TOKEN ), refreshCode );
206
- requestParams .put ( config .readAppProperty ( AppProperty .HTTP_PARAM_OAUTH_GRANT_TYPE ), grantType );
205
+ requestParams .put ( config .readDomainProperty ( DomainProperty .HTTP_PARAM_OAUTH_REFRESH_TOKEN ), refreshCode );
206
+ requestParams .put ( config .readDomainProperty ( DomainProperty .HTTP_PARAM_OAUTH_GRANT_TYPE ), grantType );
207
207
208
208
final PwmHttpClientResponse restResults = makeHttpRequest ( pwmRequest , "OAuth refresh resolver" , settings , requestUrl , requestParams , null );
209
209
@@ -221,8 +221,8 @@ String makeOAuthGetUserInfoRequest(
221
221
final DomainConfig config = pwmRequest .getDomainConfig ();
222
222
final String requestUrl = settings .getAttributesUrl ();
223
223
final Map <String , String > requestParams = new HashMap <>();
224
- requestParams .put ( config .readAppProperty ( AppProperty .HTTP_PARAM_OAUTH_ACCESS_TOKEN ), accessToken );
225
- requestParams .put ( config .readAppProperty ( AppProperty .HTTP_PARAM_OAUTH_ATTRIBUTES ), settings .getDnAttributeName () );
224
+ requestParams .put ( config .readDomainProperty ( DomainProperty .HTTP_PARAM_OAUTH_ACCESS_TOKEN ), accessToken );
225
+ requestParams .put ( config .readDomainProperty ( DomainProperty .HTTP_PARAM_OAUTH_ATTRIBUTES ), settings .getDnAttributeName () );
226
226
restResults = makeHttpRequest ( pwmRequest , "OAuth userinfo" , settings , requestUrl , requestParams , accessToken );
227
227
}
228
228
@@ -316,11 +316,11 @@ private static String figureOauthSelfEndPointUrl( final PwmRequest pwmRequest )
316
316
final String redirectUri ;
317
317
318
318
{
319
- final String returnUrlOverride = pwmRequest .getDomainConfig ().readAppProperty ( AppProperty .OAUTH_RETURN_URL_OVERRIDE );
319
+ final String returnUrlOverride = pwmRequest .getDomainConfig ().readDomainProperty ( DomainProperty .OAUTH_RETURN_URL_OVERRIDE );
320
320
final String siteURL = pwmRequest .getDomainConfig ().readSettingAsString ( PwmSetting .PWM_SITE_URL );
321
321
if ( returnUrlOverride != null && !returnUrlOverride .trim ().isEmpty () )
322
322
{
323
- debugSource = "AppProperty (\" " + AppProperty .OAUTH_RETURN_URL_OVERRIDE .getKey () + "\" )" ;
323
+ debugSource = "DomainProperty (\" " + DomainProperty .OAUTH_RETURN_URL_OVERRIDE .getKey () + "\" )" ;
324
324
redirectUri = returnUrlOverride
325
325
+ PwmServletDefinition .OAuthConsumer .servletUrl ();
326
326
}
@@ -358,7 +358,7 @@ public boolean checkOAuthExpiration(
358
358
final PwmRequest pwmRequest
359
359
) throws PwmUnrecoverableException
360
360
{
361
- if ( !Boolean .parseBoolean ( pwmRequest .getDomainConfig ().readAppProperty ( AppProperty .OAUTH_ENABLE_TOKEN_REFRESH ) ) )
361
+ if ( !Boolean .parseBoolean ( pwmRequest .getDomainConfig ().readDomainProperty ( DomainProperty .OAUTH_ENABLE_TOKEN_REFRESH ) ) )
362
362
{
363
363
return false ;
364
364
}
0 commit comments