Changeset 19008 in josm for trunk/src/org/openstreetmap/josm/gui/oauth/OAuthAuthorizationWizard.java
- Timestamp:
- 2024-03-06T15:07:01+01:00 (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/oauth/OAuthAuthorizationWizard.java
r18991 r19008 84 84 if ((this.oAuthVersion == OAuthVersion.OAuth20 || this.oAuthVersion == OAuthVersion.OAuth21) 85 85 && this.procedure == AuthorizationProcedure.FULLY_AUTOMATIC) { 86 authorize(true, callback, this.apiUrl, this.oAuthVersion );86 authorize(true, callback, this.apiUrl, this.oAuthVersion, getOAuthParameters()); 87 87 } else { 88 88 setVisible(true); … … 90 90 throw new UserCancelException(); 91 91 } 92 }93 OAuthAccessTokenHolder holder = OAuthAccessTokenHolder.getInstance();94 holder.setAccessToken(apiUrl, getAccessToken());95 holder.setSaveToPreferences(isSaveAccessTokenToPreferences());92 OAuthAccessTokenHolder holder = OAuthAccessTokenHolder.getInstance(); 93 holder.setAccessToken(apiUrl, getAccessToken()); 94 holder.setSaveToPreferences(isSaveAccessTokenToPreferences()); 95 } 96 96 } 97 97 98 98 /** 99 99 * Perform the oauth dance 100 * 100 101 * @param startRemoteControl {@code true} to start remote control if it is not already running 101 * @param callback The callback to use to notify that the OAuth dance succeeded 102 * @param apiUrl The API URL to get the token for 103 * @param oAuthVersion The OAuth version that the authorization dance is force 104 */ 105 static void authorize(boolean startRemoteControl, Consumer<Optional<IOAuthToken>> callback, String apiUrl, OAuthVersion oAuthVersion) { 102 * @param callback The callback to use to notify that the OAuth dance succeeded 103 * @param apiUrl The API URL to get the token for 104 * @param oAuthVersion The OAuth version that the authorization dance is force 105 * @param oAuthParameters The OAuth parameters to use 106 */ 107 static void authorize(boolean startRemoteControl, Consumer<Optional<IOAuthToken>> callback, String apiUrl, 108 OAuthVersion oAuthVersion, IOAuthParameters oAuthParameters) { 106 109 final boolean remoteControlIsRunning = Boolean.TRUE.equals(RemoteControl.PROP_REMOTECONTROL_ENABLED.get()); 107 110 // TODO: Ask user if they want to start remote control? … … 109 112 RemoteControl.start(); 110 113 } 111 new OAuth20Authorization().authorize(OAuthParameters.createDefault(apiUrl, oAuthVersion), token -> { 114 new OAuth20Authorization().authorize( 115 Optional.ofNullable(oAuthParameters).orElseGet(() -> OAuthParameters.createDefault(apiUrl, oAuthVersion)), 116 token -> { 112 117 if (!remoteControlIsRunning) { 113 118 RemoteControl.stop(); … … 253 258 * Creates the wizard. 254 259 * 255 * @param parent the component relative to which the dialog is displayed 256 * @param procedure the authorization procedure to use 257 * @param apiUrl the API URL. Must not be null. 258 * @param executor the executor used for running the HTTP requests for the authorization 259 * @param oAuthVersion The OAuth version this wizard is for 260 * @param parent the component relative to which the dialog is displayed 261 * @param procedure the authorization procedure to use 262 * @param apiUrl the API URL. Must not be null. 263 * @param executor the executor used for running the HTTP requests for the authorization 264 * @param oAuthVersion The OAuth version this wizard is for 265 * @param advancedParameters The OAuth parameters to initialize the wizard with 260 266 * @throws IllegalArgumentException if apiUrl is null 261 267 */ 262 268 public OAuthAuthorizationWizard(Component parent, AuthorizationProcedure procedure, String apiUrl, 263 Executor executor, OAuthVersion oAuthVersion ) {269 Executor executor, OAuthVersion oAuthVersion, IOAuthParameters advancedParameters) { 264 270 super(GuiHelper.getFrameForComponent(parent), ModalityType.DOCUMENT_MODAL); 265 271 this.procedure = Objects.requireNonNull(procedure, "procedure"); … … 268 274 this.oAuthVersion = oAuthVersion; 269 275 build(); 276 if (advancedParameters != null) { 277 pnlFullyAutomaticAuthorisationUI.getAdvancedPropertiesPanel().setAdvancedParameters(advancedParameters); 278 pnlManualAuthorisationUI.getAdvancedPropertiesPanel().setAdvancedParameters(advancedParameters); 279 } 270 280 } 271 281 … … 362 372 AuthorizationProcedure.FULLY_AUTOMATIC, 363 373 serverUrl.toString(), Utils.newDirectExecutor(), 364 OAuthVersion.OAuth20 );374 OAuthVersion.OAuth20, null); 365 375 wizard.showDialog(null); 366 376 return wizard;
Note:
See TracChangeset
for help on using the changeset viewer.