Java Code Examples for org.elasticsearch.ElasticsearchSecurityException#addHeader()

The following examples show how to use org.elasticsearch.ElasticsearchSecurityException#addHeader() . 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: KerberosAuthenticationFailureHandler.java    From elasticsearch-shield-kerberos-realm with Apache License 2.0 6 votes vote down vote up
@Override
public ElasticsearchSecurityException exceptionProcessingRequest(final RestRequest request, final Exception e) {
    final ElasticsearchSecurityException se = super.exceptionProcessingRequest(request, e);
    String outToken = "";
    if (e instanceof ElasticsearchException) {
        final ElasticsearchException kae = (ElasticsearchException) e;
        if (kae.getHeader("kerberos_out_token") != null) {
            outToken = " " + kae.getHeader("kerberos_out_token").get(0);
        }
    }

    se.addHeader(KrbConstants.WWW_AUTHENTICATE, KrbConstants.NEGOTIATE + outToken);

    if (logger.isDebugEnabled()) {
        logger.debug("exception for rest request: {}", e.toString());
    }

    return se;
}
 
Example 2
Source File: KerberosAuthenticationFailureHandler.java    From elasticsearch-shield-kerberos-realm with Apache License 2.0 6 votes vote down vote up
@Override
public ElasticsearchSecurityException exceptionProcessingRequest(final TransportMessage message, final Exception e) {
    final ElasticsearchSecurityException se = super.exceptionProcessingRequest(message, e);
    String outToken = "";

    if (e instanceof ElasticsearchException) {
        final ElasticsearchException kae = (ElasticsearchException) e;
        if (kae.getHeader("kerberos_out_token") != null) {
            outToken = " " + kae.getHeader("kerberos_out_token").get(0);
        }
    }
    se.addHeader(KrbConstants.WWW_AUTHENTICATE, KrbConstants.NEGOTIATE + outToken);

    if (logger.isDebugEnabled()) {
        logger.debug("exception for transport message: {}", e.toString());
    }

    return se;
}
 
Example 3
Source File: CustomAuthenticationFailureHandler.java    From shield-custom-realm-example with Apache License 2.0 5 votes vote down vote up
@Override
public ElasticsearchSecurityException failedAuthentication(RestRequest request, AuthenticationToken token, ThreadContext context) {
    ElasticsearchSecurityException e = super.failedAuthentication(request, token, context);
    // set a custom header
    e.addHeader("WWW-Authenticate", "custom-challenge");
    return e;
}
 
Example 4
Source File: CustomAuthenticationFailureHandler.java    From shield-custom-realm-example with Apache License 2.0 5 votes vote down vote up
@Override
public ElasticsearchSecurityException failedAuthentication(TransportMessage message, AuthenticationToken token, String action,
                                                           ThreadContext context) {
    ElasticsearchSecurityException e = super.failedAuthentication(message, token, action, context);
    // set a custom header
    e.addHeader("WWW-Authenticate", "custom-challenge");
    return e;
}
 
Example 5
Source File: CustomAuthenticationFailureHandler.java    From shield-custom-realm-example with Apache License 2.0 5 votes vote down vote up
@Override
public ElasticsearchSecurityException missingToken(RestRequest request, ThreadContext context) {
    ElasticsearchSecurityException e = super.missingToken(request, context);
    // set a custom header
    e.addHeader("WWW-Authenticate", "custom-challenge");
    return e;
}
 
Example 6
Source File: CustomAuthenticationFailureHandler.java    From shield-custom-realm-example with Apache License 2.0 5 votes vote down vote up
@Override
public ElasticsearchSecurityException missingToken(TransportMessage message, String action, ThreadContext context) {
    ElasticsearchSecurityException e = super.missingToken(message, action, context);
    // set a custom header
    e.addHeader("WWW-Authenticate", "custom-challenge");
    return e;
}
 
Example 7
Source File: CustomAuthenticationFailureHandler.java    From shield-custom-realm-example with Apache License 2.0 5 votes vote down vote up
@Override
public ElasticsearchSecurityException exceptionProcessingRequest(RestRequest request, Exception e, ThreadContext context) {
    ElasticsearchSecurityException se = super.exceptionProcessingRequest(request, e, context);
    // set a custom header
    se.addHeader("WWW-Authenticate", "custom-challenge");
    return se;
}
 
Example 8
Source File: CustomAuthenticationFailureHandler.java    From shield-custom-realm-example with Apache License 2.0 5 votes vote down vote up
@Override
public ElasticsearchSecurityException exceptionProcessingRequest(TransportMessage message, String action, Exception e,
                                                                 ThreadContext context) {
    ElasticsearchSecurityException se = super.exceptionProcessingRequest(message, action, e, context);
    // set a custom header
    se.addHeader("WWW-Authenticate", "custom-challenge");
    return se;
}
 
Example 9
Source File: CustomAuthenticationFailureHandler.java    From shield-custom-realm-example with Apache License 2.0 5 votes vote down vote up
@Override
public ElasticsearchSecurityException authenticationRequired(String action, ThreadContext context) {
    ElasticsearchSecurityException se = super.authenticationRequired(action, context);
    // set a custom header
    se.addHeader("WWW-Authenticate", "custom-challenge");
    return se;
}
 
Example 10
Source File: KerberosAuthenticationFailureHandler.java    From elasticsearch-shield-kerberos-realm with Apache License 2.0 5 votes vote down vote up
@Override
public ElasticsearchSecurityException unsuccessfulAuthentication(final RestRequest request, final AuthenticationToken token) {
    final ElasticsearchSecurityException e = super.unsuccessfulAuthentication(request, token);
    e.addHeader(KrbConstants.WWW_AUTHENTICATE, KrbConstants.NEGOTIATE);
    if (logger.isDebugEnabled()) {
        logger.debug("unsuccessfulAuthentication for rest request and token {}", token);
    }
    return e;
}
 
Example 11
Source File: KerberosAuthenticationFailureHandler.java    From elasticsearch-shield-kerberos-realm with Apache License 2.0 5 votes vote down vote up
@Override
public ElasticsearchSecurityException missingToken(final RestRequest request) {
    final ElasticsearchSecurityException e = super.missingToken(request);
    e.addHeader(KrbConstants.WWW_AUTHENTICATE, KrbConstants.NEGOTIATE);
    if (logger.isDebugEnabled()) {
        logger.debug("missing token for rest request");
    }
    return e;
}
 
Example 12
Source File: KerberosAuthenticationFailureHandler.java    From elasticsearch-shield-kerberos-realm with Apache License 2.0 5 votes vote down vote up
@Override
public ElasticsearchSecurityException authenticationRequired(final String action) {
    final ElasticsearchSecurityException se = super.authenticationRequired(action);
    se.addHeader(KrbConstants.WWW_AUTHENTICATE, KrbConstants.NEGOTIATE);

    if (logger.isDebugEnabled()) {
        logger.debug("authentication required for action {}", action);
    }
    return se;
}
 
Example 13
Source File: KerberosAuthenticationFailureHandler.java    From elasticsearch-shield-kerberos-realm with Apache License 2.0 5 votes vote down vote up
@Override
public ElasticsearchSecurityException missingToken(final TransportMessage message, final String action) {
    final ElasticsearchSecurityException se = super.missingToken(message, action);
    se.addHeader(KrbConstants.WWW_AUTHENTICATE, KrbConstants.NEGOTIATE);

    if (logger.isDebugEnabled()) {
        logger.debug("missing token for {} transport message", action);
    }

    return se;
}
 
Example 14
Source File: KerberosAuthenticationFailureHandler.java    From elasticsearch-shield-kerberos-realm with Apache License 2.0 5 votes vote down vote up
@Override
public ElasticsearchSecurityException unsuccessfulAuthentication(final TransportMessage message, final AuthenticationToken token,
        final String action) {
    final ElasticsearchSecurityException se = super.unsuccessfulAuthentication(message, token, action);
    se.addHeader(KrbConstants.WWW_AUTHENTICATE, KrbConstants.NEGOTIATE);

    if (logger.isDebugEnabled()) {
        logger.debug("unsuccessfulAuthentication for {} transport message and token {}", action, token);
    }

    return se;
}