本文整理汇总了Java中org.cloudfoundry.client.lib.CloudCredentials类的典型用法代码示例。如果您正苦于以下问题:Java CloudCredentials类的具体用法?Java CloudCredentials怎么用?Java CloudCredentials使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CloudCredentials类属于org.cloudfoundry.client.lib包,在下文中一共展示了CloudCredentials类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpWithNonEmptyConstructorWithoutLuck
import org.cloudfoundry.client.lib.CloudCredentials; //导入依赖的package包/类
/**
* Failed attempt to instantiate CloudControllerClientImpl with existing constructors. Just here to illustrate the
* need to move the initialize() method out of the constructor.
*/
public void setUpWithNonEmptyConstructorWithoutLuck() throws Exception {
restUtil = mock(RestUtil.class);
when(restUtil.createRestTemplate(any(HttpProxyConfiguration.class), false)).thenReturn(restTemplate);
when(restUtil.createOauthClient(any(URL.class), any(HttpProxyConfiguration.class), false)).thenReturn
(oauthClient);
when(restTemplate.getRequestFactory()).thenReturn(clientHttpRequestFactory);
restUtil.createRestTemplate(null, false);
restUtil.createOauthClient(new URL(CCNG_API_URL), null, false);
controllerClient = new CloudControllerClientImpl(new URL("http://api.dummyendpoint.com/login"),
restTemplate, oauthClient, loggregatorClient,
new CloudCredentials(CCNG_USER_EMAIL, CCNG_USER_PASS),
CCNG_USER_ORG, CCNG_USER_SPACE);
}
示例2: getCloudFoundryOperations
import org.cloudfoundry.client.lib.CloudCredentials; //导入依赖的package包/类
public CloudFoundryOperations getCloudFoundryOperations(CloudCredentials credentials, URL url, CloudSpace session,
boolean selfSigned) {
// Proxies are always updated on each client call by the
// CloudFoundryServerBehaviour Request as well as the client login
// handler
// therefore it is not critical to set the proxy in the client on
// client
// creation
HttpProxyConfiguration proxyConfiguration = getProxy(url);
//@ TODO tentatively set selfSigned = true
selfSigned = true;
return session != null ? new CloudFoundryClient(credentials, url, session, selfSigned)
: new CloudFoundryClient(credentials, url, proxyConfiguration, selfSigned);
}
示例3: login
import org.cloudfoundry.client.lib.CloudCredentials; //导入依赖的package包/类
public static CloudFoundryOperations login(CloudCredentials credentials, URL apiUrl, String space, String org, String domain, boolean trustSelfSignedCerts, HttpProxyConfiguration httpProxyConfiguration) {
logger.info("Running on " + apiUrl + " on behalf of " + credentials.getEmail());
logger.info("Using space " + space + " of organization " + org + " with domain " + domain);
if (httpProxyConfiguration != null) {
logger.info("Using proxy to connnect to clound foundry: httpProxyHost=" + httpProxyConfiguration.getProxyHost() + " httpProxyPort=" + httpProxyConfiguration.getProxyPort() );
}
else {
logger.info("Connection to clound foundry will not use proxy. no proxy is set. ");
}
CloudFoundryClient clientWithinTargetSpace = new CloudFoundryClient(credentials, apiUrl, org, space, httpProxyConfiguration,
trustSelfSignedCerts);
clientWithinTargetSpace.login();
// getOrCreateDomain(domain);
return clientWithinTargetSpace;
}
示例4: setUp
import org.cloudfoundry.client.lib.CloudCredentials; //导入依赖的package包/类
@Before
public void setUp() {
cfClient = CFClientFactory.login(new CloudCredentials(cfAdapter.getEmail(), cfAdapter.getPassword()), cfAdapter.getTarget(), cfAdapter.getSpace(), cfAdapter.getOrg(),
cfAdapter.getDomain(), cfAdapter.trustSelfSignedCerts, httpProxyConfiguration());
List<CloudApplication> applications = cfClient.getApplications();
for (CloudApplication application : applications) {
if (application.getName().contains(getTestAppName())) {
cfClient.deleteApplication(application.getName());
}
List<String> boundServices = application.getServices();
List<String> services = boundServices;
for (String service : services) {
cfClient.deleteService(service);
}
clearDomain(getTestDomainName(), true);
clearDomain(getDefaultDomain(), false);
}
cfAdapter.addDomain(getTestDomainName(), cfDefaultSpace);
}
示例5: run
import org.cloudfoundry.client.lib.CloudCredentials; //导入依赖的package包/类
@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();
}
}
示例6: initialiseClient
import org.cloudfoundry.client.lib.CloudCredentials; //导入依赖的package包/类
@BeforeClass
public static void initialiseClient() throws IOException {
// Skip all tests of this class if no test CF platform is specified
assumeNotNull(TEST_TARGET);
String fullTarget = TEST_TARGET;
if (!fullTarget.startsWith("https://")) {
if (!fullTarget.startsWith("api.")) {
fullTarget = "https://api." + fullTarget;
} else {
fullTarget = "https://" + fullTarget;
}
}
URL targetUrl = new URL(fullTarget);
CloudCredentials credentials = new CloudCredentials(TEST_USERNAME, TEST_PASSWORD);
client = new CloudFoundryClient(credentials, targetUrl, TEST_ORG, TEST_SPACE);
client.login();
}
示例7: CloudControllerClientImpl
import org.cloudfoundry.client.lib.CloudCredentials; //导入依赖的package包/类
public CloudControllerClientImpl(URL cloudControllerUrl, RestTemplate restTemplate, OauthClient oauthClient,
LoggregatorClient loggregatorClient, CloudCredentials cloudCredentials, CloudSpace sessionSpace) {
logger = LogFactory.getLog(getClass().getName());
initialize(cloudControllerUrl, restTemplate, oauthClient, loggregatorClient, cloudCredentials);
this.sessionSpace = sessionSpace;
}
示例8: updatePassword
import org.cloudfoundry.client.lib.CloudCredentials; //导入依赖的package包/类
@Override
public void updatePassword(CloudCredentials credentials, String newPassword) {
oauthClient.changePassword(credentials.getPassword(), newPassword);
CloudCredentials newCloudCredentials = new CloudCredentials(credentials.getEmail(), newPassword);
if (cloudCredentials.getProxyUser() != null) {
cloudCredentials = newCloudCredentials.proxyForUser(cloudCredentials.getProxyUser());
} else {
cloudCredentials = newCloudCredentials;
}
}
示例9: newCloudController
import org.cloudfoundry.client.lib.CloudCredentials; //导入依赖的package包/类
public CloudControllerClient newCloudController(URL cloudControllerUrl, CloudCredentials cloudCredentials, CloudSpace sessionSpace) {
createOauthClient(cloudControllerUrl);
LoggregatorClient loggregatorClient = new LoggregatorClient(trustSelfSignedCerts);
return new CloudControllerClientImpl(cloudControllerUrl, restTemplate, oauthClient, loggregatorClient, cloudCredentials,
sessionSpace);
}
示例10: init
import org.cloudfoundry.client.lib.CloudCredentials; //导入依赖的package包/类
public void init(CloudCredentials credentials) {
if (credentials != null) {
this.credentials = credentials;
if (credentials.getToken() != null) {
this.token = credentials.getToken();
} else {
this.token = createToken(credentials.getEmail(), credentials.getPassword(), credentials.getClientId(),
credentials.getClientSecret());
}
}
}
示例11: createClient
import org.cloudfoundry.client.lib.CloudCredentials; //导入依赖的package包/类
@Override
protected Pair<CloudFoundryOperations, TokenProvider> createClient(CloudCredentials credentials) {
CloudControllerClientFactory factory = new CloudControllerClientFactory(null, configuration.shouldSkipSslValidation());
OauthClient oauthClient = createOauthClient();
CloudControllerClient controllerClient = factory.newCloudController(configuration.getTargetURL(), credentials, null, oauthClient);
return new Pair<CloudFoundryOperations, TokenProvider>(new CloudFoundryClientExtended(controllerClient),
new CloudFoundryTokenProvider(oauthClient));
}
示例12: getSessionSpace
import org.cloudfoundry.client.lib.CloudCredentials; //导入依赖的package包/类
protected CloudSpace getSessionSpace(CloudCredentials credentials, String orgName, String spaceName) {
// There are two constructors, which can be used to create a CF client. The first accepts a session space object. The second accepts
// the org and space names of the session space and attempts to compute it from them. The computation operation is implemented in an
// incredibly inefficient way, however. This is why here, we create a client without a session space (null) and we use it to compute
// the session space in a better way (by using the CFOptimizedSpaceGetter). After we do that, we can create a CF client with the
// computed session space.
CloudFoundryOperations clientWithoutSessionSpace = createClient(credentials)._1;
CloudSpace sessionSpace = new CFOptimizedSpaceGetter().findSpace(clientWithoutSessionSpace, orgName, spaceName);
Assert.notNull(sessionSpace, "No matching organization and space found for org: " + orgName + " space: " + spaceName);
return sessionSpace;
}
示例13: createCloudFoundryClient
import org.cloudfoundry.client.lib.CloudCredentials; //导入依赖的package包/类
public CloudFoundryClient createCloudFoundryClient(OAuth2AccessToken token, URL cloudControllerUrl, String org, String space) {
CloudCredentials credentials = new CloudCredentials(token, false);
if (httpProxyConfiguration == null) {
return new CloudFoundryClient(credentials, cloudControllerUrl, org, space);
}
return new CloudFoundryClient(credentials, cloudControllerUrl, org, space, httpProxyConfiguration);
}
示例14: createStandaloneClient
import org.cloudfoundry.client.lib.CloudCredentials; //导入依赖的package包/类
/**
*
* @return standalone client based on the harness credentials, org and
* space. This is not the client used by the server instance, but a new
* client for testing purposes only.
*/
public static CloudFoundryOperations createStandaloneClient(HarnessProperties prop) throws CoreException {
try {
return CloudFoundryPlugin.getCloudFoundryClientFactory().getCloudFoundryOperations(
new CloudCredentials(prop.getUsername(), prop.getPassword()), new URL(prop.getApiUrl()),
prop.getOrg(), prop.getSpace(), prop.skipSslValidation());
}
catch (MalformedURLException e) {
throw CloudErrorUtil.toCoreException(e);
}
}
示例15: getCloudInfo
import org.cloudfoundry.client.lib.CloudCredentials; //导入依赖的package包/类
@Override
public CFInfo getCloudInfo() throws CoreException {
if (cachedInfo == null) {
CloudFoundryServer cloudServer = behaviour.getCloudFoundryServer();
cachedInfo = new CFInfo(new CloudCredentials(cloudServer.getUsername(), cloudServer.getPassword()),
cloudServer.getUrl(), cloudServer.getProxyConfiguration(), cloudServer.isSelfSigned());
}
return cachedInfo;
}