当前位置: 首页>>代码示例>>Java>>正文


Java ApiResponse类代码示例

本文整理汇总了Java中org.zaproxy.clientapi.core.ApiResponse的典型用法代码示例。如果您正苦于以下问题:Java ApiResponse类的具体用法?Java ApiResponse怎么用?Java ApiResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ApiResponse类属于org.zaproxy.clientapi.core包,在下文中一共展示了ApiResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSpiderResults

import org.zaproxy.clientapi.core.ApiResponse; //导入依赖的package包/类
@Override
public List<String> getSpiderResults(int id) {
    List<String> results = new ArrayList<String>();
    try {
        ApiResponseList responseList = (ApiResponseList) clientApi.spider
                .results(Integer.toString(id));
        for (ApiResponse response : responseList.getItems()) {
            results.add(((ApiResponseElement) response).getValue());
        }
    } catch (ClientApiException e) {
        e.printStackTrace();
        throw new ProxyException(e);
    }

    return results;
}
 
开发者ID:AgileTestingFramework,项目名称:atf-toolbox-java,代码行数:17,代码来源:ZAProxyScanner.java

示例2: getSupportedAuthenticationMethods

import org.zaproxy.clientapi.core.ApiResponse; //导入依赖的package包/类
/**
 * Returns the supported authentication methods by ZAP.
 *
 * @return list of supported authentication methods.
 * @throws ProxyException - thrown if we are unable to connect to the proxy server
 */
@Override
public List<String> getSupportedAuthenticationMethods() throws ProxyException {
    ApiResponseList apiResponseList = null;
    try {
        apiResponseList = (ApiResponseList) clientApi.authentication
                .getSupportedAuthenticationMethods();
    } catch (ClientApiException e) {
        e.printStackTrace();
        throw new ProxyException(e);
    }
    List<String> supportedAuthenticationMethods = new ArrayList<String>();
    for (ApiResponse apiResponse : apiResponseList.getItems()) {
        supportedAuthenticationMethods.add(((ApiResponseElement) apiResponse).getValue());
    }
    return supportedAuthenticationMethods;
}
 
开发者ID:AgileTestingFramework,项目名称:atf-toolbox-java,代码行数:23,代码来源:ZAProxyScanner.java

示例3: getUsersList

import org.zaproxy.clientapi.core.ApiResponse; //导入依赖的package包/类
/**
 * Returns list of {@link User}s for a given context.
 *
 * @param contextId Id of the context.
 * @return List of {@link User}s
 * @throws ProxyException - thrown if we are unable to connect to the proxy server
 * @throws IOException - thrown if we can not decode objects
 */
@Override
public List<User> getUsersList(String contextId) throws ProxyException, IOException {
    ApiResponseList apiResponseList;
    try {
        apiResponseList = (ApiResponseList) clientApi.users.usersList(contextId);
    } catch (ClientApiException e) {
        e.printStackTrace();
        throw new ProxyException(e);
    }
    List<User> users = new ArrayList<User>();
    if (apiResponseList != null) {
        for (ApiResponse apiResponse : apiResponseList.getItems()) {
            users.add(new User((ApiResponseSet) apiResponse));
        }
    }
    return users;
}
 
开发者ID:AgileTestingFramework,项目名称:atf-toolbox-java,代码行数:26,代码来源:ZAProxyScanner.java

示例4: getSupportedSessionManagementMethods

import org.zaproxy.clientapi.core.ApiResponse; //导入依赖的package包/类
/**
 * Returns list of supported session management methods.
 *
 * @return List of supported session management methods.
 * @throws ProxyException - thrown if we are unable to connect to the proxy server
 */
@Override
public List<String> getSupportedSessionManagementMethods() throws ProxyException {
    ApiResponseList apiResponseList = null;
    try {
        apiResponseList = (ApiResponseList) clientApi.sessionManagement
                .getSupportedSessionManagementMethods();
    } catch (ClientApiException e) {
        e.printStackTrace();
        throw new ProxyException(e);
    }
    List<String> supportedSessionManagementMethods = new ArrayList<String>();
    for (ApiResponse apiResponse : apiResponseList.getItems()) {
        supportedSessionManagementMethods.add(((ApiResponseElement) apiResponse).getValue());
    }
    return supportedSessionManagementMethods;
}
 
开发者ID:AgileTestingFramework,项目名称:atf-toolbox-java,代码行数:23,代码来源:ZAProxyScanner.java

示例5: listScripts

import org.zaproxy.clientapi.core.ApiResponse; //导入依赖的package包/类
/**
 * Returns the list of scripts loaded into ZAP.
 *
 * @return List of scripts.
 * @throws ProxyException - thrown if we are unable to connect to the proxy server
 */
@Override
public List<Script> listScripts() throws ProxyException {
    ApiResponseList apiResponseList;
    try {
        apiResponseList = (ApiResponseList) clientApi.script.listScripts();
    } catch (ClientApiException e) {
        e.printStackTrace();
        throw new ProxyException(e);
    }
    List<Script> scripts = new ArrayList<Script>();
    if (apiResponseList != null) {
        for (ApiResponse apiResponse : apiResponseList.getItems()) {
            scripts.add(new Script((ApiResponseSet) apiResponse));
        }
    }
    return scripts;
}
 
开发者ID:AgileTestingFramework,项目名称:atf-toolbox-java,代码行数:24,代码来源:ZAProxyScanner.java

示例6: disableAllScanners

import org.zaproxy.clientapi.core.ApiResponse; //导入依赖的package包/类
@Override
public void disableAllScanners() throws ProxyException {
    try {
        ApiResponse response = clientApi.pscan.setEnabled("false");
        response = clientApi.ascan.disableAllScanners(null);
    } catch (ClientApiException e) {
        e.printStackTrace();
        throw new ProxyException(e);
    }
}
 
开发者ID:AgileTestingFramework,项目名称:atf-toolbox-java,代码行数:11,代码来源:ZAProxyScanner.java

示例7: listEngines

import org.zaproxy.clientapi.core.ApiResponse; //导入依赖的package包/类
/**
 * Returns the list of scripting engines that ZAP supports.
 *
 * @return List of script engines.
 * @throws ProxyException - thrown if we are unable to connect to the proxy server
 */
@Override
public List<String> listEngines() throws ProxyException {
    List<String> engines = new ArrayList<String>();
    try {
        ApiResponseList apiResponseList = (ApiResponseList) clientApi.script.listEngines();
        for (ApiResponse apiResponse : apiResponseList.getItems()) {
            engines.add(((ApiResponseElement) apiResponse).getValue());
        }
    } catch (ClientApiException e) {
        e.printStackTrace();
        throw new ProxyException(e);
    }
    return engines;
}
 
开发者ID:AgileTestingFramework,项目名称:atf-toolbox-java,代码行数:21,代码来源:ZAProxyScanner.java

示例8: getInteger

import org.zaproxy.clientapi.core.ApiResponse; //导入依赖的package包/类
public static int getInteger(ApiResponse response) throws ClientApiException {
    try {
        return Integer.parseInt(((ApiResponseElement) response).getValue());
    } catch (Exception e) {
        throw new ClientApiException("Unable to get integer from response.");
    }
}
 
开发者ID:AgileTestingFramework,项目名称:atf-toolbox-java,代码行数:8,代码来源:ZAProxyScanner.java

示例9: sortAscanResults

import org.zaproxy.clientapi.core.ApiResponse; //导入依赖的package包/类
/**
 * Sort ascan results into maps based on the priority of findings.
 * 
 * @param ascanResults
 *            The ZAP ascan results.
 * @return A map of ascan results sorted by priority.
 */
private Map<String, List<ApiResponseSet>> sortAscanResults(ApiResponseList ascanResults) {
	Map<String, List<ApiResponseSet>> riskMap = new HashMap<>();
	riskMap.put(HIGH_RISK, new ArrayList<ApiResponseSet>());
	riskMap.put(MEDIUM_RISK, new ArrayList<ApiResponseSet>());
	riskMap.put(LOW_RISK, new ArrayList<ApiResponseSet>());
	riskMap.put(OTHER_RISK, new ArrayList<ApiResponseSet>());

	// Sort the report findings based on risk.
	for (ApiResponse responseItem : ascanResults.getItems()) {
		ApiResponseSet responseSet = (ApiResponseSet) responseItem;
		switch (responseSet.getAttribute("risk")) {
		case "High":
			riskMap.get(HIGH_RISK).add(responseSet);
			break;
		case "Medium":
			riskMap.get(MEDIUM_RISK).add(responseSet);
			break;
		case "Low":
			riskMap.get(LOW_RISK).add(responseSet);
			break;
		default:
			riskMap.get(OTHER_RISK).add(responseSet);
			break;
		}
	}

	return riskMap;
}
 
开发者ID:polyhedraltech,项目名称:SecurityTesting,代码行数:36,代码来源:ZAPAscanJob.java

示例10: generateSpiderReport

import org.zaproxy.clientapi.core.ApiResponse; //导入依赖的package包/类
/**
 * Generate the contents of the spider report.
 * 
 * @param targetUrl
 * @param spiderResponse
 * @return
 */
private static byte[] generateSpiderReport(String targetUrl, ApiResponseList spiderResponse) {
	StringBuilder report = new StringBuilder();

	report.append("Target URL: ").append(targetUrl).append("\n\n");

	// Display urls in scope.
	ApiResponseList inScope = (ApiResponseList) spiderResponse.getItems().get(0);
	report.append("URLs In Scope\n");

	// Loop through in scope products.
	for (ApiResponse scopeEntry : inScope.getItems()) {
		ApiResponseSet responseSet = (ApiResponseSet) scopeEntry;
		report.append("\tURL: ").append(responseSet.getAttribute("url")).append("\n");
		report.append("\tRequest Info:\n");
		report.append("\t\tMethod: ").append(responseSet.getAttribute("method")).append("\n");
		report.append("\t\tStatus: ").append(responseSet.getAttribute("statusReason")).append("\n\n");
	}

	// Display urls out of scope.
	ApiResponseList outOfScope = (ApiResponseList) spiderResponse.getItems().get(1);
	report.append("URLs Out of Scope\n");

	// Loop through out of scope products.
	for (ApiResponse outOfScopeEntry : outOfScope.getItems()) {
		ApiResponseElement responseElement = (ApiResponseElement) outOfScopeEntry;
		report.append("\tURL: ").append(responseElement.getValue()).append("\n");
	}

	return report.toString().getBytes();
}
 
开发者ID:polyhedraltech,项目名称:SecurityTesting,代码行数:38,代码来源:ZAPScanHelper.java

示例11: ScanResponse

import org.zaproxy.clientapi.core.ApiResponse; //导入依赖的package包/类
public ScanResponse(ApiResponseList responseList) {
    for (ApiResponse rawResponse : responseList.getItems()) {
        scans.add(new ScanInfo((ApiResponseSet)rawResponse));
    }
    Collections.sort(scans);
}
 
开发者ID:AgileTestingFramework,项目名称:atf-toolbox-java,代码行数:7,代码来源:ScanResponse.java

示例12: getAuthenticationMethodInfo

import org.zaproxy.clientapi.core.ApiResponse; //导入依赖的package包/类
/**
 * Returns authentication method info for a given context.
 *
 * @param contextId Id of a context.
 * @return Authentication method name for the given context id.
 * @throws ProxyException - thrown if we are unable to connect to the proxy server
 */
@Override
public Map<String, String> getAuthenticationMethodInfo(String contextId) throws ProxyException {
    Map<String, String> authenticationMethodDetails = new HashMap<String, String>();
    ApiResponse apiResponse = null;
    try {
        apiResponse = clientApi.authentication.getAuthenticationMethod(contextId);
    } catch (ClientApiException e) {
        e.printStackTrace();
        throw new ProxyException(e);
    }
    if (apiResponse instanceof ApiResponseElement) {
        authenticationMethodDetails
                .put("methodName", ((ApiResponseElement) apiResponse).getValue());
    } else if (apiResponse instanceof ApiResponseSet) {
        ApiResponseSet apiResponseSet = (ApiResponseSet) apiResponse;
        String authenticationMethod = apiResponseSet.getStringValue("methodName");
        authenticationMethodDetails.put("methodName", authenticationMethod);

        if (authenticationMethod
                .equals(AuthenticationMethod.FORM_BASED_AUTHENTICATION.getValue())) {
            List<Map<String, String>> configParameters = getAuthMethodConfigParameters(
                    AuthenticationMethod.FORM_BASED_AUTHENTICATION.getValue());
            for (Map<String, String> configParameter : configParameters) {
                authenticationMethodDetails.put(configParameter.get("name"),
                        apiResponseSet.getStringValue(configParameter.get("name")));
            }
        } else if (authenticationMethod
                .equals(AuthenticationMethod.HTTP_AUTHENTICATION.getValue())) {
            // Cannot dynamically populate the values for httpAuthentication, as one of the parameters in getAuthMethodConfigParameters (hostname) is different to what is returned here (host).
            authenticationMethodDetails.put("host", apiResponseSet.getStringValue("host"));
            authenticationMethodDetails.put("realm", apiResponseSet.getStringValue("realm"));
            authenticationMethodDetails.put("port", apiResponseSet.getStringValue("port"));
        } else if (authenticationMethod
                .equals(AuthenticationMethod.SCRIPT_BASED_AUTHENTICATION.getValue())) {
            authenticationMethodDetails
                    .put("scriptName", apiResponseSet.getStringValue("scriptName"));
            authenticationMethodDetails.put("LoginURL", apiResponseSet.getStringValue("LoginURL"));
            authenticationMethodDetails.put("Method", apiResponseSet.getStringValue("Method"));
            authenticationMethodDetails.put("Domain", apiResponseSet.getStringValue("Domain"));
            authenticationMethodDetails.put("Path", apiResponseSet.getStringValue("Path"));
        }
    }
    return authenticationMethodDetails;
}
 
开发者ID:AgileTestingFramework,项目名称:atf-toolbox-java,代码行数:52,代码来源:ZAProxyScanner.java

示例13: run

import org.zaproxy.clientapi.core.ApiResponse; //导入依赖的package包/类
/**
 * Execution of the ZAP ascan job.
 */
@Override
protected IStatus run(IProgressMonitor monitor) {
	IStatus runStatus = Status.OK_STATUS;

	try {
		// Perform Ascan of URL.
		ClientApi zapAPI = ZAPHelper.getInstance().getZAPClient();

		ApiResponse ascanResponse = zapAPI.ascan.scan(ZAPHelper.getInstance().getZapApiKey(), target.getTargetUrl(),
				"True", "False", "", "", "");
		String ascanScanID = ((ApiResponseElement) ascanResponse).getValue();
		scanProgress.setAscanId(ascanScanID);
		while (true) {
			// While the ascan is progressing, send progress updates to the
			// ZAP view.
			int progress = Integer.parseInt(((ApiResponseElement) zapAPI.ascan.status(ascanScanID)).getValue());
			if (scanStatus.isScanCancelled() || progress >= 100) {
				break;
			} else {
				Job scanProgressJob = new ZAPScanProgressJob(display, "Spider Progress", scanProgress,
						eventHandler);
				scanProgressJob.setPriority(Job.INTERACTIVE);
				scanProgressJob.schedule();

				Thread.sleep(500);
			}
		}

		Thread.sleep(5000); // give Ascan scanner time to complete
							// logging

		// Store Ascan results in project file.
		if (!scanStatus.isScanCancelled()) {
			ZAPScanHelper.generateAscanReport(target.getFileName(), target.getReportFormat(),
					sortAscanResults((ApiResponseList) zapAPI.core.alerts(target.getTargetUrl(), "", "")));
		}

	} catch (ClientApiException | InterruptedException | CoreException e) {
		ConsolePlugin.log(e);
		runStatus = Status.CANCEL_STATUS;
	}

	return runStatus;
}
 
开发者ID:polyhedraltech,项目名称:SecurityTesting,代码行数:48,代码来源:ZAPAscanJob.java

示例14: run

import org.zaproxy.clientapi.core.ApiResponse; //导入依赖的package包/类
/**
 * Execution of the ZAP spider job.
 */
@Override
protected IStatus run(IProgressMonitor monitor) {
	IStatus runStatus = Status.OK_STATUS;

	try {
		// Perform spider of URL.
		ClientApi zapAPI = ZAPHelper.getInstance().getZAPClient();

		ApiResponse spiderResponse = zapAPI.spider.scan(ZAPHelper.getInstance().getZapApiKey(),
				target.getTargetUrl(), "100");

		String spiderScanID = ((ApiResponseElement) spiderResponse).getValue();
		scanProgress.setSpiderId(spiderScanID);
		while (true) {
			// While the spider is progressing, send progress updates to the
			// ZAP view.
			Job scanProgressJob = new ZAPScanProgressJob(display, "Spider Progress", scanProgress, eventHandler);
			scanProgressJob.setPriority(Job.INTERACTIVE);
			scanProgressJob.schedule();

			int progress = Integer.parseInt(((ApiResponseElement) zapAPI.spider.status(spiderScanID)).getValue());
			if (scanStatus.isScanCancelled() || progress >= 100) {
				break;
			} else {
				Thread.sleep(500);
			}
		}

		Thread.sleep(5000); // give Spider scanner time to complete
							// logging

		// Store Spider results in a file.
		if (!scanStatus.isScanCancelled()) {
			ZAPScanHelper.generateSpiderReport(target.getFileName(), target.getTargetUrl(),
					(ApiResponseList) zapAPI.spider.fullResults(spiderScanID));
		}

	} catch (ClientApiException | InterruptedException | CoreException e) {
		ConsolePlugin.log(e);
		runStatus = Status.CANCEL_STATUS;
	}

	return runStatus;
}
 
开发者ID:polyhedraltech,项目名称:SecurityTesting,代码行数:48,代码来源:ZAPSpiderJob.java

示例15: statusToInt

import org.zaproxy.clientapi.core.ApiResponse; //导入依赖的package包/类
/**
 * Converts the ZAP API status response to an integer
 *
 * @param response the ZAP API response code
 * @return the integer status of the ApiResponse
 */
private int statusToInt(final ApiResponse response) {
	return Integer.parseInt(((ApiResponseElement)response).getValue());
}
 
开发者ID:jenkinsci,项目名称:zaproxy-plugin,代码行数:10,代码来源:ZAProxy.java


注:本文中的org.zaproxy.clientapi.core.ApiResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。