J_scurity_check fails in Firefox 4 - firefox4

The applications works fine in Firefox3.6 ,all versions of IE. I downloaded Firefox 4 and tried to login. When I entered user name and password and click on submit button, It just clears the labels and when I hit on refresh button it submits the form. If I enter wrong userid and password it redirects to the error page.
<form method="POST" action="j_security_check">
Username: <input type="text" name="j_username"> <br/>
Password: <input type="password" name="j_password">
<input type="submit" value="Login">
</form>
There are no error messages in the logs.

I still have no clue about your problem as you do not give much details about your environment and application. Do you use any javascript or ajax in your login page for example? Do you have some mal formed tags between tags?
In my case, I am using java-ee-5, JSF 2.0 framework (My login page works in Firefox 3.6, Opera 11 and IE8 but not in Google Chrome)
Here is my working login page (tested on Firefox 3.6.17 and 4.0.1).
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:o="http://openfaces.org/">
<h:head>
<div align="center">
<h:outputText value="Logon"
style="text-align: center;font-weight: bolder"/>
<br />
</div>
<h:outputStylesheet name="css/style.css"/>
<link rel="icon" href="#{resource['images/diagnostic.ico']}" type="image/x-icon"/>
<link rel="shortcut icon" href="#{resource['images/diagnostic.ico']}" type="image/x-icon"/>
</h:head>
<h:body style="font-weight: lighter;background: url(#{resource['images/master-bg.jpg']});background-repeat: repeat;">
<h:form id="logonform" onsubmit="document.logonform.action = 'j_security_check';">
<p:panel header="#{bundle.Login}" style="font-weight: lighter">
<h:panelGrid columns="2">
<h:outputLabel for="j_username" value="#{bundle.Username}" style="font-weight: bold;"/>
<input id="usernameid" type="text" name="j_username" />
<h:outputLabel for="j_password" value="#{bundle.Password}" style="font-weight: bold;"/>
<input type="password" name="j_password" />
<h:outputText value="" />
<h:panelGrid columns="2">
<p:commandButton value="Connexion" type="submit" ajax="false"/>
<p:button outcome="Logon" value="Cancel" />
</h:panelGrid>
</h:panelGrid>
</p:panel>
</h:form>
</h:body>
</html>
I used the same plain html form as you and it is working for me too in Firefox 4.0.1 and even better than 3.6.17.

I am also seeking an answer to this problem. I am developing a JavaEE6/JSF2 web application that runs inside Glassfish (first 3.0.1 and now 3.1).
The FORM based login was working fine on Firefox3.x versions, and still works fine on Safari5.0.5, but "fails silently" on both Firefox4.0.1 and on Google Chrome 12.0.742.91. (I am on Mac OS X and have not checked IE.)
It is very difficult to provide diagnostics since there are none.
Q: Are there any other logs or possible source of diagnostics I can switch on for Firefox and/or Google Chrome that might throw light in the subject ?
Here is my form:
<form id="loginForm" method="POST" action="j_security_check">
<h:panelGrid columns="3" styleClass="login" columnClasses="login-label, login-field">
<h:outputLabel for="j_username">Username:</h:outputLabel>
<h:inputText id="j_username" required="true" />
<h:message for="j_username" />
<h:outputLabel for="j_password">Password:</h:outputLabel>
<h:inputSecret id="j_password" required="true" />
<h:message for="j_password" />
<h:outputLabel for="login_button"></h:outputLabel>
<h:commandButton id="login_button" value="Login" />
</h:panelGrid>
This is similar to examples shown elsewhere that are claimed to be compatible with Firefox 4, such as from here (to respect copyright conditions not copied here, please examine external link then return):
enter link description here
That login form is claimed to be compatible with Mozilla Firefox 4, Internet Explorer 8, Chrome 11. Safari 5, Opera 11. But I can't see that it is very different from my own.

Related

CAS - Redirect to custom login page when credentials are wrong

Good morning.
I've successfully configured a CAS SSO server and client. However, I want to change CAS' configurations to use a custom login page. I followed this tutorial to make such configuration and it works like a charm. But, the problem is that when I enter invalid credentials (wrong username or password) it tries to redirect to the CAS' default login page; however, it should redirect to the custom external login page. I would really appreciate if you help me to find out how to make CAS to redirect to a different page when wrong credentials are entered.
This is my casLoginView.jsp
<%# page contentType="text/html; charset=UTF-8" %>
<html>
<head>
<script type="text/javascript">
function doAutoLogin() {
document.forms[0].submit();
}
</script>
</head>
<body onload="doAutoLogin();">
<form id="credentials" method="POST" action="https://externalsite.com/cas-server-webapp-4.0.0/login?service=<%= request.getParameter("service") %>">
<input type="hidden" name="lt" value="${loginTicket}" />
<input type="hidden" name="execution" value="${flowExecutionKey}" />
<input type="hidden" name="_eventId" value="submit" />
<input type="hidden" name="username" value="<%= request.getParameter("username") %>" />
<input type="hidden" name="password" value="<%= request.getParameter("password") %>" />
<% if ("true".equals(request.getParameter("rememberMe"))) {%>
<input type="hidden" name="rememberMe" value="true" />
<% } %>
<input type="submit" value="Submit" style="visibility: hidden;" />
</form>
</body>
And this is my external custom login page:
<form method="GET" action="https://externalsite.com/cas-server-webapp-4.0.0/">
<p>Username : <input type="text" name="username" /></p>
<p>Password : <input type="password" name="password" /></p>
<p>Remember me : <input type="checkbox" name="rememberMe" value="true" /></p>
<p><input type="submit" value="Login !" /></p>
<input type="hidden" name="auto" value="true" />
<input type="hidden" name="service" value="<%= request.getParameter("service") %>" />
</form>
Basically my external login page sends the credentials to the CAS login page and the latter is submited automatically. However, when credentials are wrong, CAS redirects to the default login page and not to my external login page.
Regards.
You need change the code at login-webflow.xml in cas-server-webapp.
The code should be changed as below:
<action-state id="handleAuthenticationFailure">
<!-- Comment FailedLoginException and AccountNotFoundException -->
<!--<transition on="FailedLoginException" to="generateLoginTicket"/>-->
<!--<transition on="AccountNotFoundException" to="generateLoginTicket"/>-->
</action-state>
Add:
<action-state id="customFailedLoginException">
<evaluate expression="generateLoginTicketAction.generate(flowRequestContext)" />
<transition on="generated" to="customFailedLoginExceptionView" />
</action-state>
<view-state id="customFailedLoginExceptionView" view="externalRedirect:#{requestParameters.service}&errorMsg=failedLogin"/>
<action-state id="customAccountNotFoundException">
<evaluate expression="generateLoginTicketAction.generate(flowRequestContext)" />
<transition on="generated" to="customAccoundNotFoundExceptionView" />
</action-state>
<view-state id="customAccoundNotFoundExceptionView" view="externalRedirect:#{requestParameters.service}&errorMsg=notFound" />
Now if you submit a user name that do not exists or a password that is wrong, your would get a response url with a parameter called 'errorMsg'.
I also make a sample about how to login cas with client custom login screen rather than server login srceen. You could download it on
https://github.com/yangminxing/cas-custom-login-page
I solved my problem by changing the transitions on the login-webflow.xml file. What I did was to create a new action state:
<action-state id="customFailedLogin">
<evaluate expression="generateLoginTicketAction.generate(flowRequestContext)" />
<transition on="generated" to="externalRedirection" />
</action-state>
and this one calls a view-state which redirects the user to my external login page
<view-state id="externalRedirection" view="externalRedirect:#{requestParameters.callingUrl}&error=true"/>
(callingUrl is a variable that I created and sent with the service url). At the end I just changed the transition in the handleAuthenticationFailure
<transition on="AccountNotFoundException" to="customFailedLogin"/>
<transition on="FailedLoginException" to="customFailedLogin"/>
Hope it helps to someone else.

Form remain the same after submiting using jquery mobile

After Im using jquery mobile to submit a form,
but after submition, and going back to form, all fields are not in default value any more. they showing data previously submitted.
(if I press f5, form will reset and works fine for another round only)
Im guessing something remain in browser cache.
Any Idea?
<!DOCTYPE html>
<html>
<head>
<script src="scripts/jquery-1.9.1.min.js"></script>
<script src="./scripts/jquery.mobile-1.3.0.js"></script>
<link rel="stylesheet" href="./style/jquery.mobile-1.3.0.min.css" />
</head>
<body>
<?php if(!(isset($_GET["submit"]))){ ?>
<form action="thisPage.PHP?submit=yes" method="get" >
<input type="text" value="0" />
<input type="submit" value="Submit" />
</form>
<?php }else{ ?>
<a href="thisPage.PHP" > FINISHED</a>
<?php } ?>
</body>
</html>
Finally I found the simple and easy answer:
add following line into form tag:
data-ajax="false"
so it should be like this:
<form action="thisPage.PHP?submit=yes" method="get" data-ajax="false" >

jsf2: form: GET method

I am trying to construct equivalent of this code in JSF2
<form action="/search.xhtml" method="get">
<div class="search">
<input type="hidden" name="mutation" value="#{facesContext.viewRoot.locale}" />
<input name="searchString" class="text" />
<input type="submit" class="searchSubmit" value="#{msg.searchIt}" />
</div>
</form>
The point of this construction is to redirect user to the search.html page, which shows the search results. The page uses URL params to decode the searchString and language mutation.
And because it uses get, it is also bookmarkable.
With JSF2 I tried to use the h:button with param for the mutation, but I dont have a clue, how to force jsf to encode the h:inputText searchString.
Thanks for your help.
As far as I know, there is no possibility to use method="GET" in JSF.
It is not what you exactly want, but may be using post-redirect-get pattern can solve your issue:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core">
<f:metadata>
<f:viewParam name="searchString" value="#{requestScopedBean.searchString}"/>
<f:viewParam name="mutation" value="#{requestScopedBean.mutation}"/>
</f:metadata>
<h:body>
<h:form>
<h:inputText value="#{requestScopedBean.searchString}"/>
<h:commandButton value="submit" action="/tests/search?faces-redirect=true&includeViewParams=true">
<f:param name="mutation" value="whatever"/>
</h:commandButton>
</h:form>
</h:body>
</html>
More about PRG pattern in JSF2 in this article: http://www.warski.org/blog/?p=185

Submit Form Equivalent To WML

I'm playing a little bit with WML with PHP, then I want to know what is the equivalent of this on WML 1.0:
<form action="upload_file.php" method="post">
<label for="file">File:</label><br />
<input type="file" name="file" id="file" /><br />
<input type="submit" name="submit" value="Submit" />
</form>
WML 1.0 is deprecated about 10 years ago, but I will answer this by looking at the spec for wml1.0 from www.wapforum.org/what/technical/wml-30-apr-98.pdf
But do note that the "file" input type isn't supported by all devices, so the chances of this actually working is quite slim.
<WML>
<CARD>
<DO TYPE="ACCEPT">
<GO URL="/upload_file.php" />
</DO>
<FIELDSET TITLE="File">
File: <INPUT TYPE="FILE" KEY="myfile"/>
</FIELDSET>
</CARD>
</WML>

Safari 3.2.1 sends POST followed by GET requests

I've a servlet running on Tomcat 5.5.27 and 5.5.26 and have a web form with POST method.
If I use Safari 3.2.1 I see from the logs that Tomcat receives a POST followed immediately/contemporarily by GET and it fails.
If I use Firefox 3.0.5 I see that it sends only POST and everything works.
Trying to debug with Eclipse I see that when using Safari it is the doGet() method that is called while when using Firefox is doPost().
Practically it seems that Safari fires both POST and then immediately GET, while Firefox fires only POST (as it should according to the HTML form).
Is there somebody else who as experienced this ? In this case is there a solution ?
Here is a snippet of the HTML form:
<form action="/vidisearch/Search" method="post" name="SearchForm" id="SearchForm">
<div class="input required">
<label for="Concepts">Concepts, comma separated<br />
ex. (remove quotes) "man-made object, cemetery, graphic event, atmospheric event, tool event"</label>
<input name="concepts" type="text" value="" id="concepts" />
</div>
<div class="input required">
<label for="Operators">Operators, comma separated<br />
ex. (remove quotes) "NOT, AND, OR, AND, AND"</label>
<input type="text" name="operators" value="" id="operators" />
</div>
<div class="input required">
<label for="Specializations">Specializations, comma separated<br />
ex. (remove quotes) "true, false, false, true, false"</label>
<input type="text" name="specializations" value="" id="specializations" />
</div>
<div class="input required">
<label for="Results">Various parameters</label>
<table width="100%" border="0" style="border: 0;">
<tr>
<td>Ontology ID<br />
<input name="ontologyID" type="text" id="ontologyID" value="" /></td>
<td>Result page<br />
<input name="page" type="text" id="page" value="0" /></td>
<td>Shots per page<br />
<input name="shotsPerPage" type="text" id="shotsPerPage" value="20" /></td>
<td>New search<br />
<input name="newSearch" type="text" id="newSearch" value="true" /></td></tr>
</table>
</div>
<div class="submit"><input type="submit" value="Search" /></div>
</form>
I think you have an image tag that has an empty src.
It's hard to say without seeing your HTML for the form, but perhaps your submit button is a wrapped with a link, and Safari is both POSTing the form and following the link (via GET).
I'm not sure what's happening but what I do know is that you need to provide more information.
Maybe it's sending a GET for associated resources (like images) whereas Firefox keeps them in the cache, or you have the form submit button inside an <a> tag, for instance.
Another alternative is a Javascript incompatibility, in case you are submitting something via Javascript.
Sniff the traffic (check out Fiddler or Wireshark) and see what is Safari trying to GET and what's it is POSTing
I'm quite puzzled by the behaviour of Safari since I remind that sometime ago it worked. I'm fearing that one of the latest upgrades has broken something.
Using HTTPScoop I've seen that apparently Safari fires POST followed by GET when it gets the response. I think however that it actually fires both requests at the same time since the date+time of the two responses is the same for both POST and GET.
The response is a RSS feed and has the HTTP/1.1 200 OK code. The second GET asks for the same request URL (http://127.0.0.1:8180/vidisearch/Search) of the POST but the body is 0 bytes, it has of course no GET parameters and the answer is wrong because of the missing parameters.
Firefox instead fires only the POST and gets the correct answer.