Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners http Client Authentication

Have Programming Question? Ask it here!
 
 
 


milind
http Client Authentication
0 Answer(s)      3 years and 7 months ago
Posted in : Java Beginners


hi friends,

i am trying a java API using HTTPCLient post method.  in which i am getting output having some authentication problem. can any one please help me to solve this problem.

please , please help me.. waiting for reply.

Thanks in advance.

This is what the PROGRAM

import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;

public class sms {

public static void main( String[] args ) throws Exception  {

 String qURL="http://9.184.65.219:10038";    
    String UserId="adm";    
    String Password="adm";
    String postTitle="Pls11";

    byte entry[] = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?><entry xmlns=\"http://www.w3.org/2005/Atom\"> <title type=\"text\"> "+postTitle+" </title></entry>").getBytes();

String placeurl = qURL+"/asd/myquic"+"/feed";

 try {
    System.out.println("\n Place Collection URL = "+ placeurl);

HttpClient client = new HttpClient();
PostMethod method = new PostMethod( placeurl );

 // Configure the form parameters

  method.addParameter( "CONTENT-TYPE", "application/atom+xml" );
  method.addParameter( "CONTENT-LENGTH", new Integer(entry.length).toString() );
  method.addParameter( "Host", "localhost");
  method.addParameter( "User-Agent", "Thingio/1.0" );
  method.addParameter( "Keep-Alive", "header");
  method.addParameter( "Authorization", "Basic " + (new  sun.misc.BASE64Encoder().encode((UserId+":"+Password).getBytes())));

System.out.write(entry);

 // Execute the POST method
int statusCode = client.executeMethod( method );

System.out.println("\n Response status code: " + statusCode);

// Display response
System.out.println("\n Response body: ");
System.out.println(method.getResponseBodyAsString());

 }

 catch( Exception e ) {
    System.err.println ( "\n Exception...\n" + e ) ;
    e.printStackTrace();
   }
 }

}

output
Place Collection URL = http://9.184.65.219:10038/asd/myquic/feed
<?xml version="1.0" encoding="UTF-8"?><entry xmlns="http://www.w3.org/2005/Atom">
Pls11 Jan 10, 2011 3:17:19 PM org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme
INFO: basic authentication scheme selected
Jan 10, 2011 3:17:19 PM org.apache.commons.httpclient.HttpMethodDirector processWWWAuthChallenge
INFO: No credentials available for BASIC 'Atom'@9.184.65.219:10038

Response status code: 401

Response body: 
Thanks and regards,
Milind.

Advertisement
View Answers

Related Tutorials/Questions & Answers:
http Client Authentication
http Client Authentication  hi friends, i am trying a java API... authentication problem. can any one please help me to solve this problem. please... ) throws Exception { String qURL="http://9.184.65.219:10038"; String
Spring Security HTTP basic authentication
Spring Security HTTP basic authentication In this section, you will learn about the HTTP basic authentication in Spring Security. You can configure HTTP... Security HTTP basic authentication configuration--> <http> <intercept
Advertisements
How to fireup HTTP request from JavaFX Client
How to fireup HTTP request from JavaFX Client  Please tel me how do I can fire HTTP post request from an JavaFX client. Sceneario: I've an JavaFX... i've working version of JSP Code to handle HTTP post request tested by posting
Basic authentication
the client's built in authentication mechanism. In java programming language... Basic authentication       Basic authentication is the process through which a web server authenticates
HTTP Authentication With PHP
HTTP Authentication with PHP: The HTTP Authentication is available when... to send a message (for authentication) to the client side (browser... for authentication. $_SERVER and $HTTP_SERVER_VARS contains these predefined
Authentication in Servlets
Authentication in Servlets  What are different Authentication options available in Servlets
Authentication - JavaMail
Authentication program in Java  How to write a program in Java for user authentication
Login authentication
Login authentication  i want d code for login authentication from mysql database on the same pc using swings
Login authentication
Login authentication  i want d code for login authentication from mysql database on the same pc using swings
Authentication - Struts
Authentication  Hello everybody, How to provide high level authentication in struts application
gmail authentication
browser window it asks for authentication how it is possible if anybody knows plz tell... request Authentication done using Session If you signout and paste URL It Ask
Sending email without authentication
Sending email without authentication  Hi sir, Am doing a project in JSP, in that i want to send mail without any authentication of password so send...: http://www.roseindia.net/ejb/introduction/j2eedemo.shtml http://www.roseindia.net
Struts Login Authentication
Struts Login Authentication  Hi Sir, Am doing a project in a struts 1.2,i want login authentication code fro that, only authenticated user can...: http://www.roseindia.net/struts/struts2/struts2login.shtml http
iphone nsurlrequest authentication
iphone nsurlrequest authentication   How to authenticate a form in iPhone Application
windows authentication with hibernate - Hibernate
windows authentication with hibernate  Does anyone know how to setup a datasource for SQL Server that uses Windows authentication instead of SQL Server mixed mood authentication? Is it possible with hibernate framwork? Thanks
SSL Authentication - JSP-Servlet
SSL Authentication  With the help of a sample code describe the use of SSL Authentication of java clients
Retrieve HTTP Request Headers using JSP
the request headers. When a HTTP client sends a request, it is required to supply GET... Retrieve HTTP Request Headers using JSP   ...-Alive value or gets a  request line indicating HTTP 1.1, it may
login authentication - Java Beginners
login authentication  i 've designed the jsp page for login. now i need to connect it with the bean and do authentication for the login for the "register" table in mysql. can anybody help me with the code immediately
Authentication of password - Swing AWT
Authentication of password  System level authentication of password...?????  check out the below link  check out this link http... information. http://www.roseindia.net/java/example/java/swing/ Thanks
JDbc Login Authentication
JDbc Login Authentication  Pease Please.. Send Me one Login Authentication Using ComboBox.From Servlet and jsp with sessions I am new to sessions... the following link: http://www.roseindia.net/jsp/loginbean.shtml
who is client
who is client   tell me who is client is management
user authentication code in php - PHP
user authentication code in php  Hi, Can you please send me a user authentication code in php? or just post the guidelines to authenticate a user. Thanks
Client Interview
Client Interview  Hi, I am kumar i am having client round in polaries client is a BANK. how to face client interview. what are the expected questions from CITI
Login Authentication and session in JSP - JSP-Servlet
Login Authentication and session in JSP  Hi, I am creating an small application in JSP,in which i need to check user authentication and session... with this. Thank you  Hi Friend, Please visit the following link: http
login authentication - Java Beginners
. http://www.roseindia.net/jsp/loginbean.shtml Thanks. Amardeep
Thin client
Thin client  What is a thin client?   A thin client is a lightweight interface to the application that does not have such operations like query databases, execute complex business rules, or connect to legacy
in php What the code is to be written for Authentication with Session Control
in php What the code is to be written for Authentication with Session Control  in php What the code is to be written for Authentication with Session Control
Login authentication & mysql - Java Beginners
Login authentication & mysql  Hi , Could you guide or provide sample coding for the following scenerio. I need to code authentication for user... Authentication with MySql using Java Swing: 1)Create a java class
Rmi client
Rmi client  Sir i just created client and server following the RMI rule, its running properly in the localhost, when i am trying to run the program in the different machine its not working, i changed the ip also, when i copied
Specifying an Authentication Mechanism in the Deployment Descriptor
In this section, you will learn how to specify an authentication mechanism in the deployment descriptor
Problem with Instead of using http://localhost:8080 using http://{ipaddress}:8080
Problem with Instead of using http://localhost:8080 using http://{ipaddress... Object to access the java class and display through flex. It works if I ues http... Address instead of localhost , login page is opening http://{ipaddress}:8080
send without authentication mail using java - JavaMail
send without authentication mail using java  Dear All, I am tring to send simple mail without authentication using java. is it possible, could i send email without authentication. I have written following code. public
HTTP Post PHP
HTTP Post PHP  HTTP post method example in PHP
http header content length
http header content length  How to check the request header content length in HTTP
error "HTTP Status 500"
error "HTTP Status 500"  How to solve this error "HTTP Status 500
HTTP Protocol
HTTP Protocol          HTTP Protocol stands for Hyper Text Transfer Protocol. It is the protocol used to convey information of World Wide Web (WWW). HTTP protocol
HTTP Status 404 -
HTTP Status 404 -   HTTP Status 404 - type Status report message description The requested resource () is not available. Apache Tomcat/5.5.31 how to rectify the above error
JMeter HTTP request example
JMeter HTTP request example  Concerning: http://www.roseindia.net/jmeter/using-jmeter.shtml how do I set path? also what do i need to do to get the helloworld servlet work? Thanks in advance
Difference between http and https
Difference between http and https  Difference b/w HTTP and HTTPS please provide answer in tabular form.   Hi Friend, Differences: 1)HTTP... and receiving information across the Internet where as HTTPS is secure http, which
Java Client Application
Java Client Application  Java Client Application
Client side refresh
Client side refresh  What is client side refresh?   The standard HTTP protocols ways of refreshing the page, which is normally supported by all browsers. <META HTTP-EQUIV="Refresh" CONTENT="5; URL=/servlet/MyServlet
Login Authentication using existing Active Directory.
Login Authentication using existing Active Directory.  I need jsp code for login authentication of username and password using already existing Active Directory. Here no need to create active directory.The JSP code should
Java Glossary : Authentication
Java Glossary : Authentication       Authentication is the process of ensuring to some in order... key.  A web authentication where a web page includes a dialog box having
HTTP_POST_VARS is deprecated
HTTP_POST_VARS is deprecated  HTTPPOSTVARS is deprecated. Which function to be used? Thanks   Hi, You should use: $id=$_GET["id"]; or $id=$_POST["id"]; thanks
HTTP Status 500 -
HTTP Status 500 -   Hi, I am new to jsp... Installed Tomcat 5.5.... wrote. i can see these errors... HTTP Status 500 - type Exception report... of your tomcat. 8)Open your browser and type the following url: http://localhost
Error : http status 500?
Error : http status 500?  hello sir, am using netbeans6.7.1 version i implemented one program i.e web application ..when am excuting this one i got one error http status 500...please solve this error ..when did i mistakn
HTTP Status 404 - Struts
HTTP Status 404   Hello, i am making a program of tiles using Struts2. i face error HTTP Status 404 May 4, 2010 11:31:59 AM org.apache.catalina.core.AprLifecycleListener init INFO: The Apache Tomcat Native library which
Java Client Application example
Java Client Application example  Java Client Application example
Java HTML Client Application
Java HTML Client Application  Java HTML Client Application
 

 

 

DMCA.com