このコンテンツは選択した言語では利用できません。

48.4. glogin


glogin Component

Available in Apache Camel 2.3 (or latest development snapshot).
The glogin component is used by Apache Camel applications outside Google App Engine (GAE) for programmatic login to GAE applications. It is part of the Chapter 48, GAE. Security-enabled GAE applications normally redirect the user to a login page. After submitting username and password for authentication, the user is redirected back to the application. That works fine for applications where the client is a browser. For all other applications, the login process must be done programmatically. All the necessary steps for programmatic login are implemented by the glogin component. These are
  1. Get an authentication token from Google Accounts via the ClientLogin API.
  2. Get an authorization cookie from Google App Engine's login API.
The authorization cookie must then be send with subsequent HTTP requests to the GAE application. It expires after 24 hours and must then be renewed.

URI format

glogin://hostname[:port][?options]
The hostname is either the internet hostname of a GAE application (e.g. camelcloud.appspot.com) or the name of the host where the development server is running (e.g. localhost). The port is only used when connecting to a development server (i.e. when devMode=true, see options) and defaults to 8080.

Options

Name Default Value Required Description
clientName apache-camel-2.x false A client name with recommended (but not required) format <organization>\-<appname>\-<version>.
userName null true (can alternatively be set via GLoginBinding.GLOGIN_USER_NAME message header) Login username (an email address).
password null true (can alternatively be set via GLoginBinding.GLOGIN_PASSWORD message header) Login password.
devMode false false If set to true a login to a development server is attempted.
devAdmin false false If set to true a login to a development server in admin role is attempted.

Message headers

Name Type Message Description
GLoginBinding.GLOGIN_HOST_NAME String in Overrides the hostname defined in the endpoint URI.
GLoginBinding.GLOGIN_USER_NAME String in Overrides the userName option.
GLoginBinding.GLOGIN_PASSWORD String in Overrides the password option.
GLoginBinding.GLOGIN_TOKEN String out Contains the authentication token obtained from Google Accounts. Login to a development server does not set this header.
GLoginBinding.GLOGIN_COOKIE String out Contains the application-specific authorization cookie obtained from Google App Engine (or a development server).

Message body

The glogin component doesn't read or write message bodies.

Usage

The following JUnit test show an example how to login to a development server as well as to a deployed GAE application located at http://camelcloud.appspot.com.
GLoginTest.java
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.ProducerTemplate;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import static org.apache.camel.component.gae.login.GLoginBinding.*;
import static org.junit.Assert.*;

public class GLoginTest {

    private ProducerTemplate template = ...

    @Test
    public void testDevLogin() {
        Exchange result = template.request("glogin://localhost:8888?userName=test@example.org&devMode=true", null);
        assertNotNull(result.getOut().getHeader(GLOGIN_COOKIE));
    }

    @Test
    public void testRemoteLogin() {
        Exchange result = template.request("glogin://camelcloud.appspot.com", new Processor() {
            public void process(Exchange exchange) throws Exception {
                exchange.getIn().setHeader(GLOGIN_USER_NAME, "replaceme@gmail.com");
                exchange.getIn().setHeader(GLOGIN_PASSWORD, "replaceme");
            }
        });
        assertNotNull(result.getOut().getHeader(GLOGIN_COOKIE));
    }

}
The resulting authorization cookie from login to a development server looks like
ahlogincookie=test@example.org:false:11223191102230730701;Path=/
The resulting authorization cookie from login to a deployed GAE application looks (shortened) like
ACSID=AJKiYcE...XxhH9P_jR_V3; expires=Sun, 07-Feb-2010 15:14:51 GMT; path=/
Red Hat logoGithubRedditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

© 2024 Red Hat, Inc.