Solved

jsoup post login is not being redicted

Posted on 2013-06-17
16
1,560 Views
Last Modified: 2013-06-18
I am having issues trying to log using the jsoup to log in. I am not sure if this one has any cookies? Am I missing something? why can't i log in?

         import java.io.IOException;
import java.util.Map;

import org.jsoup.Connection.Method;
import org.jsoup.Connection.Response;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

public class LoginJtest {

    /**
     * @param args
     * @throws IOException 
     */
    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
        // Connect to page and parse html into a 'Document'


        //This will get you the response.
        Response res = Jsoup
            .connect("https://pslweb01.ciq.labs.att.com:8080/dis/login.jsp")
            .data("txtUserName", "myusername", "txtPassword", "mypassword")
            .method(Method.POST)
            .execute();

        //This will get you cookies
        Map<String, String> loginCookies = res.cookies();

        //And this is the easiest way I've found to remain in session
        Document doc = Jsoup.connect("https://pslweb01.ciq.labs.att.com:8080/dis/")
              .cookies(loginCookies)
              .get();
           String title = doc.title();
       System.out.println(title);


    }
}

Open in new window


This is the the source of the website for the login I am trying to access.

<div class="loginPanel">
    <div class="container">
    <div class="title">Login</div>
    <form id="loginForm" class="loginForm" method="POST" action="/dis/login">
        <font class="portlet-msg-error"
         style="font-weight: bold; font-size: 10px; color:#FF0000; text-align: center;"></font>
        <table>
        <tr>
            <td class="label">USERNAME:</td>
            <td><input
                value=""
                class="edit"
                id="txtUsernameLogin"
                name="txtUserName"
                type="text"/></td>
        </tr>
        <tr>
            <td class="label">PASSWORD:</td>
            <td><input
                value=""
                class="edit"
                name="txtPassword"
                type="password"/></td>
        </tr>
        <tr>
            <td colspan="2" align="center">
            <input type="checkbox" name="txtRemember" value="true" align="middle"/>
            Remember me on this computer
            </td>
        </tr>
        <tr>
            <td></td>
            <td class=""><input type="submit"
                    class="submit"
                    value="Login"
                    alt="Login"/></td>
        </tr>
        </table>
    </form>
    </div>
</div>

Open in new window

0
Comment
Question by:yescobar2012
  • 8
  • 8
16 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 39254300
Can't say really - those pages are unreachable at the moment
0
 

Author Comment

by:yescobar2012
ID: 39254440
Those pages I am trying to log in are only in our intranet.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39254494
OK. Can't comment i'm afraid without seeing the full page source (from which you've only posted an extract)
0
 

Author Comment

by:yescobar2012
ID: 39254557
will it help if I post the whole source code it is not alot
0
 

Author Comment

by:yescobar2012
ID: 39254564
    <?xml-stylesheet type="text/xsl" href="/dis/xslt/htmlpage.xslt"?>
    
    <page hide-loading="true">
    <title>Login</title>
    
    <head>
        <link rel="stylesheet" type="text/css" href="/dis/css/login.css"> </link>
    </head>

    <info>
        
        <current-uri><![CDATA[/dis/login.jsp?]]></current-uri>
        <application-context>/dis/</application-context>
        <application-build-version><![CDATA[DIS-2.4.1.26]]></application-build-version>
        <db-username><![CDATA[PSLDISAPP1]]></db-username>
        <db-server><![CDATA[sqpdisdb.ciq.labs.att.com]]></db-server>
        <feedback-url>mailto:Jira@carrieriq.com?subject=DIS%202%28vDIS-2.4.1.26%20-%20PSLDISAPP1%40sqpdisdb.ciq.labs.att.com%29%20%23BUG%20%23MAJOR%20%23PROJECT%3DAPPOPS%20%23REPORTER%3Dciq_support%20%23ASSIGNEE%3Dciq_support&amp;body=Current%20time%3A%2006-17-2013%2021%3A04%20Timezone%20%2B0000%0ACurrent%20user%3A%20Not logged %0ADatabase%20schema%3A%20PSLDISAPP1%0ADatabase%20server%20address%3A%20sqpdisdb.ciq.labs.att.com%0ADb.xml%20modif%20date%3A%2002-20-2012%2001%3A59%20Timezone%20%2B0000%0ADb.xml%20Version%3A%201.0.70%0APackageotadef.xml%20modif%20date%3A%2002-20-2012%2001%3A59%20Timezone%20%2B0000%0ATasking%20URL%3A%20http%3A%2F%2F192.168.29.13%3A11000%0AProfile%20Aquisition%20URL%3A%20%0AApplication%20server%3A%20pslweb01.ciq.labs.att.com%0APlarform%20server%3A%20http%3A%2F%2F192.168.29.13%3A11000%0AURL%20http%3A%2F%2Fpslweb01.ciq.labs.att.com%3A8080%2Fdis%2Flogin.jsp</feedback-url>
        <timezone><![CDATA[GMT-12:00]]></timezone>
        <server-time><![CDATA[1371459852715]]></server-time>
        
    </info>
    
    <content>

<div class="loginPanel">
    <div class="container">
        <div class="title">Login</div>
        <form id="loginForm" class="loginForm" method="POST" action="/dis/login">
            <font class="portlet-msg-error"
                 style="font-weight: bold; font-size: 10px; color:#FF0000; text-align: center;"></font>
            <table>
                <tr>
                    <td class="label">USERNAME:</td>
                    <td><input
                            value=""
                            class="edit"
                            id="txtUsernameLogin"
                            name="txtUserName"
                            type="text"/></td>
                </tr>
                <tr>
                    <td class="label">PASSWORD:</td>
                    <td><input
                            value=""
                            class="edit"
                            name="txtPassword"
                            type="password"/></td>
                </tr>
                <tr>
                    <td colspan="2" align="center">
                        <input type="checkbox" name="txtRemember" value="true" align="middle"/>
                        Remember me on this computer
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td class=""><input type="submit"
                                        class="submit"
                                        value="Login"
                                        alt="Login"/></td>
                </tr>
            </table>
        </form>
    </div>
</div>
   </content>
    </page>

Open in new window

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39254587
That's a stylesheet. It will be combined, in a transform with the content, to produce (to allow jsoup to be able to deal with it) html. You need to post the actual result, the source code of the page you see i a browser
0
 

Author Comment

by:yescobar2012
ID: 39254634
I didn't understand your previous comment? Do you want me to post the source code of the (homepage) the link after i am able to successfully log in  "https://pslweb01.ciq.labs.att.com:8080/dis/"
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39254689
No, the source of the page that contains the link
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:yescobar2012
ID: 39256287
This is the source code of the second link  "https://pslweb01.ciq.labs.att.com:8080/dis/"
	   
       <?xml-stylesheet type="text/xsl" href="/dis/xslt/listpage.xslt"?>
	    <page hide-loading="true">
	    <title>All Devices</title>
	    <info>
		    <is-authenticated>true</is-authenticated>
		    <ldap-status>true</ldap-status>
		    <username>ye831c</username>
		    <logout-url>/dis/logout</logout-url>
		    <request-uri>/dis/</request-uri>
		    <query-string></query-string>

		<current-uri><![CDATA[/dis/?]]></current-uri>
		<application-context>/dis/</application-context>
		<application-build-version><![CDATA[DIS-2.4.1.26]]></application-build-version>
		<db-username><![CDATA[PSLDISAPP1]]></db-username>
		<db-server><![CDATA[sqpdisdb.ciq.labs.att.com]]></db-server>
		<feedback-url>mailto:Jira@carrieriq.com?subject=DIS%202%28vDIS-2.4.1.26%20-%20PSLDISAPP1%40sqpdisdb.ciq.labs.att.com%29%20%23BUG%20%23MAJOR%20%23PROJECT%3DAPPOPS%20%23REPORTER%3Dciq_support%20%23ASSIGNEE%3Dciq_support&amp;body=Current%20time%3A%2006-17-2013%2023%3A36%20Timezone%20%2B0000%0ACurrent%20user%3A%20ye831c%0ADatabase%20schema%3A%20PSLDISAPP1%0ADatabase%20server%20address%3A%20sqpdisdb.ciq.labs.att.com%0ADb.xml%20modif%20date%3A%2002-20-2012%2001%3A59%20Timezone%20%2B0000%0ADb.xml%20Version%3A%201.0.70%0APackageotadef.xml%20modif%20date%3A%2002-20-2012%2001%3A59%20Timezone%20%2B0000%0ATasking%20URL%3A%20http%3A%2F%2F192.168.29.13%3A11000%0AProfile%20Aquisition%20URL%3A%20%0AApplication%20server%3A%20pslweb01.ciq.labs.att.com%0APlarform%20server%3A%20http%3A%2F%2F192.168.29.13%3A11000%0AURL%20http%3A%2F%2Fpslweb01.ciq.labs.att.com%3A8080%2Fdis%2F</feedback-url>
		<timezone><![CDATA[GMT-12:00]]></timezone>
		<server-time><![CDATA[1371469006960]]></server-time>
	    </info>
	    <menu>
	<item name="Devices" id="devices" href="devices.jsp?view=list&amp;maxlength=100" tooltip=""
		selected="true">
	<item name="All Devices" id="all" href="devices.jsp?view=list&amp;maxlength=100" tooltip="">
		selected="true">
	</item>
	<item name="Metric/Trigger Search" id="Search" href="search_filter.jsp" tooltip="">
	</item>
			<!--Menu for saved items-->
	<item name="Saved Items" id="saved" href="#" tooltip="">
	<item name="" id="saved_owner" href="" tooltip=""
		       separator="true">
				<table class="separatorTable" cellpadding="0" cellspacing="0">
				    <tr>
					<td width="100">
					    My Items
					</td>
					<td>
					    <a href="saved_items.jsp?view=owner&amp;maxlength=100" style="float: right; width: auto; height: auto; padding-right: 6px; padding-left: 6px; background-color: #6b8a57; vertical-align: middle; border: 0 none;">view all</a>
					</td>
				    </tr>
				</table>
	</item>
	<item name="" id="saved_public" href="" tooltip=""
			separator="true">
			       <table class="separatorTable" cellpadding="0" cellspacing="0">
				    <tr>
					<td width="100">
					    Public Items
					</td>
					<td>
					    <a href="saved_items.jsp?view=public&amp;maxlength=100" style="float: right; width: auto; height: auto; padding-right: 6px; padding-left: 6px; background-color: #6b8a57; vertical-align: middle; border: 0 none;">view all</a>
					</td>
				    </tr>
				</table>
	</item>
	</item>
	<item name="Reprocess Packages" id="reprocess" href="reprocess.jsp" tooltip=""
	<item name="Start New Reprocessing" id="reprocessNew" href="reprocess.jsp" tooltip="">
	</item>
	<item name="View Reprocessing History" id="reprocessHist" href="reprocess_history.jsp?maxlength=100" tooltip="">
	</item>
	</item>
	</item>
	<item name="Tasking" id="tasking" href="tasking.jsp" tooltip=""
			disabled="false">
	</item>
	<item name="Reports" id="reporting" href="metric_quality.jsp" tooltip="">
	<item name="Metric Quality" id="metricQuality" href="metric_quality.jsp" tooltip="">
	</item>
	<item name="Package Comparison" id="packageComparison" href="package_comparison.jsp" tooltip="">
	<item name="Current Comparison" id="currentComparison" href="package_comparison.jsp" tooltip="">
	</item>
	<item name="New Comparison" id="newComparison" href="javascript: if (alertSaved()) window.location='comparison?newcomp=true'" tooltip="">
	</item>
	</item>
	</item>
	<item name="References" id="references" href="references.jsp" tooltip="">
	<item name="XML Metrics" id="metrics" href="references.jsp?view=metrics" tooltip="">
	</item>
	<item name="TSN Metrics" id="tsnmetrics" href="references_tsn.jsp" tooltip="">
	</item>
	<item name="Ad-Hoc Metrics" id="adhocMetrics" href="references.jsp?view=triggers" tooltip="">
	<item name="Ad-Hoc Metric Query" id="adHocMetricSearch" href="/dis/adhocmetric_search.jsp" tooltip="">
	</item>
	<item name="Add New Ad-Hoc Metric" id="adHocMetricAddNew" href="/dis/adhocmetric.jsp" tooltip="" >
	</item>
	</item>
	<item name="Triggers" id="triggers" href="references.jsp?view=triggers" tooltip="">
	</item>
	<item name="Profiles" id="profiles" href="profiles.jsp" tooltip="">
	<item name="View All Profiles" id="profilesList" href="/dis/profiles.jsp" tooltip="" >
	 </item>           
	</item>
	</item>
		</menu>                   
		<search action="/dis/devices.jsp" value=""/>
		    <autorefresh countdown="">    
	<option value="3" >3s</option>
	 <option value="5" >5s</option>
	<option value="10" >10s</option>
	<option value="20" >20s</option>
	<option value="30" >30s</option>
	<option value="60" >1m</option>
	<option value="120" >2m</option>
	<option value="180" >3m</option>
	<option value="300" >5m</option>
	<option value="600" >10m</option>
	<option value="1800" >30m</option>
	<option value="-1" selected='true'>never</option>
		    </autorefresh>
	    <content>
		<tab id="list" displayname="List" href="/dis/devices.jsp?view=list"/>
		<tab id="timeline" displayname="Timeline" href="/dis/devices.jsp?view=timeline"/>
		<tab id="cvs" displayname="CSV" href="/dis/export/devices.jsp?view=list"/>
	<html>
	</html>
		<html>
		    <div class="commands">
		    <div class="saveSearch"><a href="/dis/tasking.jsp?devices=*">Task this list</a></div>
		    <div class="saveSearch"><a href="/dis/profile_filter.jsp">Device filtering by profile</a></div>
		    </div>
		    <div class="message" id="messageDiv">
		</div>
		</html>
		     <table show-crt="true">
	    <maxlength selected="100" uri="/dis/?">
		<option value="10">10</option>
		<option value="50">50</option>
		<option value="100" selected="selected">100</option>
		<option value="250">250</option>
		<option value="500">500</option>
		<option value="1000">1000</option>
		<option value="10000">10000</option>
		<option value="">all records</option>
		<option value="?">other...</option>
	    </maxlength>
	    <header>
		<column uri="/dis/?&amp;orderby=mdn&amp;order=asc">Directory Number</column>
		<column uri="/dis/?&amp;orderby=hardwareId&amp;order=asc">Equipment ID</column>
		<column uri="/dis/?&amp;orderby=subscriberId&amp;order=asc">Subscriber ID</column>
		<column uri="/dis/?&amp;orderby=upldTime&amp;order=asc" order="desc">Upload Time</column>
		<column uri="/dis/?&amp;orderby=sessUpldTime&amp;order=asc">Session Upload Time</column>
		<column uri="/dis/?&amp;orderby=upldRsn&amp;order=asc" align="left">Upload Reason</column>
		<column uri="/dis/?&amp;orderby=prof&amp;order=asc" align="right">Profile ID</column>
		<column></column>
		<column></column>
	    </header>
	</table>
	<rowsNumberLimited value="false"/>
	    </content>
	    </page>

Open in new window

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39256422
Nope. That, again, is a stylesheet. You need to post the html source from the browser
0
 

Author Comment

by:yescobar2012
ID: 39256584
That stylesheet was from the view source. I was able to get the HTML from the inspect code in firefox. Again this is the html from  second link  "https://pslweb01.ciq.labs.att.com:8080/dis/"  . Do you need the html from the main login screen this link -->"https://pslweb01.ciq.labs.att.com:8080/dis/login.jsp"

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title> Carrier IQ DIS 2.4 :: All Devices</title>
<script type="text/javascript" src="/dis/js/main.js">
<script type="text/javascript" src="/dis/js/validate.js">
<link rel="stylesheet" type="text/css" href="/dis/css/portal.css">
<link rel="stylesheet" type="text/css" href="/dis/css/style.css">
<script type="text/javascript">
</head>
<body onload="handleOnLoad();autorefresh('', (new Date()).getTime())">
<div class="page">
<div id="portal">
<div id="linktohome">
<a href="/dis/">
<img width="120" height="27" src="/dis/img/spacer.gif" alt="">
</a>
</div>
<ul id="loadingAnimation" style="display: none;">
<li>
<img src="/dis/img/progress-running.gif" alt="*" style="display:inline;margin:0 0 0 30px">
</li>
<li class="text">loading...</li>
</ul>
<ul class="adminlinks" style="display:inline">
<li>
<input id="hidden_server_time" type="hidden" name="hidden_server_time" value="1371522216395">
<span id="clock">2013-06-18 02:27:27</span>
<img width="5" src="/dis/img/spacer.gif" alt="">
GMT-12:00
</li>
<li>
<form id="preferencesForm" method="POST" action="/dis/preferences.jsp" style="display:none">
<input type="hidden" name="returnUri" value="/dis/?">
</form>
<a href="javascript:document.getElementById('preferencesForm').submit();void(0)"> Preferences </a>
</li>
<li>
<a href="/dis/logout">Logout</a>
<img width="5" src="/dis/img/spacer.gif" alt="">
ye831c
</li>
</ul>
<br>
</div>
<div id="header">
<div class="content">
<table width="100%" cellspacing="0" cellpadding="2" border="0">
<tbody>
<tr>
<td>
<h1>All Devices</h1>
</td>
<td align="right">
<div>
<ul class="viewtabs">
<li class="selector">View:</li>
<li>
<a href="/dis/devices.jsp?view=list">List</a>
</li>
<li>
<a href="/dis/devices.jsp?view=timeline">Timeline</a>
</li>
<li>
<a href="/dis/export/devices.jsp?view=list">CSV</a>
</li>
</ul>
</div>
</td>
<td width="90">
<div id="autorefresh">
Refresh:
<select onchange="autorefreshIn(this.options[this.selectedIndex].value);">
<option value="3">3s</option>
<option value="5">5s</option>
<option value="10">10s</option>
<option value="20">20s</option>
<option value="30">30s</option>
<option value="60">1m</option>
<option value="120">2m</option>
<option value="180">3m</option>
<option value="300">5m</option>
<option value="600">10m</option>
<option value="1800">30m</option>
<option value="-1" selected="true">never</option>
</select>
<div id="divRefreshTimeoutCase" style="visibility: hidden;">
<div id="divRefreshtimeout">
<img width="1" height="1" src="/dis/img/spacer.gif" alt="">
</div>
</div>
<form id="frmAutorefresh" method="GET" action="autorefresh">
<input id="autorefreshurl" type="hidden" name="autorefreshurl" value="/dis/?">
<input id="autorefreshtime" type="hidden" name="autorefreshtime">
</form>
</div>
</td>
</tr>
</tbody>
</table>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td valign="top" align="left">
<html>
</html>
<html>
<div class="commands">
<div class="saveSearch">
<a href="/dis/tasking.jsp?devices=*">Task this list</a>
</div>
<div class="saveSearch">
<a href="/dis/profile_filter.jsp">Device filtering by profile</a>
</div>
</div>
<div id="messageDiv" class="message"> </div>
</html>
<div class="clr"></div>
<table cellspacing="1" cellpadding="0" border="0">
<tbody>
<tr>
<td></td>
<td valign="bottom" height="18px" align="right" style="padding-right:15px;padding-left:15px;">
limit records to:
<div id="maxlengthtext" style="display: none">
<input id="maxlengthcustom" class="maxlength" type="text" name="maxlengthcustom" value="100" maxlength="8" onkeydown="enterEventMaxLength(event, '/dis/?', $('maxlengthcustom').value, '');">
<input class="gobutton" type="button" value="Go" alt="Go" onclick="switchMaxLength('/dis/?', $('maxlengthcustom').value, '');">
</div>
<div id="maxlengthselect" style="display: inline">
<select id="maxlength" class="maxlength" onchange="switchMaxLength('/dis/?', this.value, '');">
<option value="10">10</option>
<option value="50">50</option>
<option value="100" selected="selected">100</option>
<option value="250">250</option>
<option value="500">500</option>
<option value="1000">1000</option>
<option value="10000">10000</option>
<option value="">all records</option>
<option value="?">other...</option>
</select>
</div>
</td>
</tr>
<tr>
<td align="left" colspan="2">
<div class="list">
<form id="listForm" name="listForm" method="POST" action="">
<table>
<thead>
<th class="first"></th>
<th>
<a href="/dis/?&orderby=mdn&order=asc">Directory Number</a>
</th>
<th>
<a href="/dis/?&orderby=hardwareId&order=asc">Equipment ID</a>
</th>
<th>
<a href="/dis/?&orderby=subscriberId&order=asc">Subscriber ID</a>
</th>
<th class="arrow_up">
<a href="/dis/?&orderby=upldTime&order=asc">Upload Time</a>
</th>
<th>
<a href="/dis/?&orderby=sessUpldTime&order=asc">Session Upload Time</a>
</th>
<th>
<a href="/dis/?&orderby=upldRsn&order=asc">Upload Reason</a>
</th>
<th>
<a href="/dis/?&orderby=prof&order=asc">Profile ID</a>
</th>
<th>
<img width="1" height="1" src="/dis/img/spacer.gif" alt="">
</th>
<th class="last">
<img width="1" height="1" src="/dis/img/spacer.gif" alt="">
</th>
</thead>
<tbody>
<tr>
<td class="noItemsMsg" colspan="10">There are no items in the list!</td>
</tr>
</tbody>
</table>
</form>
</div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
<div class="footer">
DIS-2.4.1.26-PSLDISAPP1@sqpdisdb.ciq.labs.att.com- Copyright©2005-2011 Carrier IQ, Inc. All rights reserved.
<a class="feedback" target="_blank" href="mailto:Jira@carrieriq.com?subject=DIS%202%28vDIS-2.4.1.26%20-%20PSLDISAPP1%40sqpdisdb.ciq.labs.att.com%29%20%23BUG%20%23MAJOR%20%23PROJECT%3DAPPOPS%20%23REPORTER%3Dciq_support%20%23ASSIGNEE%3Dciq_support&body=Current%20time%3A%2006-18-2013%2014%3A23%20Timezone%20%2B0000%0ACurrent%20user%3A%20ye831c%0ADatabase%20schema%3A%20PSLDISAPP1%0ADatabase%20server%20address%3A%20sqpdisdb.ciq.labs.att.com%0ADb.xml%20modif%20date%3A%2002-20-2012%2001%3A59%20Timezone%20%2B0000%0ADb.xml%20Version%3A%201.0.70%0APackageotadef.xml%20modif%20date%3A%2002-20-2012%2001%3A59%20Timezone%20%2B0000%0ATasking%20URL%3A%20http%3A%2F%2F192.168.29.13%3A11000%0AProfile%20Aquisition%20URL%3A%20%0AApplication%20server%3A%20pslweb01.ciq.labs.att.com%0APlarform%20server%3A%20http%3A%2F%2F192.168.29.13%3A11000%0AURL%20http%3A%2F%2Fpslweb01.ciq.labs.att.com%3A8080%2Fdis%2F">feedback</a>
</div>
</div>
</body>
</html>

Open in new window

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39256841
<script type="text/javascript" src="/dis/js/main.js">
<script type="text/javascript" src="/dis/js/validate.js">

Open in new window

At least one of those could well be involved in authentication, and by extension, redirection. Ask yourself what JSoup is going to be able to do about that. A clue: i've already covered this in your previous questions
0
 

Author Comment

by:yescobar2012
ID: 39256971
so Jsoup won't be able to work because it can't do javascript?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39257037
To answer that, you need to first test this hypothesis by examining the javascript
At least one of those could well be involved in authentication, and by extension, redirection
0
 

Author Comment

by:yescobar2012
ID: 39257082
I am not sure what to look for in the javascript for the authentication
/dis/js/main.js
function $(obj)
{
    return document.getElementById(obj);
}

function DisPage(params) {
    this.loadingSection = params.loadingSection;
    this.currentSection = params.currentSection; 
}

DisPage.prototype.init = function init()
{
    startClock();
    if($('TASK_HIST_ID'))
    {
        setTimeout('stateRefresh()',10000);
    }
    if($('hiddenPid'))
    {
        setTimeout('refreshReprocessingStatus()', 1);
    }
    if($('hiddenHistory'))
    {
        setTimeout('refreshReprocessingHistory()', 1);
    }
}

DisPage.prototype.showLoading = function() {
    this.loadingSection.style.display = "";
}

DisPage.prototype.hideLoading = function() {
    this.loadingSection.style.display = "none";
}

function view_metric_log()
{
    var selectedItems = getSelectedItemString(";");
    if (selectedItems != "")
    {
        if (selectedItems.length < 700)
        {
            window.location = "metriclog.jsp?PKG_GID=" + escape(selectedItems) + "&view=list";
        }
        else
        {
            try
            {
                if (enableExtendedMetricLog)
                {
                    if (confirm("You've selected a large number of packages.\nThis request will probably take a long time.\nWould you like to continue?"))
                    {
                        $('PKG_GID').value = selectedItems;
                        $('lotsOfPackages').submit();
                    }
                }
            }
            catch (e)
            {
                alert("Please select a lower number of packages!");
            }
        }
    }
    else
    {
        alert("Please select at least one package ..");
    }

}

function getSelectedItemString(separator)
{
    var items = "";
    var elems = document.getElementById("listForm").elements;
    for (var i = 0; i < elems.length; i++)
    {
        var obj = elems[i];
        if (obj != null)
        {
            //only checkboxes
            if (obj.type == "checkbox" && obj.id != "selectPkgsAllCheckBox" &&
                obj.id != "selectGroupsAllCheckBox" && obj.id != "selectPublicProfilesAllCheckBox" &&
                obj.id != "selectDevicesAllCheckBox" && obj.id != "selectProfilesAllCheckBox")
            {
                if (obj.checked)
                {
                    if (items != "") items = items + separator;
                    items = items + obj.value;
                }
            }
        }
    }
    return items;
}

function validate(myfield, e, dec)
{
    var key;
    if (window.event)
        key = window.event.keyCode;
    else if (e)
        key = e.which;
    else
        return true;

    var keychar = String.fromCharCode(key);

    return (('0123456789*?,').indexOf(keychar) > -1);
}

function switchMaxLength(uri, maxLength, prefix)
{
    if(maxLength>=2000 && !confirm("Warning! You haved selected to display "+ maxLength+" records, this will take a long time. Do you want to continue ?"))
    {
        return;
    }
    maxLength=trim(maxLength);
    if(maxLength== "" && !confirm("Warning! You haved selected to display all records, this may take a long time. Do you want to continue ?"))
    {
        return;
    }

        if (maxLength == "?")
        {
            $(prefix + "maxlengthselect").style.display = "none";
            $(prefix + "maxlengthtext").style.display = "inline";
            $(prefix + "maxlengthcustom").focus();
        }
        else
        {
            if (maxLength!="" && (!isFiguresOnly(maxLength) || (maxLength-0)<1))
            {
                alert("Please enter a valid value for record limit");
                return;
            }
            window.location = uri + "&maxlength=" + maxLength;
        }

}

function enterEventMaxLength(event, uri, value, prefix)
{
    if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13))
    {
        switchMaxLength(uri, value, prefix);
    }
    else
    {
        return true;
    }
}

function isFiguresOnly(str)
{
    for(i=0; i<str.length; i++)
    {
        if (('0123456789').indexOf(str.substr(i,1)) == -1)
        {
            return false;
        }
    }
    return true;
}

function filterByTrigger(frm, uri)
{
    var filter = "";
    for (i = 0; i < frm.elements.length; i++)
    {
        var obj = frm.elements[i];
        if (obj.type == "checkbox")
        {
            if (obj.checked)
            {
                filter = filter + (filter == "" ? "" : ",") + obj.value;
            }
        }
    }
    window.location = uri + "&triggerfilter=" + escape(filter);
}
var onDiv = 0;
function mouseOnDiv()
{
    onDiv = 1;
}
function mouseNotOnDiv()
{
    onDiv = 0;
    setTimeout("hideMenu()", 750);
}

var ddsToUnhide = new Array();

function isIE()
{
    return typeof(document.all) != "undefined";
}

function isIE7()
{
    try
    {
        return navigator.appVersion.indexOf("MSIE 7") > -1;
    }
    catch(ex)
    {
        return false;
    }
}

function showMenu(menuId) {
    if (isIE() && !isIE7() && typeof(page) == "object" && typeof(page.currentSection) == "string" && page.currentSection == "tasking")
    {
        var dds = document.getElementsByTagName("SELECT");
        for (var i = 0; i < dds.length; i++)
        {
            if (typeof(dds[i].style) != "undefined" && dds[i].style.visibility != "hidden")
            {
                dds[i].style.visibility = "hidden";
                ddsToUnhide[ddsToUnhide.length] = dds[i];
            }
        }
    }
    document.getElementById(menuId).style.display='';
}
function hideMenu()
{
    if (onDiv == 0)
    {
        for (var i = 0; i < 15; i++)
        {
            if ($('ueexpmenu' + i))
            {
                $('ueexpmenu' + i).style.display = 'none';
            }
        }
        if (isIE() && !isIE7() && typeof(page) == "object" && typeof(page.currentSection) == "string" && page.currentSection == "tasking" && ddsToUnhide.length > 0)
        {
            for (var i = 0; i < ddsToUnhide.length; i++)
            {
                if (typeof(ddsToUnhide[i].style) != "undefined" && ddsToUnhide[i].style.visibility == "hidden")
                {
                    ddsToUnhide[i].style.visibility = "visible";
                }
            }
        }
        ddsToUnhide.length = 0;
    }
}

function hideSearchDiv()
{
    $('searchDiv').style.display = 'none';
}

function showCopyUrl(currentURI)
{
    if ($("url_combobox").value != 'select')
    {
        $("url_edit_text").href = ($("url_combobox").value + currentURI).replace('&amp;','&');
        $("url_edit_text").innerHTML = $("url_combobox").value + currentURI;
        $("text_select").style.display = 'inline';
        copy_clip($("url_edit_text").href);    
    }
    else
    {
        $("text_select").style.display = 'none';
    }
}

function copy_clip(meintext)
{
    if (window.clipboardData)
    {

        // the IE-manier
        window.clipboardData.setData("Text", meintext);
    }
    else if (window.netscape)
    {

        netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

        var clip = Components.classes['@mozilla.org/widget/clipboard;1']
                .createInstance(Components.interfaces.nsIClipboard);
        if (!clip) return;

        var trans = Components.classes['@mozilla.org/widget/transferable;1']
                .createInstance(Components.interfaces.nsITransferable);
        if (!trans) return;
        trans.addDataFlavor('text/unicode');

        var str = new Object();
        var len = new Object();

        var str = Components.classes["@mozilla.org/supports-string;1"]
                .createInstance(Components.interfaces.nsISupportsString);

        var copytext = meintext;

        str.data = copytext;

        trans.setTransferData("text/unicode", str, copytext.length * 2);

        var clipid = Components.interfaces.nsIClipboard;

        if (!clip) return false;

        clip.setData(trans, null, clipid.kGlobalClipboard);

    }
    return false;
}

function validPrefs()
{
    if ($('maxLength').value.match('^[1-9][0-9]*$'))
    {
        return true;
    }
    else
    {
        alert("Please enter a valid MAX LENGTH value.");
        return false;
    }
}

function trim(str)
{
    return str.replace(/^\s*|\s*$/g, "");
}
function saveSearch()
{
    if (trim($('searchNameText').value) != '')
    {
        $('frmSaveSearch').submit();
    }
    else
    {
        alert('Please provide a name for this search.');
    }
}
function renameSearch()
{
    $('deleteSearch').style.display = 'none';
    $('frmEditSearch').style.display = 'inline';
    $('txtSearchRename').focus();
}

var time;

function startClock()
{
    time = new Date().getTime();
    updateClock();
}

function updateClock()
{
    if (!$('hidden_server_time')) {
        return;
    }
    var serverTime = $('hidden_server_time').value - 0;
    var date = new Date(new Date().getTime() - time + serverTime
            + new Date().getTimezoneOffset() * 60000);

    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    if (month < 10) month = "0" + month;
    var day = date.getDate();
    if (day < 10) day = "0" + day;
    var hours = date.getHours();
    if (hours < 10) hours = "0" + hours;
    var minutes = date.getMinutes();
    if (minutes < 10) minutes = "0" + minutes;
    var seconds = date.getSeconds();
    if (seconds < 10) seconds = "0" + seconds;

    document.getElementById("clock").innerHTML = ""
            + year + "-" + month + "-" + day
            + " " + hours + ":" + minutes + ":" + seconds;

    setTimeout("updateClock()", 1000);
}

function goToMetricDict(metricName)
{
    window.location = "/dis/referencesDispatcher?metricXID=" + metricName;
}
function goToMetLogTimeline(date)
{
    var strHref = window.location.href;
    var replaced;
    if(strHref.indexOf('view=list')==-1)
    {
        replaced = strHref + "&view=timeline"
    }
    else
    {
        replaced = strHref.replace("=list", "=timeline");
    }
    replaced = replaced + "&date=" + date.replace(/:|-|\./g, "").replace(/\s/, "T");
    window.location = replaced;
}
function metricLogTimeline(mlTimeline)
{
    var timelineDate = $('mlFirstMetTime').value.replace(/:|-|\./g,"").replace(/\s/,"T");
    if(trim(timelineDate)!="")
    {
        window.location = mlTimeline+"&date="+timelineDate.replace(/:|-|\./g,"").replace(/\s/,"T");
    }
    else
    {
        window.location = mlTimeline;
    }
}
function stateRefresh()
{
    TaskingStateLogic.getMdnStatesForAjax(stateTableRefresh,document.getElementById('TASK_HIST_ID').value,document.getElementById('TIMEZONE_ID').value);
}
function stateTableRefresh(map)
{
    var cells = $("TASKING_STATES_TABLE").getElementsByTagName("div");
    for(var j=0;j<cells.length;j++)
    {
        if(cells[j].id!='')
        {
            //states
            if(cells[j].id.indexOf("_##_") > -1)
            {
                if(map[cells[j].id] == -1)
                {
                    cells[j].className='notAvailableState';
                }
                else if (map[cells[j].id] == 0)
                {
                    cells[j].className='failState';
                }
                else if (map[cells[j].id] == 1)
                {
                    cells[j].className='successState';
                }
                else
                {
                    cells[j].className="";
                }
            }
            else
            {
                if (map[cells[j].id] == null || map[cells[j].id] == undefined || map[cells[j].id] == '')
                {
                    cells[j].innerHTML = 'none';
                    cells[j].className = 'emptyStateCell';
                }
                else
                {
                    cells[j].innerHTML = map[cells[j].id];
                    cells[j].className = "";
                }
            }
        }
    }
    setTimeout("stateRefresh()", 3000);
}

function autorefreshIn(seconds) {
    $("autorefreshtime").value=seconds;
    $("frmAutorefresh").submit();
}

function autorefresh(countdown, start) {
    if (countdown=="" || countdown=="-1")
    {
        if ($("divRefreshTimeoutCase"))
        {
            $("divRefreshTimeoutCase").style.visibility="hidden";
        }
    }
    else
    {
        var countdownmillis=countdown*1000;
        var passed=((new Date()).getTime()-start);
        if (passed>=countdownmillis)
        {
            $("divRefreshtimeout").style.width="0";
            window.location.reload(true);
        }
        else
        {
            $("divRefreshtimeout").style.width=100*((countdownmillis-passed)/(countdownmillis)) + "%";
            setTimeout('autorefresh(' + countdown + "," + start + ");", 1000);
        }
    }
}

function normalizeDevicesList(str, sep) {
    var rslt = "", lastIsSep = true;
    for (var i = 0; i < str.length; i++)
    {
        var c = str.charAt(i);
        //permit XML chars in device validation
        if (c.match(/^[0-9A-Za-z\*\?!\/\+;<>&"']{1,1}$/))
        {
            rslt += c;
            lastIsSep = false;
        }
        else if (c.match(/^[\\n,\s]{1,1}$/))
        {
            if (!lastIsSep) {
                rslt += sep ? sep : "\n";
            }
            lastIsSep = true;
        }
    }
    return rslt;
}

function filterMetrics(frmMetricFilter, urlWithoutFilter)
{
    var filter = "";
    for (i = 0; i < frmMetricFilter.elements.length; i++)
    {
        var obj = frmMetricFilter.elements[i];
        if (obj.type == "checkbox")
        {
            if (obj.checked)
            {
                filter = filter + (filter == "" ? "" : ",") + obj.value;
            }
        }
    }
    window.location = urlWithoutFilter + "&filter=" + escape(filter);
}

function displayMetricDiv(divCollapsed, divExpanded, header)
{
    // only on IE
    if (document.all)
    {
        $('MetricLogMultiplePanel').style.right = "";
    }
    if ($(divCollapsed).style.display != "none")
    {
        $(divCollapsed).style.display = "none";
        $(divExpanded).style.display = "inline";
        $(header).className = "panelOpen";
    }
    else
    {
        $(divCollapsed).style.display = "inline";
        $(divExpanded).style.display = "none";
        $(header).className = "panelClosed";
    }
    // only on IE
    if (document.all)
    {
        $('MetricLogMultiplePanel').style.left = (document.documentElement.clientWidth - $('MetricLogMultiplePanel').offsetWidth) + "px";
    }
}

/* used to display the calendar above the timeline */
var calendarLoaded = false;

function displayCalendar()
{
    if (calendarLoaded)
    {
        return;
    }
    Calendar.setup({
        inputField     :    "startDate1",   // id of the input field
        ifFormat       :    "%m.%d.%Y",       // format of the input field
        showsTime      :    false,
        onUpdate       :    catcalc
    });
    Calendar.setup({
        inputField     :    "startDate2",   // id of the input field
        ifFormat       :    "%m.%d.%Y",       // format of the input field
        showsTime      :    false,
        onUpdate       :    catcalc
    });
    calendarLoaded = true;
}

/* used to redisplay the timeline with the value of the start time */
function addInitialTimeToUrl(url, control)
{
    var initialDate;
    if (control == 2)
    {
        initialDate = document.getElementById('startDate2').value;
    }
    else
    {
        initialDate = document.getElementById('startDate1').value;
    }
    var dateElements = initialDate.split('.');
    var newUrl = url + "&date="
    newUrl += dateElements[2] + dateElements[0] + dateElements[1] + 'T';
    var initialTime;
    if (control == 2)
    {
        initialTime = document.getElementById('startTime2').value;
    }
    else
    {
        initialTime = document.getElementById('startTime1').value;
    }
    var timeElements = initialTime.split(':');
    newUrl += timeElements[0] + timeElements[1] + "00" + "000";
    window.location = newUrl;
}


var onCompMenu=false;

function showCompMenu()
{
    $("compMenu").style.display="inline";
    onCompMenu=true;
}

function enterCompMenu()
{
    onCompMenu=true;
}

function exitCompMenu()
{
    onCompMenu=false;
    setTimeout("hideCompMenu()", 1000);
}

function hideCompMenu()
{
    if (!onCompMenu)
    {
        $("compMenu").style.display="none";
    }
}

function alertSaved()
{
    return confirm ("The current comparison is not saved. Would you like to ignore the changes?");
}

function addPackagesToColumn(colIndex, createNewComp)
{
    //get packages to add
    var separator=";";
    var elems = document.getElementById("listForm").elements;
    var items="";
    var pkgGid, mdn, previousMdn;

    previousMdn = "";

    if ((createNewComp != undefined ) && (!createNewComp))
    {
        if ((colIndex > 0) && $("hidMdn" + colIndex))
        {
            previousMdn = $("hidMdn" + colIndex).value;
        }
    }

    for (var i = 0; i < elems.length; i++)
    {
        var obj = elems[i];
        if (obj != null)
        {
            //only checkboxes
            if (obj.type == "checkbox" && obj.id != "selectPkgsAllCheckBox")
            {
                if (obj.checked)
                {
                    if (items != "") items = items + separator;
                    pkgGid = obj.value;
                    if ($("mdn_" + pkgGid))
                    {
                        mdn = $("mdn_" + pkgGid).value;
                        if (mdn != "")
                        {
                            if ((previousMdn != "") && (mdn != previousMdn))
                            {
                                alert("Please note you cannot add packages from different Devices to the same column. Unselect some of the packages and retry.");
                                return;
                            }
                            previousMdn = mdn;
                        }
                    }
                    items = items + obj.value;
                }
            }
        }
    }
    if ((createNewComp != undefined ) && (!createNewComp))
    {
        $("hidMdn" + colIndex).value = previousMdn;
    }
    if (items!="")
    {
        $("hidId").value=items;
        if (createNewComp)
        {
            $("hidAction").value="columnAddPackageNewComp";
            $("packageCompFrm").submit();
        }
        else
        {
            $("hidAction").value="columnAddPackage";
            $("hidOffset").value=colIndex-1;
            $("packageCompFrm").submit();
        }
    }
    else
    {
        alert("No package was selected.");
    }
}

function createComparisonByMDN()
{
    var separator=";";
    var elems = document.getElementById("listForm").elements;
    var items="";
    var pkgGid, mdn;
    for (var i = 0; i < elems.length; i++)
    {
        var obj = elems[i];
        if (obj != null)
        {
            //only checkboxes
            if (obj.type == "checkbox" && obj.id != "selectPkgsAllCheckBox")
            {
                if (obj.checked)
                {
                    if (items != "") items = items + separator;
                    pkgGid=obj.value;
                    if ($("mdn_" + pkgGid))
                    {
                        mdn=$("mdn_" + pkgGid).value;
                        items = items + pkgGid + "|" + mdn;
                    }
                }
            }
        }
    }

    if (items!="")
    {
        $("hidAction").value="columnAddPackageByMDN";
        $("hidId").value=items;
        $("packageCompFrm").submit();        
    }
    else
    {
        alert("No package was selected.");
    }
}

function createNewComparison()
{
    addPackagesToColumn(1, true);
}

/* Function used to show the mac users alert div in training page in case the OS is MacOS or is Safari browser*/
function macUsersAlertVisibility(macDivId)
{
    var macDiv = document.getElementById(macDivId);

    // check if we have MacOS or Safari browser
    if ( (navigator.platform.indexOf("Mac") != -1) || (navigator.userAgent.toLowerCase().indexOf("safari") != -1))
    {
        macDiv.style.display = "block";
    }
    else
    {
        macDiv.style.display = "none";
    }
}

Open in new window


/dis/js/validate.js

function FormValidator(form, validations)
{
    this.form = form;
    this.validations = validations;
}

FormValidator.prototype.validate = function(stopOnError)
{
    var result = true;
    for (var fieldName in this.validations)
    {
        var field = eval("this.form." + fieldName) || this.form.elements[fieldName] || document.getElementById(fieldName);
        if (!field) {
            continue;
        }
        var validationDescs = this.validations[fieldName];
        var fieldValidationResult = true;
        for (var index in validationDescs)
        {
            var validation = validationDescs[index];
            try
            {
                //IE7 makes a default xml encoding, need to replace back: < > &
                if (validation.regExp != null)
                {
                    validation.regExp = new RegExp(validation.regExp.source
                            .replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&amp;/g, '&'));
                }
                if (!eval("this." + validation.type + "(field, validation)"))
                {
                    validation["errorAction"](field, validation);
                    try
                    {
                        field.focus();
                    }
                    catch(ex)
                    {
                    }
                    if (stopOnError)
                    {
                        return false;
                    }
                    else
                    {
                        fieldValidationResult = false;
                        break;
                    }
                }
            }
            catch(ex)
            {
            }
        }
        result = result && fieldValidationResult;
    }
    return result;
}

FormValidator.prototype.required = function(field, validation)
{
    return "" != field.value;
}

FormValidator.prototype.mask = function(field, validation)
{
    return field.value.match(validation.regExp);
}

FormValidator.prototype.numberBetween = function(field, validation)
{
    try
    {
        with (field)
        {
            var result = true;
            if (typeof validation["low"] != "undefined")
            {
                result = result && validation["low"] <= value;
            }
            if (typeof validation["high"] != "undefined")
            {
                result = result && validation["high"] >= value;
            }
            return result;
        }
    }
    catch(ex)
    {
        return false;
    }
}

FormValidator.prototype.lengthRange = function(field, validation)
{
    try
    {
        with (field)
        {
            var result = true;
            if (typeof validation["low"] != "undefined")
            {
                result = result && validation["low"] <= value.length;
            }
            if (typeof validation["high"] != "undefined")
            {
                result = result && validation["high"] >= value.length;
            }
            return result;
        }
    }
    catch(ex)
    {
        return false;
    }
}

Open in new window

0
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 39257104
Well you'd need to run that past someone in the Javascript TA  but my guess is that proper form submission depends on Javascript. Since JSoup (afaik) does not support Javascript, it probably won't work.

I've already told you what to use, but for some reason, you seem to be determined to ingore that advice
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
array11 challenge 16 51
countHi2 challenge 7 44
maven java path setting 5 50
topping2 challenge 13 59
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now