dcsimg
Getting java.net.SocketException: java.security.NoSuchAlgorithmException
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   manoj_baranwal
Posted On:   Monday, March 31, 2008 12:15 AM

This is not server client programming. This is standalone java program. I have an URL https://xyz.com/ReportChart?Data=text, When I am using IE, a pop up appeared, asking for user name and password for authentication. After authentication it will open the page. I have written a standalone program to read this URL. Given below: import java.net.*; import java.io.*; import java.util.*; import javax.naming.*; import javax.naming.ldap.*; public class URLReader { public static void main(String[] args) throws Exception { Hashtable env = new Hashtable(); String adminName = "userName"; String adminPassw   More>>

This is not server client programming. This is standalone java program.
I have an URL
https://xyz.com/ReportChart?Data=text, When I am using IE, a pop up appeared, asking for user name and password for authentication. After authentication it will open the page.
I have written a standalone program to read this URL. Given below:


import java.net.*;

import java.io.*;

import java.util.*;

import javax.naming.*;

import javax.naming.ldap.*;


public class URLReader {

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

Hashtable env = new Hashtable();

String adminName = "userName";

String adminPassword = "password";

String ldapURL = "ldaps://xyz.com:636";

String keystore = System.getProperty("java.home")+"/lib/security/cacerts";

System.setProperty("javax.net.ssl.trustStore",keystore);

env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");

env.put(Context.SECURITY_AUTHENTICATION,"EXTERNAL");//"simple");

env.put(Context.SECURITY_PRINCIPAL,adminName);

env.put(Context.SECURITY_CREDENTIALS,adminPassword);

env.put(Context.SECURITY_PROTOCOL,"ssl");

env.put(Context.PROVIDER_URL,ldapURL);

try {

LdapContext ctx = new InitialLdapContext(env,null);

ctx.close();

System.out.println("success");
}

catch (NamingException e) {

System.err.println("Problem searching directory: " + e);

}


URL url = new URL("https://xyz.com/ReportChart?Data=text");

try {

URLConnection yc = url.openConnection();

yc.connect();

BufferedReader in = new BufferedReader(
new InputStreamReader(
yc.getInputStream()));

String inputLine;

while ((inputLine = in.readLine()) != null)

System.out.println(inputLine);


in.close();

} catch (MalformedURLException e) {

System.out.println("URL Exception..."+e);

} catch (IOException e) {

System.out.println("IO Exception..."+e);

}

}

}



This is compiling but when I am running it, getting following errors:

Problem searching directory: javax.naming.CommunicationException: xyz.com:636 [Root exception is java.net.ConnectException: Connection refused: connect]
IO Exception...javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Please help me, How can I resolve this issue.

   <<Less
About | Sitemap | Contact