}
static private Endpoint createEndpoint(String user) throws ClientServicesException {
Endpoint endpoint = getEndpoint("connections");
if (endpoint instanceof SmartCloudOAuthEndpoint) {
SmartCloudOAuthEndpoint smartcloud = (SmartCloudOAuthEndpoint)endpoint;
SmartCloudOAuthEndpoint cloned = new SmartCloudOAuthEndpoint();
cloned.setApiVersion(smartcloud.getApiVersion());
cloned.setUrl(smartcloud.getUrl());
cloned.setForceTrustSSLCertificate(smartcloud.isForceTrustSSLCertificate());
cloned.setConsumerKey(smartcloud.getConsumerKey());
cloned.setConsumerSecret(smartcloud.getConsumerSecret());
cloned.setRequestTokenURL(smartcloud.getRequestTokenURL());
cloned.setAuthorizationURL(smartcloud.getAuthorizationURL());
cloned.setAccessTokenURL(smartcloud.getAccessTokenURL());
cloned.setSignatureMethod(smartcloud.getSignatureMethod());
cloned.setCredentialStore(smartcloud.getCredentialStore());
cloned.setServiceName(smartcloud.getServiceName());
cloned.setAppId(smartcloud.getAppId());
cloned.setAuthenticationService(smartcloud.getAuthenticationService());
if (cloned.login(user)) {
return cloned;
}
}
if (endpoint instanceof ConnectionsOAuth2Endpoint) {
ConnectionsOAuth2Endpoint connections = (ConnectionsOAuth2Endpoint)endpoint;
ConnectionsOAuth2Endpoint cloned = new ConnectionsOAuth2Endpoint();
cloned.setApiVersion(connections.getApiVersion());
cloned.setUrl(connections.getUrl());
cloned.setForceTrustSSLCertificate(connections.isForceTrustSSLCertificate());
cloned.setConsumerKey(connections.getConsumerKey());
cloned.setConsumerSecret(connections.getConsumerSecret());
cloned.setAuthorizationURL(connections.getAuthorizationURL());
cloned.setAccessTokenURL(connections.getAccessTokenURL());
cloned.setCredentialStore(connections.getCredentialStore());
cloned.setServiceName(connections.getServiceName());
cloned.setAppId(connections.getAppId());
cloned.setAuthenticationService(connections.getAuthenticationService());
if (cloned.login(user)) {
return cloned;
}
}
return null;