次の問題があります。PrimeFaces 4.0-SNAPSHOT、JSF2.2、および Glassfish 4.0 を使用して、FORM ベースのログインを作成しました。
別のログインページで使用すると、ログインが機能します。ただし、 http: //www.primefaces.org/showcase/ui/dialogLogin.jsf のショーケースの例に示されているように、PF ポップアップを使用してログインを作成したい場合、ログインはできますが、保護されたサイトには転送されません。
保護された領域をターゲットとするリンクをクリックし、その後ログインダイアログのリンクをクリックした場合にのみ、転送されます。
フォーム ベースのログインは、ログイン ダイアログを使用するときに、何らかの形で保護領域をターゲットにできる場合にのみ機能するようです。loginBean を使用してこれを行うことができますか、それとも FORM ベースの認証のみを使用してこれを行うことができますか? 誰かが可能な解決策を教えてもらえますか? 私はこの環境に不慣れで、ポップアップ ダイアログ ボックスと組み合わせたフォーム ベースのログインに関する解決策を見つけることができませんでした。
どうもありがとう。
ポップアップをトリガーするリンク:
<h:outputLink id="loginLink" value="javascript:void(0)" onclick="PF('dlg').show()" title="login" class="sign_in" >Sign in here!</h:outputLink>
ログインフォーム:
<p:dialog id="logindialog" header="Login" widgetVar="dlg" resizable="false">
<h:form id="login" onsubmit="document.getElementById('login').action='j_security_check';" prependId="false">
<p:growl id="growl" showDetail="true" life="3000" />
<h:panelGrid columns="3" cellpadding="5">
<h:outputLabel for="j_username" value="Username:" />
<p:inputText id="j_username" />
<p:tooltip for="j_username" value="Bitte Benutzernamen eingeben" showEffect="fade" hideEffect="fade" />
<h:outputLabel for="password" value="Password:" />
<p:password id="j_password" />
<p:tooltip for="j_password" value="Bitte Passwort eingeben" showEffect="fade" hideEffect="fade" />
<f:facet name="footer">
<div style="text-align: center">
<p:commandButton id="submit" value="Login" ajax="false" oncomplete="app/index?faces-redirect=true"/>
</div>
</f:facet>
</h:panelGrid>
</h:form>
</p:dialog>
web.xml
<security-constraint>
<display-name>Mofnug Pages</display-name>
<web-resource-collection>
<web-resource-name>Protected Mofnug Area</web-resource-name>
<description></description>
<url-pattern>/faces/app/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>HEAD</http-method>
<http-method>PUT</http-method>
<http-method>OPTIONS</http-method>
<http-method>TRACE</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint>
<description/>
<role-name>admin</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>mofnug</realm-name>
<form-login-config>
<form-login-page>/faces/index.xhtml</form-login-page>
<form-error-page>/faces/loginerror.xhtml</form-error-page>
</form-login-config>
</login-config>