3

單擊Google Apps帳戶中Google通用導航欄的「更多」部分中的導航鏈接時,我不直接登錄到我的應用程序,而是單擊登錄頁面顯示我的應用程序。Google Apps Marketplace - 適用於Google App Engine的SSO Java應用程序

我Apps Marketplace中的清單:

<ApplicationManifest xmlns="http://schemas.google.com/ApplicationManifest/2009"> 
    <Name>App Name</Name> 
    <Description>App Description</Description> 

    <!-- Administrators and users will be sent to this URL for application support --> 
    <Support> 
    <Link rel="support" href="http://myappid.appspot.com/help.html" /> 
    </Support> 

    <!-- Show this link in Google's universal navigation for all users --> 
    <Extension id="navLink" type="link"> 
    <Name>Myapp Navlink Name</Name> 
    <Url>http://myappid.appspot.com/ms.jsp?hd=${DOMAIN_NAME}</Url> 
    </Extension> 

    <!-- Declare our OpenID realm so our app is white listed --> 
    <Extension id="realm" type="openIdRealm"> 
    <Url>http://myappid.appspot.com/</Url> 
    </Extension> 

</ApplicationManifest> 

我的web.xml中相關部分:

<servlet> 
    <servlet-name>loginJsp</servlet-name> 
    <jsp-file>/login.jsp</jsp-file> 
</servlet> 

<servlet-mapping> 
    <servlet-name>loginJsp</servlet-name> 
    <url-pattern>/_ah/login_required</url-pattern> 
</servlet-mapping> 

<security-constraint> 
    <web-resource-collection> 
    <web-resource-name>ms</web-resource-name> 
    <url-pattern>/ms.jsp</url-pattern> 
    </web-resource-collection> 
    <auth-constraint> 
    <role-name>*</role-name> 
    </auth-constraint> 
</security-constraint> 

回答

0

您需要創建一個servlet來處理http://myappid.appspot.com/ms.jsp?hd=${DOMAIN_NAME}。它將獲得域名並重定向到使用域名的登錄網址federatedIdentity。請參閱:

http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/users/UserService.html#createLoginURL%28java.lang.String,%20java.lang.String,%20java.lang.String,%20java.util.Set%29

有了正確的federatedIdentity設置,用戶將谷歌從應用程序自動登錄。

0

另外。你應該添加到您的應用程序的manifest.xml:

<Edition id="free"> 
    <Name>Myapp Navlink Name</Name> 
    <Extension ref="navLink" /> 
    <Extension ref="realm" /> 
</Edition> 
相關問題