use of com.sforce.ws.ConnectionException in project gitblit by gitblit.
the class SalesforceAuthProvider method authenticate.
@Override
public UserModel authenticate(String username, char[] password) {
ConnectorConfig config = new ConnectorConfig();
config.setUsername(username);
config.setPassword(new String(password));
try {
PartnerConnection connection = Connector.newConnection(config);
GetUserInfoResult info = connection.getUserInfo();
String org = settings.getString(Keys.realm.salesforce.orgId, "0").trim();
if (!org.equals("0")) {
if (!org.equals(info.getOrganizationId())) {
logger.warn("Access attempted by user of an invalid org: " + info.getUserName() + ", org: " + info.getOrganizationName() + "(" + info.getOrganizationId() + ")");
return null;
}
}
logger.info("Authenticated user " + info.getUserName() + " using org " + info.getOrganizationName() + "(" + info.getOrganizationId() + ")");
String simpleUsername = getSimpleUsername(info);
UserModel user = null;
synchronized (this) {
user = userManager.getUserModel(simpleUsername);
if (user == null) {
user = new UserModel(simpleUsername);
}
setCookie(user);
setUserAttributes(user, info);
updateUser(user);
}
return user;
} catch (ConnectionException e) {
logger.error("Failed to authenticate", e);
}
return null;
}
use of com.sforce.ws.ConnectionException in project tdi-studio-se by Talend.
the class SforceOAuthBulkConnection method renewSession.
@Override
protected void renewSession() throws ConnectionException {
Token token;
try {
token = loginWithOAuth();
} catch (Exception e) {
throw new ConnectionException(e.getMessage());
}
String session_id = token.getAccess_token();
String endpoint = OAuthClient.getBulkEndpoint(token, apiVersion);
config.setSessionId(session_id);
config.setRestEndpoint(endpoint);
}
Aggregations