use of com.mercedesbenz.sechub.adapter.netsparker.NetsparkerConfig.NetsparkerConfigBuilder in project sechub by mercedes-benz.
the class NetsparkerAdapterTestApplication method main.
public static void main(String[] args) throws Exception {
SecHubTimeUnitData maxScanDuration = null;
String maxScanDurationDurationProperty = getSystemProperty("sechub.adapter.netsparker.maxscanduration.duration");
String maxScanDurationUnitProperty = getSystemProperty("sechub.adapter.netsparker.maxscanduration.unit");
if (maxScanDurationDurationProperty != null && maxScanDurationUnitProperty != null) {
int duration = Integer.valueOf(maxScanDurationDurationProperty);
SecHubTimeUnit unit = SecHubTimeUnit.valueOf(maxScanDurationUnitProperty);
maxScanDuration = SecHubTimeUnitData.of(duration, unit);
}
/* @formatter:off */
NetsparkerConfigBuilder builder = NetsparkerConfig.builder().setUser(getSystemProperty("sechub.adapter.netsparker.user")).setTrustAllCertificates(getSystemPropertyBooleanOrFalse("sechub.adapter.netsparker.trustall")).setAgentGroupName(getSystemProperty("sechub.adapter.netsparker.user.agent.groupname")).setPasswordOrAPIToken(getSystemProperty("sechub.adapter.netsparker.apitoken")).setPolicyID(getSystemProperty("sechub.adapter.netsparker.policyid")).setProductBaseUrl(getSystemProperty("sechub.adapter.netsparker.baseurl")).setLicenseID(getSystemProperty("sechub.adapter.netsparker.licenseid", "none")).setTargetURI(new URI(getSystemProperty("sechub.adapter.netsparker.targeturi"))).setMaxScanDuration(maxScanDuration);
/* @formatter:on */
String loginType = getSystemProperty("sechub.adapter.netsparker.login.type", "<none>");
if ("basic".equalsIgnoreCase(loginType)) {
handleBasicLogin(builder);
} else if ("formAutodetect".equalsIgnoreCase(loginType)) {
handleFormAutodetect(builder);
} else if ("formScript".equalsIgnoreCase(loginType)) {
handleFormScript(builder);
} else if ("<none>".equalsIgnoreCase(loginType)) {
/* ignore */
} else {
throw new IllegalArgumentException("login type:" + loginType + " not supported!");
}
NetsparkerAdapterConfig config = builder.build();
NetsparkerAdapter netsparker = new NetsparkerAdapterV1();
String result = netsparker.start(config, new AdapterMetaDataCallback() {
AdapterMetaData metaData;
@Override
public void persist(AdapterMetaData metaData) {
System.out.println("persist:" + metaData);
this.metaData = metaData;
}
@Override
public AdapterMetaData getMetaDataOrNull() {
return metaData;
}
});
System.out.println("result:");
System.out.println(result);
}
Aggregations