Java Code Examples for org.elasticsearch.rest.RestRequest#hasContentOrSourceParam()
The following examples show how to use
org.elasticsearch.rest.RestRequest#hasContentOrSourceParam() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractAuditLog.java From deprecated-security-advanced-modules with Apache License 2.0 | 6 votes |
@Override public void logFailedLogin(String effectiveUser, boolean securityadmin, String initiatingUser, RestRequest request) { if(!checkRestFilter(Category.FAILED_LOGIN, effectiveUser, request)) { return; } AuditMessage msg = new AuditMessage(Category.FAILED_LOGIN, clusterService, getOrigin(), Origin.REST); TransportAddress remoteAddress = getRemoteAddress(); msg.addRemoteAddress(remoteAddress); if(request != null && logRequestBody && request.hasContentOrSourceParam()) { msg.addTupleToRequestBody(request.contentOrSourceParam()); } if(request != null) { msg.addPath(request.path()); msg.addRestHeaders(request.getHeaders(), excludeSensitiveHeaders); msg.addRestParams(request.params()); } msg.addInitiatingUser(initiatingUser); msg.addEffectiveUser(effectiveUser); msg.addIsAdminDn(securityadmin); save(msg); }
Example 2
Source File: AbstractAuditLog.java From deprecated-security-advanced-modules with Apache License 2.0 | 6 votes |
@Override public void logSucceededLogin(String effectiveUser, boolean securityadmin, String initiatingUser, RestRequest request) { if(!checkRestFilter(Category.AUTHENTICATED, effectiveUser, request)) { return; } AuditMessage msg = new AuditMessage(Category.AUTHENTICATED, clusterService, getOrigin(), Origin.REST); TransportAddress remoteAddress = getRemoteAddress(); msg.addRemoteAddress(remoteAddress); if(request != null && logRequestBody && request.hasContentOrSourceParam()) { msg.addTupleToRequestBody(request.contentOrSourceParam()); } if(request != null) { msg.addPath(request.path()); msg.addRestHeaders(request.getHeaders(), excludeSensitiveHeaders); msg.addRestParams(request.params()); } msg.addInitiatingUser(initiatingUser); msg.addEffectiveUser(effectiveUser); msg.addIsAdminDn(securityadmin); save(msg); }
Example 3
Source File: AbstractAuditLog.java From deprecated-security-advanced-modules with Apache License 2.0 | 6 votes |
@Override public void logMissingPrivileges(String privilege, String effectiveUser, RestRequest request) { if(!checkRestFilter(Category.MISSING_PRIVILEGES, effectiveUser, request)) { return; } AuditMessage msg = new AuditMessage(Category.MISSING_PRIVILEGES, clusterService, getOrigin(), Origin.REST); TransportAddress remoteAddress = getRemoteAddress(); msg.addRemoteAddress(remoteAddress); if(request != null && logRequestBody && request.hasContentOrSourceParam()) { msg.addTupleToRequestBody(request.contentOrSourceParam()); } if(request != null) { msg.addPath(request.path()); msg.addRestHeaders(request.getHeaders(), excludeSensitiveHeaders); msg.addRestParams(request.params()); } msg.addEffectiveUser(effectiveUser); save(msg); }
Example 4
Source File: AbstractAuditLog.java From deprecated-security-advanced-modules with Apache License 2.0 | 6 votes |
@Override public void logBadHeaders(RestRequest request) { if(!checkRestFilter(Category.BAD_HEADERS, getUser(), request)) { return; } AuditMessage msg = new AuditMessage(Category.BAD_HEADERS, clusterService, getOrigin(), Origin.REST); TransportAddress remoteAddress = getRemoteAddress(); msg.addRemoteAddress(remoteAddress); if(request != null && logRequestBody && request.hasContentOrSourceParam()) { msg.addTupleToRequestBody(request.contentOrSourceParam()); } if(request != null) { msg.addPath(request.path()); msg.addRestHeaders(request.getHeaders(), excludeSensitiveHeaders); msg.addRestParams(request.params()); } msg.addEffectiveUser(getUser()); save(msg); }
Example 5
Source File: AbstractAuditLog.java From deprecated-security-advanced-modules with Apache License 2.0 | 6 votes |
@Override public void logSSLException(RestRequest request, Throwable t) { if(!checkRestFilter(Category.SSL_EXCEPTION, getUser(), request)) { return; } AuditMessage msg = new AuditMessage(Category.SSL_EXCEPTION, clusterService, Origin.REST, Origin.REST); TransportAddress remoteAddress = getRemoteAddress(); msg.addRemoteAddress(remoteAddress); if(request != null && logRequestBody && request.hasContentOrSourceParam()) { msg.addTupleToRequestBody(request.contentOrSourceParam()); } if(request != null) { msg.addPath(request.path()); msg.addRestHeaders(request.getHeaders(), excludeSensitiveHeaders); msg.addRestParams(request.params()); } msg.addException(t); msg.addEffectiveUser(getUser()); save(msg); }
Example 6
Source File: RestAddFeatureToSet.java From elasticsearch-learning-to-rank with Apache License 2.0 | 5 votes |
@Override protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException { String store = indexName(request); String setName = request.param("name"); String routing = request.param("routing"); String featureQuery = null; List<StoredFeature> features = null; boolean merge = request.paramAsBoolean("merge", false); if (request.hasParam("query")) { featureQuery = request.param("query"); } FeatureValidation validation = null; if (request.hasContentOrSourceParam()) { FeaturesParserState featuresParser = new FeaturesParserState(); request.applyContentParser(featuresParser::parse); features = featuresParser.features; validation = featuresParser.validation; } if (featureQuery == null && (features == null || features.isEmpty())) { throw new IllegalArgumentException("features must be provided as a query for the feature store " + "or in the body, none provided"); } if (featureQuery != null && (features != null && !features.isEmpty())) { throw new IllegalArgumentException("features must be provided as a query for the feature store " + "or directly in the body not both"); } AddFeaturesToSetRequestBuilder builder = new AddFeaturesToSetRequestBuilder(client); builder.request().setStore(store); builder.request().setFeatureSet(setName); builder.request().setFeatureNameQuery(featureQuery); builder.request().setRouting(routing); builder.request().setFeatures(features); builder.request().setMerge(merge); builder.request().setValidation(validation); return (channel) -> builder.execute(new RestStatusToXContentListener<>(channel, (r) -> r.getResponse().getLocation(routing))); }