org.cloudfoundry.client.lib.CloudCredentials Java Examples

The following examples show how to use org.cloudfoundry.client.lib.CloudCredentials. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 6 votes vote down vote up
public CloudControllerRestClientImpl(URL controllerUrl, CloudCredentials credentials, RestTemplate restTemplate,
                                     OAuthClient oAuthClient, CloudFoundryClient delegate, DopplerClient dopplerClient,
                                     CloudSpace target) {
    Assert.notNull(controllerUrl, "CloudControllerUrl cannot be null");
    Assert.notNull(restTemplate, "RestTemplate cannot be null");
    Assert.notNull(oAuthClient, "OAuthClient cannot be null");

    this.controllerUrl = controllerUrl;
    this.credentials = credentials;
    this.restTemplate = restTemplate;
    this.oAuthClient = oAuthClient;
    this.target = target;

    this.delegate = delegate;
    this.dopplerClient = dopplerClient;
}
 
Example #2
Source File: PreferencePage.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    String msg = StringUtil.format("Testing connection to \"{0}\"...", _server); // $NLX-PreferencePage.Testingconnectionto0-1$
    monitor.beginTask(msg, IProgressMonitor.UNKNOWN);
    try {
        CloudCredentials credentials = new CloudCredentials(_userName, _password);
        CloudFoundryClient client = new CloudFoundryClient(credentials, URI.create(_server).toURL());
        client.login();
    } catch (Throwable e) {       
        throw new InvocationTargetException(e);
    }            
    
    if (monitor.isCanceled()) {
        throw new InterruptedException();
    }
}
 
Example #3
Source File: CloudControllerRestClientFactory.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
public CloudControllerRestClient createClient(URL controllerUrl, CloudCredentials credentials, String organizationName,
                                              String spaceName, OAuthClient oAuthClient) {
    CloudControllerRestClient clientWithoutTarget = createClient(controllerUrl, credentials, oAuthClient);
    CloudSpace target = clientWithoutTarget.getSpace(organizationName, spaceName);

    return createClient(controllerUrl, credentials, target, oAuthClient);
}
 
Example #4
Source File: CloudControllerRestClientFactory.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
public CloudControllerRestClient createClient(URL controllerUrl, CloudCredentials credentials, CloudSpace target,
                                              OAuthClient oAuthClient) {
    RestTemplate restTemplate = createAuthorizationSettingRestTemplate(credentials, oAuthClient);
    CloudFoundryClient delegate = getCloudFoundryClientFactory().createClient(controllerUrl, oAuthClient);
    DopplerClient dopplerClient = getCloudFoundryClientFactory().createDopplerClient(controllerUrl, oAuthClient);

    return new CloudControllerRestClientImpl(controllerUrl, credentials, restTemplate, oAuthClient, delegate, dopplerClient, target);
}
 
Example #5
Source File: OAuthClient.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
public void init(CloudCredentials credentials) {
    if (credentials != null) {
        this.credentials = credentials;

        if (credentials.getToken() != null) {
            this.token = credentials.getToken();
        } else {
            this.token = createToken();
        }
    }
}
 
Example #6
Source File: DataTerminationService.java    From multiapps-controller with Apache License 2.0 5 votes vote down vote up
private CloudControllerClientImpl getCFClient() {
    CloudCredentials cloudCredentials = new CloudCredentials(configuration.getGlobalAuditorUser(),
                                                             configuration.getGlobalAuditorPassword(),
                                                             SecurityUtil.CLIENT_ID,
                                                             SecurityUtil.CLIENT_SECRET,
                                                             AUTH_ORIGIN);

    CloudControllerClientImpl cfClient = new CloudControllerClientImpl(configuration.getControllerUrl(),
                                                                       cloudCredentials,
                                                                       configuration.shouldSkipSslValidation());
    cfClient.login();
    return cfClient;
}
 
Example #7
Source File: CloudFoundryClientFactory.java    From multiapps-controller with Apache License 2.0 5 votes vote down vote up
@Override
protected CloudControllerClient createClient(CloudCredentials credentials, String spaceId) {
    CloudSpace target = computeTarget(credentials, spaceId);
    OAuthClient oAuthClient = oAuthClientFactory.createOAuthClient();
    CloudControllerRestClient controllerClient = clientFactory.createClient(configuration.getControllerUrl(), credentials, target,
                                                                            oAuthClient);
    addTaggingInterceptor(controllerClient.getRestTemplate(), target.getOrganization()
                                                                    .getName(),
                          target.getName());
    return new ResilientCloudControllerClient(controllerClient);
}
 
Example #8
Source File: CloudControllerRestClientHttpRequestFactory.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
public CloudControllerRestClientHttpRequestFactory(ClientHttpRequestFactory delegate, CloudCredentials credentials,
                                                   OAuthClient oAuthClient) {
    this.delegate = delegate;
    this.credentials = credentials;
    this.oAuthClient = oAuthClient;
    captureDefaultReadTimeout();
}
 
Example #9
Source File: CloudFoundryClientFactory.java    From multiapps-controller with Apache License 2.0 5 votes vote down vote up
@Override
protected CloudControllerClient createClient(CloudCredentials credentials) {
    OAuthClient oAuthClient = oAuthClientFactory.createOAuthClient();
    CloudControllerRestClient controllerClient = clientFactory.createClient(configuration.getControllerUrl(), credentials, null,
                                                                            oAuthClient);
    addTaggingInterceptor(controllerClient.getRestTemplate());
    return new ResilientCloudControllerClient(controllerClient);
}
 
Example #10
Source File: CloudFoundryClientFactory.java    From multiapps-controller with Apache License 2.0 5 votes vote down vote up
@Override
protected CloudControllerClient createClient(CloudCredentials credentials, String org, String space) {
    OAuthClient oAuthClient = oAuthClientFactory.createOAuthClient();
    CloudControllerRestClient controllerClient = clientFactory.createClient(configuration.getControllerUrl(), credentials, org, space,
                                                                            oAuthClient);
    addTaggingInterceptor(controllerClient.getRestTemplate(), org, space);
    return new ResilientCloudControllerClient(controllerClient);
}
 
Example #11
Source File: TokenProviderFactory.java    From multiapps-controller with Apache License 2.0 4 votes vote down vote up
private static CloudCredentials createCredentials(String userName, String password) {
    return new CloudCredentials(userName, password, SecurityUtil.CLIENT_ID, SecurityUtil.CLIENT_SECRET);
}
 
Example #12
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 4 votes vote down vote up
public CloudControllerRestClientImpl(URL controllerUrl, CloudCredentials credentials, RestTemplate restTemplate,
                                     OAuthClient oAuthClient, CloudFoundryClient delegate) {
    this(controllerUrl, credentials, restTemplate, oAuthClient, delegate, null, null);
}
 
Example #13
Source File: AbstractBluemixWizard.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
public AbstractBluemixWizard() {
    super(BluemixPlugin.getImageDescriptor("wizban_bluemix.png")); // $NON-NLS-1$
    String user = PreferencePage.getSecurePreference(KEY_BLUEMIX_SERVER_USERNAME, "");
    String password = PreferencePage.getSecurePreference(KEY_BLUEMIX_SERVER_PASSWORD, "");
    _credentials = new CloudCredentials(user, password);
}
 
Example #14
Source File: LoggregatorSourceConfiguration.java    From spring-cloud-stream-app-starters with Apache License 2.0 4 votes vote down vote up
@Bean
public CloudCredentials cloudCredentials() {
	return new CloudCredentials(this.loggregatorSourceProperties.getCloudFoundryUser(),
			this.loggregatorSourceProperties.getCloudFoundryPassword());
}
 
Example #15
Source File: ApplicationShutdownExecutor.java    From multiapps-controller with Apache License 2.0 4 votes vote down vote up
private static CloudCredentials createCloudCredentials(ShutdownConfiguration shutdownConfiguration) {
    return new CloudCredentials(shutdownConfiguration.getUsername(), shutdownConfiguration.getPassword());
}
 
Example #16
Source File: ClientFactory.java    From multiapps-controller with Apache License 2.0 4 votes vote down vote up
private static CloudCredentials createCredentials(OAuth2AccessToken token) {
    boolean refreshable = (token.getRefreshToken() != null);
    return new CloudCredentials(token, refreshable);
}
 
Example #17
Source File: CloudFoundryClientFactory.java    From multiapps-controller with Apache License 2.0 4 votes vote down vote up
protected CloudSpace computeTarget(CloudCredentials credentials, String spaceId) {
    CloudControllerClient clientWithoutTarget = createClient(credentials);
    return clientWithoutTarget.getSpace(UUID.fromString(spaceId));
}
 
Example #18
Source File: TokenProviderFactory.java    From multiapps-controller with Apache License 2.0 4 votes vote down vote up
public TokenProvider createTokenProvider(String username, String password) {
    CloudCredentials credentials = createCredentials(username, password);
    OAuthClient oAuthClient = oAuthClientFactory.createOAuthClient();
    oAuthClient.init(credentials);
    return new CloudFoundryTokenProvider(oAuthClient);
}
 
Example #19
Source File: CloudControllerRestClientFactory.java    From cf-java-client-sap with Apache License 2.0 4 votes vote down vote up
private void setAuthorizingRequestFactory(RestTemplate restTemplate, CloudCredentials credentials, OAuthClient oAuthClient) {
    ClientHttpRequestFactory requestFactory = restTemplate.getRequestFactory();
    if (!(requestFactory instanceof CloudControllerRestClientHttpRequestFactory)) {
        restTemplate.setRequestFactory(new CloudControllerRestClientHttpRequestFactory(requestFactory, credentials, oAuthClient));
    }
}
 
Example #20
Source File: CloudControllerRestClientFactory.java    From cf-java-client-sap with Apache License 2.0 4 votes vote down vote up
private RestTemplate createAuthorizationSettingRestTemplate(CloudCredentials credentials, OAuthClient oAuthClient) {
    RestTemplate restTemplate = restUtil.createRestTemplate(getHttpProxyConfiguration(), shouldTrustSelfSignedCertificates());
    oAuthClient.init(credentials);
    setAuthorizingRequestFactory(restTemplate, credentials, oAuthClient);
    return restTemplate;
}
 
Example #21
Source File: CloudControllerRestClientFactory.java    From cf-java-client-sap with Apache License 2.0 4 votes vote down vote up
public CloudControllerRestClient createClient(URL controllerUrl, CloudCredentials credentials, CloudSpace target) {
    return createClient(controllerUrl, credentials, target, createOAuthClient(controllerUrl, credentials.getOrigin()));
}
 
Example #22
Source File: CloudControllerRestClientFactory.java    From cf-java-client-sap with Apache License 2.0 4 votes vote down vote up
public CloudControllerRestClient createClient(URL controllerUrl, CloudCredentials credentials, String organizationName,
                                              String spaceName) {
    return createClient(controllerUrl, credentials, organizationName, spaceName,
                        createOAuthClient(controllerUrl, credentials.getOrigin()));
}
 
Example #23
Source File: CloudControllerRestClientFactory.java    From cf-java-client-sap with Apache License 2.0 4 votes vote down vote up
public CloudControllerRestClient createClient(URL controllerUrl, CloudCredentials credentials, OAuthClient oAuthClient) {
    return createClient(controllerUrl, credentials, null, oAuthClient);
}
 
Example #24
Source File: CloudControllerRestClientFactory.java    From cf-java-client-sap with Apache License 2.0 4 votes vote down vote up
public CloudControllerRestClient createClient(URL controllerUrl, CloudCredentials credentials) {
    return createClient(controllerUrl, credentials, (CloudSpace) null);
}
 
Example #25
Source File: ClientFactory.java    From multiapps-controller with Apache License 2.0 votes vote down vote up
protected abstract CloudControllerClient createClient(CloudCredentials credentials); 
Example #26
Source File: ClientFactory.java    From multiapps-controller with Apache License 2.0 votes vote down vote up
protected abstract CloudControllerClient createClient(CloudCredentials credentials, String org, String space); 
Example #27
Source File: ClientFactory.java    From multiapps-controller with Apache License 2.0 votes vote down vote up
protected abstract CloudControllerClient createClient(CloudCredentials credentials, String spaceId);