Example usage for com.liferay.portal.kernel.servlet HttpHeaders AUTHORIZATION

List of usage examples for com.liferay.portal.kernel.servlet HttpHeaders AUTHORIZATION

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.servlet HttpHeaders AUTHORIZATION.

Prototype

String AUTHORIZATION

To view the source code for com.liferay.portal.kernel.servlet HttpHeaders AUTHORIZATION.

Click Source Link

Usage

From source file:com.liferay.google.apps.connector.GHelperUtil.java

License:Open Source License

private static Http.Options _getOptions(GAuthenticator gAuthenticator) {
    Http.Options options = new Http.Options();

    options.addHeader(HttpHeaders.AUTHORIZATION, "GoogleLogin auth=" + gAuthenticator.getAuthenticationToken());

    return options;
}

From source file:org.kmworks.liferay.rpc.utils.RPCTunnelUtil.java

License:Open Source License

private static HttpURLConnection _getConnection(String baseUrl, String login, String password)
        throws IOException {

    checkNotNull(baseUrl);//  w  w  w. j  av  a 2  s.  co m
    checkNotNull(login);
    checkNotNull(password);

    ///-URL url = new URL(httpPrincipal.getUrl() + "/api/liferay/do");
    final URL url = new URL(baseUrl + "/rpc-server-hook/api/do"); ///+
    HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
    httpURLConnection.setDoInput(true);
    httpURLConnection.setDoOutput(true);

    if (!_VERIFY_SSL_HOSTNAME && httpURLConnection instanceof HttpsURLConnection) {
        HttpsURLConnection httpsURLConnection = (HttpsURLConnection) httpURLConnection;

        httpsURLConnection.setHostnameVerifier(new HostnameVerifier() {

            @Override
            public boolean verify(String hostname, SSLSession session) {
                return true;
            }
        });
    }

    httpURLConnection.setRequestProperty(HttpHeaders.CONTENT_TYPE,
            ContentTypes.APPLICATION_X_JAVA_SERIALIZED_OBJECT);
    httpURLConnection.setUseCaches(false);
    httpURLConnection.setRequestMethod(HttpMethods.POST);

    final String userNameAndPassword = login + StringPool.COLON + password;
    httpURLConnection.setRequestProperty(HttpHeaders.AUTHORIZATION,
            HttpServletRequest.BASIC_AUTH + StringPool.SPACE + Base64.encode(userNameAndPassword.getBytes()));

    return httpURLConnection;
}

From source file:org.kmworks.portal.rpc.io.HttpUtil.java

License:Open Source License

public static HttpURLConnection getConnection(String tgtUrl, String loginName, String password,
        String contentType) throws IOException {

    checkNotNull(tgtUrl);/*from   ww w .ja v a  2s.  c  o  m*/
    checkNotNull(loginName);
    checkNotNull(password);
    checkNotNull(contentType);

    final URL url = new URL(tgtUrl); ///+

    final HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
    httpURLConnection.setDoInput(true);
    httpURLConnection.setDoOutput(true);
    httpURLConnection.setRequestProperty(HttpHeaders.CONTENT_TYPE, contentType);
    httpURLConnection.setUseCaches(false);
    httpURLConnection.setRequestMethod(HttpMethods.POST);

    final String userNameAndPassword = loginName + ":" + password;
    httpURLConnection.setRequestProperty(HttpHeaders.AUTHORIZATION,
            HttpServletRequest.BASIC_AUTH + " " + Base64.encode(userNameAndPassword.getBytes()));

    return httpURLConnection;
}