Java Code Examples for javax.servlet.http.HttpServletRequest#BASIC_AUTH

The following examples show how to use javax.servlet.http.HttpServletRequest#BASIC_AUTH . These examples are extracted from open source projects. 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
private void checkExpectedMechanism(HttpServletRequest req) {
    String expectedMechanism = req.getHeader("ExpectedMechanism");
    if (expectedMechanism == null) {
        throw new IllegalStateException("No ExpectedMechanism received.");
    }
    if (expectedMechanism.equals("None")) {
        if (req.getAuthType() != null) {
            throw new IllegalStateException("Authentication occurred when not expected.");
        }
    } else if (expectedMechanism.equals("BASIC")) {
        if (req.getAuthType() != HttpServletRequest.BASIC_AUTH) {
            throw new IllegalStateException("Expected mechanism type not matched.");
        }
    } else {
        throw new IllegalStateException("ExpectedMechanism not recognised.");
    }
}
 
Example 2
Source Project: Tomcat8-Source-Read   File: BasicAuthenticator.java    License: MIT License 4 votes vote down vote up
@Override
protected String getAuthMethod() {
    return HttpServletRequest.BASIC_AUTH;
}
 
Example 3
Source Project: onedev   File: ExceptionUtils.java    License: MIT License 4 votes vote down vote up
private static void requireAuthentication(HttpServletResponse response) {
	response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    String authcHeader = HttpServletRequest.BASIC_AUTH + " realm=\"" + OneDev.NAME + "\"";
    response.setHeader(HttpHeaders.WWW_AUTHENTICATE, authcHeader);
}
 
Example 4
public String getAuthType() {
	return HttpServletRequest.BASIC_AUTH;
}
 
Example 5
Source Project: Tomcat7.0.67   File: BasicAuthenticator.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected String getAuthMethod() {
    return HttpServletRequest.BASIC_AUTH;
}
 
Example 6
@Override
public String getAuthType() {
	return HttpServletRequest.BASIC_AUTH;
}
 
Example 7
Source Project: tomcatsrc   File: BasicAuthenticator.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected String getAuthMethod() {
    return HttpServletRequest.BASIC_AUTH;
}
 
Example 8
/**
 * {@inheritDoc}
 */
@Override
public String getAuthType( HttpServletRequest request )
{
    return HttpServletRequest.BASIC_AUTH;
}