@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; } }
/** * Create proxy credentials. * * @param cloudCredentials credentials to use * @param proxyForUser user to be proxied */ public CloudCredentials(CloudCredentials cloudCredentials, String proxyForUser) { this.email = cloudCredentials.getEmail(); this.password = cloudCredentials.getPassword(); this.clientId = cloudCredentials.getClientId(); this.token = cloudCredentials.getToken(); this.proxyUser = proxyForUser; }
public OAuth2AccessToken getToken() { if (token == null) { return null; } if(this.credentials.isRefreshable()) { if (token.getExpiresIn() < 50) { // 50 seconds before expiration? Then refresh it. token = refreshToken(token, credentials.getEmail(), credentials.getPassword(), credentials.getClientId(), credentials.getClientSecret()); } } return token; }
/** * Run commands as a different user. The authenticated user must be * privileged to run as this user. * @param user the user to proxy for * @return credentials for the proxied user */ public CloudCredentials proxyForUser(String user) { return new CloudCredentials(this, user); }
credentials.getEmail(), credentials.getPassword(), selfSigned, monitor);
@Override public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException { ClientHttpRequest request = delegate.createRequest(uri, httpMethod); String authorizationHeader = oauthClient.getAuthorizationHeader(); if (authorizationHeader != null) { request.getHeaders() .add(AUTHORIZATION_HEADER_KEY, authorizationHeader); } if (cloudCredentials != null && cloudCredentials.getProxyUser() != null) { request.getHeaders() .add(PROXY_USER_HEADER_KEY, cloudCredentials.getProxyUser()); } return request; }
/** * Run commands as a different user. The authenticated user must be privileged to run as this user. * * @param user the user to proxy for * @return credentials for the proxied user */ public CloudCredentials proxyForUser(String user) { return new CloudCredentials(this, user); } }
@Override public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException { ClientHttpRequest request = delegate.createRequest(uri, httpMethod); String authorizationHeader = oauthClient.getAuthorizationHeader(); if (authorizationHeader != null) { request.getHeaders().add(AUTHORIZATION_HEADER_KEY, authorizationHeader); } if (cloudCredentials != null && cloudCredentials.getProxyUser() != null) { request.getHeaders().add(PROXY_USER_HEADER_KEY, cloudCredentials.getProxyUser()); } return request; }
@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; } }
/** * Create proxy credentials. * * @param cloudCredentials credentials to use * @param proxyForUser user to be proxied */ public CloudCredentials(CloudCredentials cloudCredentials, String proxyForUser) { this.email = cloudCredentials.getEmail(); this.password = cloudCredentials.getPassword(); this.clientId = cloudCredentials.getClientId(); this.token = cloudCredentials.getToken(); this.proxyUser = proxyForUser; }
private static CloudCredentials createCredentials(String userName, String password) { return new CloudCredentials(userName, password, SecurityUtil.CLIENT_ID, SecurityUtil.CLIENT_SECRET); }
public OAuth2AccessToken getToken() { if (token == null) { return null; } if (this.credentials.isRefreshable()) { if (token.getExpiresIn() < 50) { // 50 seconds before expiration? Then refresh it. token = refreshToken(token, credentials.getEmail(), credentials.getPassword(), credentials.getClientId(), credentials.getClientSecret()); } } return token; }
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()); } } }
protected static CloudCredentials getCredentials(String userName, String password) { return new CloudCredentials(userName, password); }
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()); } } }
private static CloudCredentials createCredentials(OAuth2AccessToken token) { boolean refreshable = (token.getRefreshToken() != null); return new CloudCredentials(token, refreshable); } }
@Bean public CloudCredentials cloudCredentials() { return new CloudCredentials(this.loggregatorSourceProperties.getCloudFoundryUser(), this.loggregatorSourceProperties.getCloudFoundryPassword()); }
@Bean public CloudCredentials cloudCredentials() { return new CloudCredentials(this.loggregatorSourceProperties.getCloudFoundryUser(), this.loggregatorSourceProperties.getCloudFoundryPassword()); }
/** * Creates a new client to the given server URL using the specified * credentials. This does NOT connect the client to the server, nor does it * set the client as a session client for the server delegate. * * @param serverURL must not be null * @param userName must not be null * @param password must not be null * @param cloudSpace optional, as a valid client can still be created * without org/space (for example, a client can be used to do an org/space * lookup. * @param selfSigned true if connecting to self-signed server. False * otherwise * @return Non-null client. * @throws CoreException if failed to create the client. */ private static CloudFoundryOperations createClient(String serverURL, String userName, String password, CloudFoundrySpace cloudSpace, boolean selfSigned) throws CoreException { if (password == null) { // lost the password, start with an empty one to avoid assertion // error password = ""; //$NON-NLS-1$ } return createClient(serverURL, new CloudCredentials(userName, password), cloudSpace, selfSigned); }
public CloudFoundryConnector(String APIEndPoint, String login, String passwd, String organization, String space){ try { URL cloudControllerUrl = URI.create(APIEndPoint).toURL(); journal.log(Level.INFO, ">> Connecting to CloudFoundry ..."); CloudControllerClientFactory cff=new CloudControllerClientFactory(null,true); connectedClient = cff.newCloudController(cloudControllerUrl, new CloudCredentials(login,passwd),organization,space); connectedClient.login(); defaultDomainName = connectedClient.getDefaultDomain().getName(); journal.log(Level.INFO, ">> Default domain name: "+defaultDomainName); } catch (MalformedURLException e) { journal.log(Level.SEVERE, e.getMessage()); } catch (Exception e) { journal.log(Level.SEVERE, e.getMessage()); } }