이 콘텐츠는 선택한 언어로 제공되지 않습니다.

51.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 51, 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]
Copy to Clipboard Toggle word wrap
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

Expand
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

Expand
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));
    }

}
Copy to Clipboard Toggle word wrap
The resulting authorization cookie from login to a development server looks like
ahlogincookie=test@example.org:false:11223191102230730701;Path=/
Copy to Clipboard Toggle word wrap
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=/
Copy to Clipboard Toggle word wrap
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat