camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > glogin
Date Wed, 09 Jun 2010 11:18:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/9/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CAMEL/glogin">glogin</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~fbolton">Fintan
Bolton</a>
    </h4>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
            <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>{code} <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">gauth://hostname[:port][?options]</span>
<span class="diff-added-words"style="background-color: #dfd;">glogin://hostname[:port][?options]</span>
<br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
        </table>
</div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="glogin-%7B%7Bglogin%7D%7DComponent"></a><tt>glogin</tt>
Component</h2>

<p><b>Available in Camel 2.3</b></p>

<p>The <tt>glogin</tt> component is used by Camel applications outside Google
App Engine (GAE) for programmatic login to GAE applications. It is part of the <a href="/confluence/display/CAMEL/GAE"
title="GAE">Camel Components for Google App Engine</a>. <a href="/confluence/display/CAMEL/gsec"
title="gsec">Security-enabled GAE applications</a> 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 <a href="http://krasserm.blogspot.com/2010/01/accessing-security-enabled-google-app.html"
class="external-link" rel="nofollow">necessary steps</a> for programmatic login are
implemented by the <tt>glogin</tt> component. These are</p>

<ol>
	<li>Get an authentication token from <a href="http://code.google.com/apis/accounts/"
class="external-link" rel="nofollow">Google Accounts</a> via the <a href="http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html"
class="external-link" rel="nofollow">ClientLogin API</a>.</li>
	<li>Get an authorization cookie from Google App Engine's login API.</li>
</ol>


<p>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.</p>

<h3><a name="glogin-URIformat"></a>URI format</h3>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
glogin:<span class="code-comment">//hostname[:port][?options]</span>
</pre>
</div></div>

<p>The <tt>hostname</tt> is either the internet hostname of a GAE application
(e.g. <tt>camelcloud.appspot.com</tt>) or the name of the host where the <a
href="http://code.google.com/appengine/docs/java/tools/devserver.html" class="external-link"
rel="nofollow">development server</a> is running (e.g. <tt>localhost</tt>).
The <tt>port</tt> is only used when connecting to a development server (i.e. when
<tt>devMode=true</tt>, see <a href="#glogin-Options">options</a>)
and defaults to <tt>8080</tt>. </p>

<h3><a name="glogin-Options"></a>Options</h3>

<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Required </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>clientName</tt> </td>
<td class='confluenceTd'> <tt>apache-camel-2.x</tt> </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> A client name with recommended (but not required) format <tt>&lt;organization&gt;&#45;&lt;appname&gt;&#45;&lt;version&gt;</tt>.</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>userName</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> true (can alternatively be set via <tt>GLoginBinding.GLOGIN_USER_NAME</tt>
<a href="#glogin-Messageheaders">message header</a>) </td>
<td class='confluenceTd'> Login username (an email address).</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>password</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> true (can alternatively be set via <tt>GLoginBinding.GLOGIN_PASSWORD</tt>
<a href="#glogin-Messageheaders">message header</a>) </td>
<td class='confluenceTd'> Login password.</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>devMode</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> false</td>
<td class='confluenceTd'> If set to <tt>true</tt> a login to a development
server is attempted.</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>devAdmin</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'>If set to <tt>true</tt> a login to a development
server in admin role is attempted.</td>
</tr>
</tbody></table>
</div>


<h3><a name="glogin-Messageheaders"></a>Message headers</h3>

<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Message </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>GLoginBinding.GLOGIN_HOST_NAME</tt> </td>
<td class='confluenceTd'> <tt>String</tt></td>
<td class='confluenceTd'> in </td>
<td class='confluenceTd'> Overrides the hostname defined in the endpoint URI.</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>GLoginBinding.GLOGIN_USER_NAME</tt> </td>
<td class='confluenceTd'> <tt>String</tt></td>
<td class='confluenceTd'> in </td>
<td class='confluenceTd'> Overrides the <tt>userName</tt> option.</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>GLoginBinding.GLOGIN_PASSWORD</tt> </td>
<td class='confluenceTd'> <tt>String</tt></td>
<td class='confluenceTd'> in </td>
<td class='confluenceTd'> Overrides the <tt>password</tt> option.</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>GLoginBinding.GLOGIN_TOKEN</tt> </td>
<td class='confluenceTd'> <tt>String</tt></td>
<td class='confluenceTd'> out </td>
<td class='confluenceTd'> Contains the authentication token obtained from <a href="http://code.google.com/apis/accounts/"
class="external-link" rel="nofollow">Google Accounts</a>. Login to a development
server does not set this header.</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>GLoginBinding.GLOGIN_COOKIE</tt> </td>
<td class='confluenceTd'> <tt>String</tt></td>
<td class='confluenceTd'> out </td>
<td class='confluenceTd'> Contains the application-specific authorization cookie obtained
from Google App Engine (or a development server).</td>
</tr>
</tbody></table>
</div>


<h3><a name="glogin-Messagebody"></a>Message body</h3>

<p>The <tt>glogin</tt> component doesn't read or write message bodies.</p>

<h3><a name="glogin-Usage"></a>Usage</h3>

<p>The following JUnit test show an example how to login to a development server as
well as to a deployed GAE application located at <a href="http://camelcloud.appspot.com"
class="external-link" rel="nofollow">http://camelcloud.appspot.com</a>. </p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>GLoginTest.java</b></div><div
class="codeContent panelContent">
<pre class="code-java">
<span class="code-keyword">import</span> org.apache.camel.Exchange;
<span class="code-keyword">import</span> org.apache.camel.Processor;
<span class="code-keyword">import</span> org.apache.camel.ProducerTemplate;
<span class="code-keyword">import</span> org.junit.Ignore;
<span class="code-keyword">import</span> org.junit.Test;
<span class="code-keyword">import</span> org.junit.runner.RunWith;
<span class="code-keyword">import</span> org.springframework.beans.factory.annotation.Autowired;
<span class="code-keyword">import</span> org.springframework.test.context.ContextConfiguration;
<span class="code-keyword">import</span> org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

<span class="code-keyword">import</span> <span class="code-keyword">static</span>
org.apache.camel.component.gae.login.GLoginBinding.*;
<span class="code-keyword">import</span> <span class="code-keyword">static</span>
org.junit.Assert.*;

<span class="code-keyword">public</span> class GLoginTest {

    <span class="code-keyword">private</span> ProducerTemplate template = ...

    @Test
    <span class="code-keyword">public</span> void testDevLogin() {
        Exchange result = template.request(<span class="code-quote">"glogin:<span
class="code-comment">//localhost:8888?userName=test@example.org&amp;devMode=<span
class="code-keyword">true</span>"</span>, <span class="code-keyword">null</span>);
</span>        assertNotNull(result.getOut().getHeader(GLOGIN_COOKIE));
    }

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

}
</pre>
</div></div>

<p>The resulting authorization cookie from login to a development server looks like</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>ahlogincookie=test@example.org:false:11223191102230730701;Path=/
</pre>
</div></div>

<p>The resulting authorization cookie from login to a deployed GAE application looks
(shortened) like </p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>ACSID=AJKiYcE...XxhH9P_jR_V3; expires=Sun, 07-Feb-2010 15:14:51 GMT; path=/
</pre>
</div></div>

<h3><a name="glogin-Dependencies"></a>Dependencies</h3>

<p>Maven users will need to add the following dependency to their <tt>pom.xml</tt>.
</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>pom.xml</b></div><div class="codeContent
panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;dependency&gt;</span>
    <span class="code-tag">&lt;groupId&gt;</span>org.apache.camel<span
class="code-tag">&lt;/groupId&gt;</span>
    <span class="code-tag">&lt;artifactId&gt;</span>camel-gae<span
class="code-tag">&lt;/artifactId&gt;</span>
    <span class="code-tag">&lt;version&gt;</span>${camel-version}<span
class="code-tag">&lt;/version&gt;</span>
<span class="code-tag">&lt;/dependency&gt;</span>
</pre>
</div></div>

<p>where <tt>${camel-version</tt>} must be replaced by the actual version
of Camel (2.3.0 or higher).</p>

<h3><a name="glogin-SeeAlso"></a>See Also</h3>
<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring
Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting
Started</a></li>
</ul>

    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/glogin">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=13271489&revisedVersion=3&originalVersion=2">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/glogin?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message