dcsimg
error message error msg Https unknown protocol
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   thanga_lakshmi
Posted On:   Monday, August 1, 2005 02:25 PM

i have the following code.i am getting the error message heeps unknown protocol.i am using jdk 1.3 package Innkeeper; import java.io.*; import java.net.*; import java.sql.*; import java.util.*; import javax.net.ssl.*; import java.security.*; import com.sun.net.ssl.*; import javax.security.*; //import com.sun.net.ssl.HttpsURLConnection; /** * Title: Easy Innkeeping * Description: This class has functionlities to process the Credit card online * through authirize.net * Copyright: Copyright (c) 2003 * Company: Grace Software Inc * @author saravana * @version 3.5 */    More>>

i have the following code.i am getting the error message heeps unknown protocol.i am using jdk 1.3
package Innkeeper;

import java.io.*;
import java.net.*;
import java.sql.*;
import java.util.*;
import javax.net.ssl.*;
import java.security.*;
import com.sun.net.ssl.*;
import javax.security.*;

//import com.sun.net.ssl.HttpsURLConnection;



/**
* Title: Easy Innkeeping
* Description: This class has functionlities to process the Credit card online
* through authirize.net
* Copyright: Copyright (c) 2003
* Company: Grace Software Inc
* @author saravana
* @version 3.5
*/

public class CCProcess
{
private static CCProcess ccProcess = null;
CardData ccData = new CardData ();

public CCProcess ()
{

}

public static CCProcess getInstance () {
if ( ccProcess == null )
ccProcess = new CCProcess ();

return ccProcess;
}

//==============================================================================
//Calling from QuickReservation Screen
//==============================================================================

public boolean processFromQReservation ( int reservId, String firstName, String lastName, double depAmount,
String cardType, String cardNumber,String cardExpire,String address, String city, String state,
String zip, String phNumber,String eMail)
{

clearValues();

ccData.strFirstName = firstName;
ccData.strLastName = lastName;
ccData.depositAmt = depAmount;
ccData.strCardType = cardType;
ccData.strCardNumber = cardNumber;
ccData.strCardExpireDate = cardExpire;
ccData.strAddress = address;
ccData.strCity = city;
ccData.strState = state;
ccData.strZip = zip;
ccData.strPhone = phNumber;
ccData.strMail = eMail;

ccData.merchantUsername = Globals.merchantUsername;
ccData.merchantPassword = Globals.merchantPassword;

boolean val = startProcess ( ccData );
if ( val )
return true;
else
return false;

}

//From resercharges.java billing screen

public void setDatasFomBilling(String cardType, String cardNumber, String expDate, double Amount)
{
// clearValues();
ccData.depositAmt = Amount;
ccData.strCardExpireDate = expDate;
ccData.strCardNumber = cardNumber;
ccData.strCardType = cardType;
}

//==============================================================================
// Calling from Billing Screen
//==============================================================================

public boolean processFromBilling(int reservId)
{
ResultSet rs = null;
// clearValues();
try
{
rs = InnkeeperData.getInstance ().getCardDetails ( reservId );

while ( rs.next () )
{
ccData.strFirstName = rs.getString ( "firstname" );
ccData.strLastName = rs.getString ( "lastname" );
}
rs.close ();
rs = InnkeeperData.getInstance ().getGuestInfoForPrint ( ccData.guestId );

while ( rs.next () )
{
ccData.strAddress = rs.getString ( "address" );
ccData.strCity = rs.getString ( "city" );
ccData.strState = rs.getString ( "state" );
ccData.strZip = rs.getString ( "zip" );
ccData.strPhone = rs.getString ( "buss_phone" );
ccData.strMail = rs.getString ( "email_addr" );
}

rs.close ();
rs = null;

ccData.merchantUsername = Globals.merchantUsername;
ccData.merchantPassword = Globals.merchantPassword;

// System.out.println(ccData.strFirstName +","+ ccData.strLastName +","+ ccData.strAddress +","+ccData.strMail );
boolean val = startProcess ( ccData );
if ( val )
return true;
else
return false;
}
catch ( Exception e )
{
CommonMethods.getInstance ().writeErrToErrLog ( e );
return false;
}
}

//==============================================================================
//Starting Process " Hitting the server with SSL Implementation"
//==============================================================================

public boolean startProcess ( CardData ccData )
{
System.err.println ( "Process started" );
boolean val = false;
String postData = "";
String returnVal = "";
StringTokenizer st = null;
String token1 = "";
String token2 = "";
String token3 = "";
String token4 = "";

try
{

// Setting the System property to work with https protocol

// System.setProperty( "java.protocol.handler.pkgs", "com.sun.net.ssl.inernal.www.protocol" );
System.setProperty( "java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol" );
// Security.addProvider( new com.sun.net.ssl.internal.ssl.Provider());

URL url = new URL ( "https://secure.authorize.net/gateway/transact.dll?" );

postData = collectData ();

returnVal = submitData ( url, postData );

if ( !returnVal.equals ( null ) )
{
st = new StringTokenizer ( returnVal, "," );
token1 = st.nextToken ();
token2 = st.nextToken ();
token3 = st.nextToken ();
token4 = st.nextToken ();
}
else
return false;

if ( token1.trim ().equals ( "1" ) && ( token2.trim ().equals ( "1" ) ) &&( token3.trim ().equals ( "1" ) ) )
return true;
else
{
Globals.showMessageBox("Warning",token4,Globals.ERROR_DIALOG );
return false;
}

}
catch ( Exception e )
{
CommonMethods.getInstance ().writeErrToErrLog ( e );
return false;
}

}

//==============================================================================
//Collecting data to send to Authorize.net for Processing
//==============================================================================

public String collectData ()
{

String postData = "";

try
{
postData = "x_login=" + URLEncoder.encode( ccData.merchantUsername ) + "&";
postData += "x_Password=" + URLEncoder.encode( ccData.merchantPassword ) + "&";
postData += "x_version=" + URLEncoder.encode( "3.0" ) + "&";
postData += "x_Test_Request=" + URLEncoder.encode( "TRUE" ) + "&";
postData += "x_ADC_Delim_Data=" + URLEncoder.encode( "TRUE" ) + "&";
postData += "x_ADC_URL=" + URLEncoder.encode( "FALSE" ) + "&";
postData += "x_Card_Num=" + URLEncoder.encode( ccData.strCardNumber ) + "&";
postData += "x_Exp_Date=" + URLEncoder.encode( ccData.strCardExpireDate ) + "&";
postData += "x_Amount=" + URLEncoder.encode( String.valueOf( ccData.depositAmt ) ) + "&";
postData += "x_First_Name=" + URLEncoder.encode( ccData.strFirstName ) + "&";
postData += "x_Last_Name=" + URLEncoder.encode( ccData.strLastName ) + "&";
postData += "x_company=" + URLEncoder.encode( ccData.strCompany ) + "&";
postData += "x_Address=" + URLEncoder.encode( ccData.strAddress ) + "&";
postData += "x_City=" + URLEncoder.encode( ccData.strCity ) + "&";
postData += "x_State=" + URLEncoder.encode( ccData.strState ) + "&";
postData += "x_ZIP=" + URLEncoder.encode( ccData.strZip ) + "&";
postData += "x_Phone=" + URLEncoder.encode( ccData.strPhone ) + "&";
postData += "x_Fax=" + URLEncoder.encode( ccData.strFax ) + "&";
postData += "x_Email=" + URLEncoder.encode( ccData.strMail ) + "&";


/*postData = "x_login=" + URLEncoder.encode( ccData.merchantUsername, "UTF-8" ) + "&";
postData += "x_Password=" + URLEncoder.encode( ccData.merchantPassword, "UTF-8" ) + "&";
postData += "x_version=" + URLEncoder.encode( "3.0", "UTF-8" ) + "&";
postData += "x_Test_Request=" + URLEncoder.encode( "TRUE", "UTF-8" ) + "&";
postData += "x_ADC_Delim_Data=" + URLEncoder.encode( "TRUE", "UTF-8" ) + "&";
postData += "x_ADC_URL=" + URLEncoder.encode( "FALSE", "UTF-8" ) + "&";
postData += "x_Card_Num=" + URLEncoder.encode( ccData.strCardNumber, "UTF-8" ) + "&";
postData += "x_Exp_Date=" + URLEncoder.encode( ccData.strCardExpireDate, "UTF-8" ) + "&";
postData += "x_Amount=" + URLEncoder.encode( String.valueOf( ccData.depositAmt ), "UTF-8" ) + "&";
postData += "x_First_Name=" + URLEncoder.encode( ccData.strFirstName, "UTF-8" ) + "&";
postData += "x_Last_Name=" + URLEncoder.encode( ccData.strLastName, "UTF-8" ) + "&";
postData += "x_company=" + URLEncoder.encode( ccData.strCompany, "UTF-8" ) + "&";
postData += "x_Address=" + URLEncoder.encode( ccData.strAddress, "UTF-8" ) + "&";
postData += "x_City=" + URLEncoder.encode( ccData.strCity, "UTF-8" ) + "&";
postData += "x_State=" + URLEncoder.encode( ccData.strState, "UTF-8" ) + "&";
postData += "x_ZIP=" + URLEncoder.encode( ccData.strZip, "UTF-8" ) + "&";
postData += "x_Phone=" + URLEncoder.encode( ccData.strPhone, "UTF-8" ) + "&";
postData += "x_Fax=" + URLEncoder.encode( ccData.strFax, "UTF-8" ) + "&";
postData += "x_Email=" + URLEncoder.encode( ccData.strMail, "UTF-8" ) + "&";
*/

}
catch ( Exception e )
{
CommonMethods.getInstance ().writeErrToErrLog ( e );
}

System.out.println(postData);
return postData;
}

//==============================================================================
//Submitting data to authorize.net server
//==============================================================================

public String submitData ( URL url, String postData )
{

String returnVal = "";
HttpURLConnection targetURL = null;
DataOutputStream dos = null;
DataInputStream dis = null;

try
{

System.err.println ( "Open Process" );

targetURL = ( HttpURLConnection ) url.openConnection ();
targetURL.setDoOutput ( true );
targetURL.setDoInput ( true );
targetURL.setAllowUserInteraction ( false );

dos = new DataOutputStream (targetURL.getOutputStream () );
dos.writeBytes ( postData );
dos.close ();

System.err.println ( "Get Output" );

dis = new DataInputStream ( targetURL.getInputStream () );
String val = "";
BufferedReader br = new BufferedReader ( new InputStreamReader ( dis ) );

while ( ( val = br.readLine () ) != null )
{
returnVal = val + returnVal;
}

dis.close ();
targetURL.disconnect() ;

System.err.println ( "Disconnect" );

return returnVal;
}
catch ( Exception e )
{
CommonMethods.getInstance ().writeErrToErrLog ( e );
Globals.showMessageBox ( "Warning Message","Error in opening connection",Globals.WARNING_DIALOG );
}

return returnVal;

}

//==============================================================================
// Clearing values
//==============================================================================

private void clearValues()
{
ccData.guestId = 0;
ccData.strAddress = "";
ccData.strCardExpireDate = "";
ccData.strCardNumber = "";
ccData.strCardType = "";
ccData.strCity = "";
ccData.strCompany = "";
ccData.strFax = "";
ccData.strFirstName = "";
ccData.strLastName = "";
ccData.strMail = "";
ccData.strPhone = "";
ccData.strState = "";
ccData.strZip = "";
}

//==============================================================================
// Credit card data
//==============================================================================

private class CardData
{
String merchantUsername = "";
String merchantPassword = "";
String strFirstName = "";
String strLastName = "";
int guestId = 0;
double depositAmt = 0.0;
String strCardType = "";
String strCardNumber = "";
String strCardExpireDate = "";
String strCompany = "";
String strAddress = "";
String strCity = "";
String strState = "";
String strZip = "";
String strPhone = "";
String strFax = "";
String strMail = "";

}

//==============================================================================
//main method
//==============================================================================

public static void main ( String args[] )
{
CCProcess ccProcess1 = new CCProcess ();
}

}

   <<Less

Re: error message error msg Https unknown protocol

Posted By:   Anand_Rajasekar  
Posted On:   Tuesday, August 2, 2005 02:06 AM

Refer the jsse install instructions


HTTPS Support

The JSSE reference implementation contains a URL handler for the "https" URL protocol type. In order to use this handler, you must add the handler's implementation package name to the list of packages which are searched by the java URL class. This is configured via the "java.protocol.handler.pkgs" system property. See the java.net.URL class documentation for details. System properties can be set via the command line or at runtime through the java.lang.System class.


For example, you can set this property on the command line via:


java -Djava.protocol.handler.pkgs=
com.sun.net.ssl.internal.www.protocol



When accessing HTTPS servers through a web proxy, you must set the https.proxyHost and https.proxyPort system properties to the correct host name and port number of the web proxy.


For example, to set this property on the command line to access HTTPS servers through the proxy host "webproxy" running at port 8080 you would use:


java -Dhttps.proxyHost=webproxy -Dhttps.proxyPort=8080

Re: error message error msg Https unknown protocol

Posted By:   Almagest_FUTT  
Posted On:   Monday, August 1, 2005 04:00 PM

Are you seriously expecting anybody to read this ?
About | Sitemap | Contact