use of org.zaproxy.zap.extension.authorization.BasicAuthorizationDetectionMethod.LogicalOperator in project zaproxy by zaproxy.
the class AuthorizationAPI method handleApiAction.
@Override
public ApiResponse handleApiAction(String name, JSONObject params) throws ApiException {
log.debug("handleApiAction " + name + " " + params.toString());
Context context;
switch(name) {
case ACTION_SET_AUTHORIZATION_METHOD:
context = ApiUtils.getContextByParamId(params, PARAM_CONTEXT_ID);
String headerRegex = params.optString(PARAM_HEADER_REGEX, null);
String bodyRegex = params.optString(PARAM_BODY_REGEX, null);
LogicalOperator logicalOperator = ApiUtils.getOptionalEnumParam(params, PARAM_LOGICAL_OPERATOR, LogicalOperator.class);
if (logicalOperator == null) {
logicalOperator = LogicalOperator.AND;
}
int statusCode = params.optInt(PARAM_STATUS_CODE, BasicAuthorizationDetectionMethod.NO_STATUS_CODE);
if (log.isDebugEnabled()) {
log.debug(String.format("Setting basic authorization detection to: %s / %s / %d / %s", headerRegex, bodyRegex, statusCode, logicalOperator));
}
BasicAuthorizationDetectionMethod method = new BasicAuthorizationDetectionMethod(statusCode, headerRegex, bodyRegex, logicalOperator);
context.setAuthorizationDetectionMethod(method);
return ApiResponseElement.OK;
default:
throw new ApiException(Type.BAD_ACTION);
}
}
use of org.zaproxy.zap.extension.authorization.BasicAuthorizationDetectionMethod.LogicalOperator in project zaproxy by zaproxy.
the class ContextAuthorizationPanel method saveMethod.
private void saveMethod() {
Integer selectedStatusCode = (Integer) (statusCodeComboBox.getSelectedIndex() == 0 ? null : statusCodeComboBox.getSelectedItem());
LogicalOperator selectedComposition = logicalOperatorComboBox.getSelectedItem().equals(FIELD_VALUE_AND_COMPOSITION) ? LogicalOperator.AND : LogicalOperator.OR;
authorizationMethod = new BasicAuthorizationDetectionMethod(selectedStatusCode, headerPatternText.getText(), bodyPatternText.getText(), selectedComposition);
}
Aggregations