Hemal Mahagederawatte

Greenhorn
+ Follow
since Dec 17, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
3
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Hemal Mahagederawatte

I tried the following code



But it returns the index page not the page that should be get if it is successfully authenticated.

In the example that is in the http://www.exampledepot.com/egs/java.net/Post.html it uses http. In my scenario it is a https connection. Does some additional thing to be done when you are posting to a https connection.
9 years ago
Finally after spending hours I found the answer.

I was using httpcore-4.0beta jar.

I replaced it with httpcore-4.1.jar and now it works fine
When i the following code as it is in http://hc.apache.org/httpcomponents-client-ga/tutorial/html/fundamentals.html#d4e37 tutorial. I get the following exception when i run the following code.



The exception I get is follow.

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.http.protocol.BasicHttpContext: method <init>()V not found
at org.apache.http.impl.client.DefaultHttpClient.createHttpContext(DefaultHttpClient.java:205)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:532)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
at httpclient.Main.main(Main.java:31)
Java Result: 1



Can somebody help me please.
Thanks in advanced.

Ops.. I forgot to edit it. Thank you.

Well my requirement is like this,

create a java class which can send openid and the password off the user along with a authnRequest message and this java class must get the authnResponse message (which has the openid token) from the openid provider in return. Then this token is wrapped and send to a STS.
Hi everybody,

I want to send username and password to www.myopenid.com and get authenticated response.
The authentication page is at https://www.myopenid.com/signin_password which has the following form



So i wrote the following code



But i don't get authenticated. ( The return is the html page https://www.myopenid.com/ with link to sign in and not the page you get if you had sign in).

Can anybody help me please.
Thanks in advanced.
I'm really sorry, I'm new to java.

I though it's not possible to directly send request to the https://www.myopenid.com/signin_submit. Because if you do it in the browser it will give the following message

Error
You have followed a bad link. Please inform the owners of the site from which you came.


Any way can you give me any suggestion on how to authenticate.

Thanks in advanced.
9 years ago
I said i don't get authenticated because after I run my code and went to the https://www.myopenid.com/signin_password it asks for my username and password. If I was successfully authenticated when i run my code it shouldn't be asking like that. Isn't it?

Well when i run the above code i get the reply as this . which is the html of the https://www.myopenid.com/signin_password




Date
Sat, 29 Jan 2011 19:26:30 GMT
Server
Apache/2.2
Content-Length
9227
Content-Type
text/html; charset=UTF-8
Set-Cookie
ephemeral_session_id=fe90fa60478e0107616ac9fe48a803b0784c44e4319cc61a6af3b06f8c4bc6e9; domain=myopenid.com; path=/
Set-Cookie
browser_id=14758d0f3fd05ad24d40ff26c7286df5f161fbc939cf425f50e3d77dca1a9fcf; domain=myopenid.com; path=/; expires=Sun, 29-Jan-2012 19:26:30 GMT
Set-Cookie
secure_session_id=45821a0e8563d543e50bd894b558f818832a04d700569ca7652cf1f33647109c; domain=myopenid.com; path=/; secure; expires=Sun, 29-Jan-2012 19:26:30 GMT
Set-Cookie
session_id=82b46b818e3309a1ecf7e05d5adc0908227f6f0ac77d27924b54c21a8fc7db09; domain=myopenid.com; path=/; expires=Sun, 29-Jan-2012 19:26:30 GMT
P3P
CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
Connection
close
BUILD SUCCESSFUL (total time: 2 seconds)
9 years ago
I changed the following code to code below. But i don't get authenticated


URL url = new URL("https://www.myopenid.com/signin_password";);
URLConnection uRLConnection = url.openConnection();
uRLConnection.setAllowUserInteraction(true);
uRLConnection.setDoInput(true);
uRLConnection.setDoOutput(true);
uRLConnection.setRequestProperty("Username", "hemaljoes");
uRLConnection.setRequestProperty("password", "password");
uRLConnection.connect();



URL url = new URL("https://www.myopenid.com/signin_password";);
URLConnection uRLConnection = url.openConnection();
uRLConnection.setAllowUserInteraction(true);
uRLConnection.setDoInput(true);
uRLConnection.setDoOutput(true);

sun.misc.BASE64Encoder encoder = new BASE64Encoder();
String authorization ="hemaljoes:password";
byte[] bt =authorization.getBytes();
String encodedData = encoder.encode(bt);

uRLConnection.setRequestProperty("Authorization", "Basic " + encodedData);
uRLConnection.connect();


9 years ago
How do i give the username and the password

I tried the following code, but it didn't succeed.

URL url = new URL("https://www.myopenid.com/signin_password";);
URLConnection uRLConnection = url.openConnection();
uRLConnection.setAllowUserInteraction(true);
uRLConnection.setDoInput(true);
uRLConnection.setDoOutput(true);
uRLConnection.setRequestProperty("Username", "hemaljoes");
uRLConnection.setRequestProperty("password", "password");
uRLConnection.connect();

OutputStream outputStream = uRLConnection.getOutputStream();
outputStream.flush();

InputStream in = uRLConnection.getInputStream();
InputStreamReader inReader = new InputStreamReader(in);
BufferedReader reader = new BufferedReader(inReader);

String newLine = null;
while ((newLine = reader.readLine()) != null)
System.out.println(newLine);
reader.close();

String headerName=null;
for (int i=1; (headerName = uRLConnection.getHeaderFieldKey(i))!=null; i++) {
System.out.println(uRLConnection.getHeaderFieldKey(i));
System.out.println(uRLConnection.getHeaderField(i));
}

Can anyone help me please.
9 years ago
Sorry i figured out the solution from some other forum.

instead of creating a URLConnection by new URLConnection()
need to write the code as follow

URL url = new URL("http://www.abc.com";);
URLConnection uRLConnection = url.OpenConnection();
9 years ago
Thanks for your information.

But a small problem.
When i write URLConnection uRLConnection = new URLConnection(url) it gives and error saying that all abstract methods are not implemented.
When i click the suggestion button and click implement all abstract methods its shows something like this.

URLConnection uRLConnection = new URLConnection(url) {

@Override
public void connect() throws IOException {
throw new UnsupportedOperationException("Not supported yet.");
}
};


What should be written inside the connect method?

Thank you.

9 years ago
Hi everyone,

I need to create a java class which can do the following requirement.

- When the openid and the password is given it should create and HttpRequest and send to the https://www.myopenid.com/signin_password page and get the authResponse which has the openid token.

- I need to do accomplish the above task without using a browser.

How can i accomplish my task. A sample code would be much appreciated.

Thanks in advanced.
9 years ago
I have a .war file. I want to deploy it in the Tomcat server.

I copied the .war file in <Tomcat_Home>/webapps/
and started the Tomcat server

But i can not access my application through http://localhost:8080/webapps/<app_name>; or http://localhost:8080/<app_name>;

when i try to access my application with http://localhost:8080/<app_name>; it is redirected to ocalhost:8080/axis2/services/ and displays a error HTTP Status 404

Thanks in advanced
9 years ago
I am new to Java web service.

I want to build a web service client which can get an OpenID token from www.myopenid.com through REST call. Can anyone give me some references on how to start this.

Thanks in advanced.
9 years ago
Hi herb slocomb & Ilja Preuss,
Thank you so much for your replyies