List of usage examples for org.springframework.ide.eclipse.boot.dash.dialogs StoreCredentialsMode STORE_NOTHING
StoreCredentialsMode STORE_NOTHING
To view the source code for org.springframework.ide.eclipse.boot.dash.dialogs StoreCredentialsMode STORE_NOTHING.
Click Source Link
From source file:org.springframework.ide.eclipse.boot.dash.cloudfoundry.CloudFoundryTargetWizardModel.java
/** * Create target properties based on current input values in the wizard. * <p>/* w w w . j av a 2s. c o m*/ * Note that there are two slightly different ways to produce these properties. * <p> * a) to create a intermediate client just to fetch orgs and spaces. * <p> * b) the final properties used to create the client after space is selected and the user * clicks 'finish' button. */ private CloudFoundryTargetProperties createTargetProperties(boolean toFetchSpaces) throws CannotAccessPropertyException { CloudFoundryTargetProperties targetProps = new CloudFoundryTargetProperties(runTargetType, context); if (!toFetchSpaces) { //Take care: when fetching spaces the space may not be known yet, so neither is the id String id = CloudFoundryTargetProperties.getId(this.getUsername(), this.getUrl(), this.getOrganizationName(), this.getSpaceName()); targetProps.put(TargetProperties.RUN_TARGET_ID, id); } targetProps.setUrl(url.getValue()); targetProps.setSelfSigned(selfsigned.getValue()); targetProps.setSkipSslValidation(skipSslValidation.getValue()); targetProps.setUserName(userName.getValue()); if (toFetchSpaces) { targetProps.setStoreCredentials(StoreCredentialsMode.STORE_NOTHING); targetProps.setCredentials(CFCredentials.fromLogin(method.getValue(), password.getValue())); } else { //use credentials of a style that is consistent with the 'store mode'. if (method.getValue() == LoginMethod.TEMPORARY_CODE && storeCredentials.getValue() == StoreCredentialsMode.STORE_PASSWORD) { //The one token shouldn't be stored since its meaningless. Silently downgrade storemode to store storeCredentials.setValue(StoreCredentialsMode.STORE_NOTHING); } StoreCredentialsMode mode = storeCredentials.getValue(); targetProps.setStoreCredentials(storeCredentials.getValue()); switch (mode) { case STORE_NOTHING: case STORE_TOKEN: Assert.isTrue(refreshToken != null); targetProps.setCredentials(CFCredentials.fromRefreshToken(refreshToken)); break; case STORE_PASSWORD: targetProps.setCredentials(CFCredentials.fromPassword(password.getValue())); break; default: throw new IllegalStateException("BUG: Missing switch case?"); } } targetProps.setSpace(space.getValue()); return targetProps; }
From source file:org.springframework.ide.eclipse.boot.dash.cloudfoundry.CloudFoundryTargetWizardModel.java
public CloudFoundryRunTarget finish() throws Exception { CloudFoundryTargetProperties targetProps = null; try {// w ww. ja v a2 s . co m targetProps = createTargetProperties(/*toFetchSpaces*/false); } catch (Exception e) { final StorageException storageException = getStorageException(e); // Allow run target to be created on storage exceptions as the run target can still be created and connected if (storageException != null) { Log.log(storageException); if (interactions != null) { String message = "Failed to store credentials in secure storage. Please check your secure storage preferences. Error: " + storageException.getMessage(); interactions.informationPopup("Secure Storage Error", message); } storeCredentials.setValue(StoreCredentialsMode.STORE_NOTHING); targetProps = createTargetProperties(/*toFetchSpaces*/false); } else { throw e; } } return (CloudFoundryRunTarget) runTargetType.createRunTarget(targetProps); }