use of com.checkmarx.sdk.exception.CheckmarxLegacyException in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class CxLegacyService method login.
/**
* Login to Cx using legacy SOAP WS
* @param username
* @param password
* @return
* @throws CheckmarxLegacyException
*/
public String login(String username, String password) throws CheckmarxLegacyException {
LoginV2 request = new LoginV2();
WebServiceTemplate wsInstance = ws;
// If shards are enabled then fetch the current shard info for override.
if (properties.getEnableShardManager()) {
ShardSession shard = sessionTracker.getShardSession();
wsInstance = shard.getShardWs();
username = shard.getUsername();
password = shard.getPassword();
}
request.setApplicationCredentials(new Credentials(username, password));
if (properties.getVersion() >= 9.0) {
return "-1";
}
LoginV2Response response = (LoginV2Response) wsInstance.marshalSendAndReceive(wsInstance.getDefaultUri(), request, new SoapActionCallback(CX_WS_LOGIN_URI));
try {
if (!response.getLoginV2Result().isIsSuccesfull())
throw new CheckmarxLegacyException("Authentication Error");
if (properties.getEnableShardManager()) {
ShardSession shard = sessionTracker.getShardSession();
shard.setSoapToken(response.getLoginV2Result().getSessionId());
}
return response.getLoginV2Result().getSessionId();
} catch (NullPointerException e) {
log.error("Authentication Error while logging into CX using SOAP WS");
throw new CheckmarxLegacyException("Authentication Error");
}
}
Aggregations