Search in sources :

Example 1 with HttpUrlConnection

use of org.springframework.ws.transport.http.HttpUrlConnection in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.

the class CxLegacyService method getWSCallback.

private WebServiceMessageCallback getWSCallback(String callbackUri, String token) {
    String curToken;
    if (properties.getEnableShardManager()) {
        ShardSession shard = sessionTracker.getShardSession();
        curToken = shard.getSoapToken();
    } else {
        curToken = token;
    }
    return message -> {
        SoapMessage soapMessage = (SoapMessage) message;
        soapMessage.setSoapAction(callbackUri);
        TransportContext context = TransportContextHolder.getTransportContext();
        HttpUrlConnection connection = (HttpUrlConnection) context.getConnection();
        try {
            if (!ScanUtils.empty(curToken) && properties.getVersion() >= 9.0) {
                connection.addRequestHeader(HttpHeaders.AUTHORIZATION, "Bearer ".concat(token));
            }
        } catch (IOException e) {
            log.warn("Problem adding SOAP WS http header: {}", ExceptionUtils.getStackTrace(e));
        }
    };
}
Also used : ShardSessionTracker(com.checkmarx.sdk.ShardManager.ShardSessionTracker) CxProperties(com.checkmarx.sdk.config.CxProperties) HashMap(java.util.HashMap) CheckmarxException(com.checkmarx.sdk.exception.CheckmarxException) ArrayList(java.util.ArrayList) checkmarx.wsdl.portal(checkmarx.wsdl.portal) WebServiceTemplate(org.springframework.ws.client.core.WebServiceTemplate) ShardSession(com.checkmarx.sdk.ShardManager.ShardSession) HttpUrlConnection(org.springframework.ws.transport.http.HttpUrlConnection) Map(java.util.Map) HttpHeaders(org.apache.http.HttpHeaders) SoapActionCallback(org.springframework.ws.soap.client.core.SoapActionCallback) ScanUtils(com.checkmarx.sdk.utils.ScanUtils) Logger(org.slf4j.Logger) CxUser(com.checkmarx.sdk.dto.sast.CxUser) SoapMessage(org.springframework.ws.soap.SoapMessage) ImmutableMap(com.google.common.collect.ImmutableMap) CheckmarxLegacyException(com.checkmarx.sdk.exception.CheckmarxLegacyException) IOException(java.io.IOException) TransportContext(org.springframework.ws.transport.context.TransportContext) Component(org.springframework.stereotype.Component) List(java.util.List) WebServiceMessageCallback(org.springframework.ws.client.core.WebServiceMessageCallback) ExceptionUtils(org.apache.commons.lang3.exception.ExceptionUtils) TransportContextHolder(org.springframework.ws.transport.context.TransportContextHolder) HttpUrlConnection(org.springframework.ws.transport.http.HttpUrlConnection) ShardSession(com.checkmarx.sdk.ShardManager.ShardSession) TransportContext(org.springframework.ws.transport.context.TransportContext) IOException(java.io.IOException) SoapMessage(org.springframework.ws.soap.SoapMessage)

Aggregations

checkmarx.wsdl.portal (checkmarx.wsdl.portal)1 ShardSession (com.checkmarx.sdk.ShardManager.ShardSession)1 ShardSessionTracker (com.checkmarx.sdk.ShardManager.ShardSessionTracker)1 CxProperties (com.checkmarx.sdk.config.CxProperties)1 CxUser (com.checkmarx.sdk.dto.sast.CxUser)1 CheckmarxException (com.checkmarx.sdk.exception.CheckmarxException)1 CheckmarxLegacyException (com.checkmarx.sdk.exception.CheckmarxLegacyException)1 ScanUtils (com.checkmarx.sdk.utils.ScanUtils)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 ExceptionUtils (org.apache.commons.lang3.exception.ExceptionUtils)1 HttpHeaders (org.apache.http.HttpHeaders)1 Logger (org.slf4j.Logger)1 Component (org.springframework.stereotype.Component)1 WebServiceMessageCallback (org.springframework.ws.client.core.WebServiceMessageCallback)1 WebServiceTemplate (org.springframework.ws.client.core.WebServiceTemplate)1