jenkins-build-driver/src/main/java/org/jboss/pnc/jenkinsbuilddriver/JenkinsServerFactory.java
boolean isJenkinsServerSecuredWithCSRF(String url) throws BuildDriverException {
        try {
            JenkinsBuildDriverModuleConfig config = configuration
                    .getModuleConfig(new PncConfigProvider<JenkinsBuildDriverModuleConfig>(JenkinsBuildDriverModuleConfig.class));
            String username = config.getUsername();
            String password = config.getPassword();

            if (url == null || username == null || password == null) {
                throw new BuildDriverException("Missing config to instantiate " + JenkinsBuildDriver.DRIVER_ID + ".");
            }
            try {
                JenkinsHttpClient jenkinsHttpClient = new JenkinsHttpClient(new URI(url), username, password);
                try {
                    jenkinsHttpClient.get("/crumbIssuer/api/xml");
                    return true ;
                } catch (IOException e) {
                    return false;
                }
            } catch (URISyntaxException e) {
                throw new BuildDriverException("Cannot instantiate " + JenkinsBuildDriver.DRIVER_ID + ". Make sure you are using valid url: " + url, e);
            }
        } catch (ConfigurationParseException e) {
            throw new BuildDriverException("Cannot read configuration for " + JenkinsBuildDriver.DRIVER_ID + ".", e);        }
        
    }
boolean isJenkinsServerSecuredWithCSRF(String url) throws BuildDriverException {
        try {
            JenkinsBuildDriverModuleConfig config = configuration
                    .getModuleConfig(new PncConfigProvider<JenkinsBuildDriverModuleConfig>(JenkinsBuildDriverModuleConfig.class));
            String username = config.getUsername();
            String password = config.getPassword();

            if (url == null || username == null || password == null) {
                throw new BuildDriverException("Missing config to instantiate " + JenkinsBuildDriver.DRIVER_ID + ".");
            }
            try {
                JenkinsHttpClient jenkinsHttpClient = new JenkinsHttpClient(new URI(url), username, password);
                try {
                    jenkinsHttpClient.get("/crumbIssuer/api/xml");
                    return true ;
                } catch (IOException e) {
                    return false;
                }
            } catch (URISyntaxException e) {
                throw new BuildDriverException("Cannot instantiate " + JenkinsBuildDriver.DRIVER_ID + ". Make sure you are using valid url: " + url, e);
            }
        } catch (ConfigurationParseException e) {
            throw new BuildDriverException("Cannot read configuration for " + JenkinsBuildDriver.DRIVER_ID + ".", e);        }
        
    }
boolean isJenkinsServerSecuredWithCSRF ( String url ) throws BuildDriverException { try { JenkinsBuildDriverModuleConfig config = configuration . getModuleConfig ( new PncConfigProvider < JenkinsBuildDriverModuleConfig > ( JenkinsBuildDriverModuleConfig . class ) ) ; String username = config . getUsername ( ) ; String password = config . getPassword ( ) ; if ( url == null || username == null || password == null ) { throw new BuildDriverException ( "Missing config to instantiate " + JenkinsBuildDriver . DRIVER_ID + "." ) ; } try { JenkinsHttpClient jenkinsHttpClient = new JenkinsHttpClient ( new URI ( url ) , username , password ) ; try { jenkinsHttpClient . get ( "/crumbIssuer/api/xml" ) ; return true ; } catch ( IOException e ) { return false ; } } catch ( URISyntaxException e ) { throw new BuildDriverException ( "Cannot instantiate " + JenkinsBuildDriver . DRIVER_ID + ". Make sure you are using valid url: " + url , e ) ; } } catch ( ConfigurationParseException e ) { throw new BuildDriverException ( "Cannot read configuration for " + JenkinsBuildDriver . DRIVER_ID + "." , e ) ; } }
This checks if jenkins does not use option Prevent Cross Site Request Forgery exploits

mnovotny: TODO: see NCL-669 this method should be placed in producing JenkinsServer, but as CSRF is not propagated
out from JenkinsServer instance, we need to figure out the setting by special API call through JenkinsHttpClient

@param url Jenkins instance URL with port
@return
@throws BuildDriverException
This checks if jenkins does not use option Prevent Cross Site Request Forgery exploits