本文整理汇总了Java中org.cloudfoundry.client.lib.CloudCredentials类的典型用法代码示例。如果您正苦于以下问题:Java CloudCredentials类的具体用法?Java CloudCredentials怎么用?Java CloudCredentials使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloudCredentials类属于org.cloudfoundry.client.lib包,在下文中一共展示了CloudCredentials类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:20,代码来源:CloudControllerClientImplTest.java
示例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);
}
开发者ID:osswangxining,项目名称:dockerfoundry,代码行数:17,代码来源:DockerFoundryClientFactory.java
示例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;
}
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:18,代码来源:CFClientFactory.java
示例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);
}
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:20,代码来源:AbstractCfAdapterIT.java
示例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();
}
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:17,代码来源:PreferencePage.java
示例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();
}
开发者ID:hpcloud,项目名称:cloudfoundry-jenkins,代码行数:20,代码来源:CloudFoundryPushPublisherTest.java
示例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;
}
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:9,代码来源:CloudControllerClientImpl.java
示例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;
}
}
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:11,代码来源:CloudControllerClientImpl.java
示例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);
}
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:8,代码来源:CloudControllerClientFactory.java
示例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());
}
}
}
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:13,代码来源:OauthClient.java
示例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));
}
开发者ID:SAP,项目名称:cf-mta-deploy-service,代码行数:9,代码来源:CloudFoundryClientFactory.java
示例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;
}
开发者ID:SAP,项目名称:cf-mta-deploy-service,代码行数:12,代码来源:CloudFoundryClientFactory.java
示例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);
}
开发者ID:cloudfoundry-community,项目名称:oauth-register-broker,代码行数:8,代码来源:CloudFoundryClientFactory.java
示例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);
}
}
开发者ID:eclipse,项目名称:cft,代码行数:18,代码来源:StsTestUtil.java
示例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;
}
开发者ID:eclipse,项目名称:cft,代码行数:10,代码来源:DiegoRequestFactory.java
示例16: 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);
return session != null ? new CloudFoundryClient(credentials, url, session, selfSigned)
: new CloudFoundryClient(credentials, url, proxyConfiguration, selfSigned);
}
开发者ID:eclipse,项目名称:cft,代码行数:15,代码来源:CloudFoundryClientFactory.java
示例17: getCloudInfo
import org.cloudfoundry.client.lib.CloudCredentials; //导入依赖的package包/类
public CFInfo getCloudInfo() throws CoreException {
// cache the info to avoid frequent network connection to Cloud Foundry.
if (cachedInfo == null) {
CloudFoundryServer cloudServer = behaviour.getCloudFoundryServer();
cachedInfo = new CFInfo(new CloudCredentials(cloudServer.getUsername(), cloudServer.getPassword()),
cloudServer.getUrl(), cloudServer.getProxyConfiguration(), cloudServer.isSelfSigned());
}
return cachedInfo;
}
开发者ID:eclipse,项目名称:cft,代码行数:10,代码来源:ClientRequestFactory.java
示例18: reestablishSsoSessionIfNeeded
import org.cloudfoundry.client.lib.CloudCredentials; //导入依赖的package包/类
/**
* Called by getClient(...) to prompt the user and reacquire token with
* passcode, if an exception occurs while connecting with SSO
*/
private void reestablishSsoSessionIfNeeded(CloudFoundryException e, CloudFoundryServer cloudServer)
throws CoreException {
// Status Code: 401 / Description = Invalid Auth Token, or;
// Status Code: 403 / Description: Access token denied.
if (cloudServer.isSso()
&& (e.getStatusCode() == HttpStatus.UNAUTHORIZED || e.getStatusCode() == HttpStatus.FORBIDDEN)) {
boolean result = CloudFoundryPlugin.getCallback().ssoLoginUserPrompt(cloudServer);
if (client != null) {
// Success: another thread has established the client.
return;
}
if (result) {
// Client is null but the login did succeed, so recreate w/ new
// token stored in server
CloudCredentials credentials = CloudUtil.createSsoCredentials(cloudServer.getPasscode(),
cloudServer.getToken());
client = createClientWithCredentials(cloudServer.getUrl(), credentials,
cloudServer.getCloudFoundrySpace(), cloudServer.isSelfSigned());
return;
}
}
// Otherwise, rethrow the exception
throw e;
}
开发者ID:eclipse,项目名称:cft,代码行数:32,代码来源:CloudFoundryServerBehaviour.java
示例19: createClientWithCredentials
import org.cloudfoundry.client.lib.CloudCredentials; //导入依赖的package包/类
/**
* Creates a new client to the specified server URL using the given
* credentials. This does NOT connect the client to the server, nor does it
* set the client as the session client for the server behaviour. The
* session client is set indirectly via {@link #connect(IProgressMonitor)}
* @param serverURL server to connect to. Must NOT be null.
* @param credentials must not be null.
* @param cloudSpace optional. Can be null, as a client can be created
* without specifying an org/space (e.g. a client can be created for the
* purpose of looking up all the orgs/spaces in a server)
* @param selfSigned true if connecting to a server with self signed
* certificate. False otherwise
* @return non-null client.
* @throws CoreException if failed to create client.
*/
private static CloudFoundryOperations createClientWithCredentials(String serverURL, CloudCredentials credentials,
CloudFoundrySpace cloudSpace, boolean selfSigned) throws CoreException {
URL url;
try {
url = new URL(serverURL);
int port = url.getPort();
if (port == -1) {
port = url.getDefaultPort();
}
// If no cloud space is specified, use appropriate client factory
// API to create a non-space client
// NOTE that using a space API with null org and space will result
// in errors as that API will
// expect valid org and space values.
return cloudSpace != null
? CloudFoundryPlugin.getCloudFoundryClientFactory().getCloudFoundryOperations(credentials, url,
cloudSpace.getOrgName(), cloudSpace.getSpaceName(), selfSigned)
: CloudFoundryPlugin.getCloudFoundryClientFactory().getCloudFoundryOperations(credentials, url,
selfSigned);
}
catch (MalformedURLException e) {
throw new CoreException(new Status(IStatus.ERROR, CloudFoundryPlugin.PLUGIN_ID,
"The server url " + serverURL + " is invalid: " + e.getMessage(), e)); //$NON-NLS-1$ //$NON-NLS-2$
}
}
开发者ID:eclipse,项目名称:cft,代码行数:43,代码来源:CloudFoundryServerBehaviour.java
示例20: getClient
import org.cloudfoundry.client.lib.CloudCredentials; //导入依赖的package包/类
/**
* Gets the active client used by the behaviour for server operations.
* However, clients are created lazily, and invoking it multipe times does
* not recreate the client, as only one client is created per lifecycle of
* the server behaviour (but not necessarily per connection session, as the
* server behaviour may be created and disposed multiple times by the WST
* framework). To use the server-stored credentials, pass null credentials.
* <p/>
* This API is not suitable to changing credentials. User appropriate API
* for the latter like {@link #updatePassword(String, IProgressMonitor)}
*/
protected synchronized DockerClient getClient(CloudCredentials credentials, IProgressMonitor monitor)
throws CoreException {
if (client == null) {
DockerFoundryServer cloudServer = getCloudFoundryServer();
DockerConnectionElement dockerConnElem = cloudServer.getDockerConnElem();
if (dockerConnElem != null) {
try {
client = dockerConnElem.getDockerClient();
}
catch (DockerCertificateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// String url = cloudServer.getUrl();
// if (!cloudServer.hasCloudSpace()) {
// throw
// CloudErrorUtil.toCoreException(NLS.bind(Messages.ERROR_FAILED_CLIENT_CREATION_NO_SPACE,
// cloudServer.getServerId()));
// }
//
// CloudFoundrySpace cloudFoundrySpace =
// cloudServer.getCloudFoundrySpace();
//
// if (credentials != null) {
// client = createClient(url, credentials, cloudFoundrySpace,
// cloudServer.getSelfSignedCertificate());
// }
// else {
// String userName = getCloudFoundryServer().getUsername();
// String password = getCloudFoundryServer().getPassword();
// client = createClient(url, userName, password, cloudFoundrySpace,
// cloudServer.getSelfSignedCertificate());
// }
}
return client;
}
开发者ID:osswangxining,项目名称:dockerfoundry,代码行数:50,代码来源:DockerFoundryServerBehaviour.java
注:本文中的org.cloudfoundry.client.lib.CloudCredentials类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论