Tuesday, June 30, 2009

Javascript form autosubmit

Autosubmit form with Javascript. Place


onload="document.forms[0].submit()"


in your form's body tag then something like




/>
/>




POST with HttpClient

An alternative way to do Http POST using Jakarta-HttpClient


PostMethod post = new PostMethod("http://jakarata.apache.org/");
NameValuePair[] data = {
new NameValuePair("user", "joe"),
new NameValuePair("password", "bloggs")
};
post.setRequestBody(data);
// execute method and handle any error responses.
...
InputStream in = post.getResponseBodyAsStream();
// handle response.

Monday, June 29, 2009

Shibboleth UsernamePassword login handler

We recently switched our IdP installation from using RemoteUser login handler to the UsernamePassword handler for authentication. The UsernamePassword handler uses jaas for authentication. We're attempting to customize the default login.jsp page used by the Shibboleth IdP to our own page, this is done by recompiling the IdP with a web.xml file pointing to the new login page


UsernamePasswordAuthHandler
edu.internet2.middleware.shibboleth.idp.authn.provider.UsernamePasswordLoginServlet

loginPage
specialPages/login.jsp


Tuesday, June 23, 2009

Java HTTP POST Request

    public void doPost() throws Exception {
try {
// Construct data
String data = URLEncoder.encode("j_username", "UTF-8") + "=" + URLEncoder.encode("test", "UTF-8");
data += "&" + URLEncoder.encode("j_password", "UTF-8") + "=" + URLEncoder.encode("test", "UTF-8");

// Send data
URL url = new URL("/specialpages/script.jsp");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();

//// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
wr.close();
rd.close();
} catch (Exception e) {
}

}

Monday, June 22, 2009

test

test