Example usage for org.apache.http.auth.params AuthParams getCredentialCharset

List of usage examples for org.apache.http.auth.params AuthParams getCredentialCharset

Introduction

In this page you can find the example usage for org.apache.http.auth.params AuthParams getCredentialCharset.

Prototype

public static String getCredentialCharset(final HttpParams params) 

Source Link

Document

Obtains the charset for encoding org.apache.http.auth.Credentials .If not configured, HTTP#DEFAULT_PROTOCOL_CHARSET is used instead.

Usage

From source file:org.odk.collect.android.utilities.EnhancedDigestScheme.java

/**
 * Produces a digest authorization string for the given set of
 * {@link Credentials}, method name and URI.
 * //www. j av a  2  s  . c  o m
 * @param credentials
 *            A set of credentials to be used for athentication
 * @param request
 *            The request being authenticated
 * 
 * @throws org.apache.http.auth.InvalidCredentialsException
 *             if authentication credentials are not valid or not applicable
 *             for this authentication scheme
 * @throws AuthenticationException
 *             if authorization string cannot be generated due to an
 *             authentication failure
 * 
 * @return a digest authorization string
 */
public Header authenticate(final Credentials credentials, final HttpRequest request)
        throws AuthenticationException {

    if (credentials == null) {
        throw new IllegalArgumentException("Credentials may not be null");
    }
    if (request == null) {
        throw new IllegalArgumentException("HTTP request may not be null");
    }

    // Add method name and request-URI to the parameter map
    getParameters().put("methodname", request.getRequestLine().getMethod());
    getParameters().put("uri", request.getRequestLine().getUri());
    String charset = getParameter("charset");
    if (charset == null) {
        charset = AuthParams.getCredentialCharset(request.getParams());
        getParameters().put("charset", charset);
    }
    return createDigestHeader(credentials);
}

From source file:org.obiba.opal.rest.client.magma.OpalJavaClient.java

private void authenticate(HttpMessage msg) {
    if (keyStore == null) {
        msg.addHeader(OpalAuthScheme.authenticate(credentials, AuthParams.getCredentialCharset(msg.getParams()),
                false));/*from  w w w. ja v a  2s  .com*/
    }
}