JSoup posting login data - html-parsing

I am attempting to use JSoup for parsing HTML, logging into an account and then parsing additional HTML.
There are several tests I have performed on simple HTML, but I picked a website written in JSP that I have an account on, but I am not having any luck attempting to log into the site..
From the HTML, I have the following fields as part of the input:
input id="loginPopup" type="text" size="25" value="" name="/atg/userprofiling/ProfileFormHandler.value.login" maxlength="46"
input type="hidden" value=" " name="_D:/atg/userprofiling/ProfileFormHandler.value.login"
and
input id="passwordPopup" maxlength="25" name="/atg/userprofiling/ProfileFormHandler.value.password" value="" type="password" autocomplete="off" size="25"
input name="_D:/atg/userprofiling/ProfileFormHandler.value.password" value=" " type="hidden"
After retrieving the HTML, I am executing the following:
doc = Jsoup.connect(MAIN_URL)
.data("/atg/userprofiling/ProfileFormHandler.value.login", "xxxxxx#yahoo.com")
.data("/atg/userprofiling/ProfileFormHandler.value.password", "<password>");
.post();
..actually, I have tried several combinations, but am having no success.. I end up getting the "wrong userid/password" screen...
I have also used JSoup to ensure I have the proper name value by:
Element input = doc.getElementById("loginPopup");
String inputName = input.attr("name");
I have been looking for other JSoup examples, and thought maybe someone here might have some insight...
I will be redirected to a secured (HTTPS) page, but I don't think that is the issue. I am assuming it something to do with the strange "name" values of the HTML inputs..?
Thanks

Use a chrome extension called POSTMAN to try simulate the login, Oracle ATG usually needs more fields to login than just Login and Password, open chrome Developer Tools and check the Network while doing a real login to the site, then you will be able to see all the paramenters needed to simulate the login from code.
[]s

Related

Error input type when using webview to make IOS application

I have a ruby on rails website which is designed mobile's view. In this web, I have 2 input: email and zip code which is define input[type=email] and input[type=tel] respectively. I checked this view in Safari browser and 2 above inputs work correctly - it mean the keyboard display # in email field and numeric keyboard in zip code field. I used this website (or webview exactly) to make IOS webview application, however 2 above inputs is still input[type=text] and the keyboard only display text keyboard. This is html my code:
- email field:
<input type="email" name="user_email" id="user_mail" maxlength="300" size="30" >
zip code field:
<input type="tel" name="zip_code" id="zip_code" maxlength="8" size="10" placeholder="1050001" >
What are reasons and solution of this issue? Please help me. Thank you.
For iOS webview to display numeric only, you have to have pattern="[0-9]*" at the zip code field.
<input type="tel" name="zip_code" pattern="[0-9]*" id="zip_code" maxlength="8" size="10" placeholder="1050001">
Reference: iPhone / iOS : Presenting HTML 5 Keyboard for Postal Codes

MODX Revolution and Formit plugin: not sending mail attachments

Using MODX Revolution and Formit, I try to attach a file to a contact form. The mail is sent but without the attachment. For some strange reason, I can also no longer find any information on the attachments hook. Has that feature been removed from Formit recently?
[[!FormIt?
&hooks=`spam,email,attachments,redirect`
&emailTpl=`sometemplate`
&emailTo=`foo#foo.com`
&emailBCC=`foo2#foo.com`
&emailSubject=`some subject`
&redirectTo=`123`
&validate=`name:required, filedata:required`
]]
<form action="[[~[[*id]]]]" method="post" class="form" enctype="multipart/form-data">
<input type="text" name="name" id="name" value="[[!+fi.name]]">
<input id="filedata" name="filedata" type="file" value="[[+fi.filedata]]">
<button type="submit">SEND</button>
</form>
Again, mail is sent (I tried many different email adresses) but the attachment is always missing. What's wrong?
Did you try https://modx.com/extras/package/ajaxupload2 extra?
From description:
With two FormIt hooks the upload queue could be pre filled from a FormIt field
value and be saved into a FormIt field value. With a third FormIt hook the
uploaded files could be attached to the FormIt mails.
Just leave the hook 'attachements' away, formit handles a file input without that hook.

Error on first login attempt - Spring Security (With Grails)

I'm creating an app using Grails 3 and SpringSecurity Core, as of now there is only a custom login page (named auth.gsp so that it can overwrite the default spring security auth.gsp, it does not have the Remember-me option), a index page with the message "Welcome" and a logout button, and some domain classes (the SpringSecurity User, Role and UserRole, beside some other classes that does nothing right now).
Every time I run the app after restarting the computer, on the first login attempt I'm redirected to a error (http://localhost:8080/error) such as this one:
Whitelabel Error PageThis application has no explicit mapping for /error, so you are seeing this as a fallback.Wed Apr 27 14:58:55 GMT-03:00 2016There was an unexpected error (type=None, status=999).No message available
If I erase the "/error" and go to the URL http://localhost:8080/ it works fine (it shows me the Welcome page), and if I logout and try to login again it does not show the error page (even if I run stop-app and run it again, the error page will not show anymore, I have to restart the computer for it to show again).
Anyone has any idea why is this happening? There is absolutly nothing running besides SpringSecurity, the custom auto.gsp and the auto generated domain classes. Is it an issue with the plugin?
The auth.gsp form is as follow:
<form action="${postUrl ?: '/login/authenticate'}" method="POST" class="login-form">
<input class="form-control"
name="${usernameParameter ?: 'username'}" placeholder="User" type="text"/>
<input class="form-control" name="${passwordParameter ?: 'password'}"
placeholder="Password" type="password"/>
<button class="btn ing-btn-primary login-btn-confirm" type="submit">
Login
</button>
</form>

ASP.NET MVC date string slash being converted to dash in Safari input fields

I am outputting a DateTime to a string format of MM/dd/yyyy to an text input field. This works fine on all browsers except latest version of Safari (on Yosemite, if that matters). See examples below:
This code:
<div><input type="text" value='#Model.Arrival.Value.ToString("MM/dd/yyyy")' /></div>
<div><input type="text" value="#Html.Raw(Model.ArrivalDateString)" /></div>
<div><input type="text" value="8/23/2015" /></div>
<div><input type="text" value="08/23/2015" /></div>
Produces this:
The test page I setup for this has absolutely nothing else running on it. It's just a bare bones HTML page with server side output from a view model. MVC 5 and .net framework 4.5.1
Viewing page source, it looks like this in Safari:
<input type="text" value="08-20-2015" />
On other browsers, it is this:
<input type="text" value="08/20/2015" />
UPDATE: It looks like .NET is choosing a different culture / format for Safari browsers. A possible fix is to specify a format provider.
I was able to fix the issue by specifying a culture for the string format. ie.:
DateTime arrival = DateTime.Now;
CultureInfo invariant = CultureInfo.InvariantCulture;
string dateString = arrival.ToString("MM/dd/yyyy", invariant);
en-US works as well. Still not sure why this happens. It looks like ASP.NET is doing something different based on the user agent. The request headers otherwise looks like same.
I would've figured this out earlier if I was able to get browserstack to work locally.

Syntax error with parseJSON during unobtrusive validation

My MVC app is generating the following HTML which causes a Javascript syntax error upon submission (I'm not typing anything into the two text boxes). Here's the generated HTML and the submit handler:
<form action="/UrIntake/Save" id="UrIntakeForm" method="post">
<input data-val="true" data-val-length="The field LastName must be a string with a maximum length of 50." data-val-length-max="50" data-val-required="The LastName field is required." id="FormSubmitter_LastName" name="FormSubmitter.LastName" type="text" value="" />
<input data-val="true" data-val-length="The field FirstName must be a string with a maximum length of 50." data-val-length-max="50" data-val-required="The FirstName field is required." id="FormSubmitter_FirstName" name="FormSubmitter.FirstName" type="text" value="" />
<div id="SubmissionButtons" class="right">
<input type="button" onclick="SubmitForm()" value="Submit" />
<input type="button" onclick="CancelForm()" value="Cancel" />
</div>
</form>
function SubmitForm() {
$("#UrIntakeForm").valid();
.
.
.
This is the jQuery code where the syntax error is occurring (v1.9.0). "data" is undefined and the "return" line is where the error occurs:
parseJSON: function( data ) {
// Attempt to parse using the native JSON parser first
if ( window.JSON && window.JSON.parse ) {
return window.JSON.parse( data );
}
Presumably, I don't have to enter anything into the text boxes (and should then get the "field is required" message). Is this what's causing the error? That doesn't make sense, but I don't see what else it could be.
Cause
This is an issue with jquery.validate.unobtrusive.js in your ASP.NET.MVC package.
As of jQuery 1.9, the behavior of parseJSON() has changed and an undefined value would be considered a malformed JSON, resulting in the error you've specified. See the jQuery 1.9 Core Upgrade Guide for more information.
Solution
Use the jQuery Migrate plugin, which among other things adds backward-compatibility to the jQuery parseJSON() utility.
EDIT
According to the official announcement in this thread on Microsoft Connect, the issue has been resolved in the latest release of the framework.
Naturally, as Andreas Larsen noted in the comments, make sure to clear any relevant cache, server-side and client-side, after upgrading to the new release.
I also had this issue. The problem was that $.parseJSON(undefined) causes an exception to be thrown, and that the unobtrusive validation was making that call. As stated in the accepted answer, this has since been fixed.
You can download the Microsoft version of this script which will properly validate without causing an exception from this link: http://ajax.aspnetcdn.com/ajax/mvc/5.1/jquery.validate.unobtrusive.min.js

Resources