• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using J2me/Kssl/Ksecurity on Palm O/S

 
Vijay Pat
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can Someone help for using kssl/Ksecurity on Palm O/S
KVM stdout: 5 Sep 2002, 14:48
Stream Connection sc com.sun.cldc.io.palm.https.Protocol@ea0ef881
output stream opened com.sun.cldc.io.palm.http.PrivateOutputStream@84aee8b
Stream Connection sc again com.sun.cldc.io.palm.https.Protocol@ea0ef881
error caught prateek
com.sun.cldc.io.palm.http.InetException: errCode=1290
at com.sun.cldc.io.palm.http.Inet.InetHTTPReqCreateAndSend(+92)
at com.sun.cldc.io.palm.http.Protocol.sendRequest(+63)
at com.sun.cldc.io.palm.http.Protocol.openInputStream(+65)
at j2meKssl.connect(+210)
at j2meKssl.commandAction(+4)
at javax.microedition.lcdui.Display$DisplayAccessor.commandAction(+99)
at com.sun.midp.lcdui.DefaultEventHandler$2.run(+410)
Exception in MIDlet's CommandAction method
java.lang.NullPointerException
at j2meKssl.connect(+246)
at j2meKssl.commandAction(+4)
at javax.microedition.lcdui.Display$DisplayAccessor.commandAction(+99)
at com.sun.midp.lcdui.DefaultEventHandler$2.run(+410)
Do we need to say https or inethttps://
Example
sc = (HttpConnection) Connector.open("https://vijayp:8443/index.html", Connector.READ_WRITE);
or
sc = (HttpConnection) Connector.open("inethttps://vijayp:8443/index.html", Connector.READ_WRITE);
above errors are caught when inethttps is used
When i use https on palm, getting a error :- No such field default_port.|
Tested the program on J2me toolkit 1.0.3, Server Side Tomcat

below is my source code for j2me Application

********************************************************
import java.io.*;
import java.lang.*;
import java.util.*;
import javax.microedition.io.*;
import javax.microedition.midlet.*;
import javax.microedition.io.Connector;
import javax.microedition.io.StreamConnection;
import javax.microedition.io.ConnectionNotFoundException;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.ChoiceGroup;
import com.sun.kssl.*;
import com.sun.ksecurity.*;
import com.sun.kssl.SSLStreamConnection;
import com.sun.midp.io.j2me.https.*;
//import com.sun.cldc.io.j2me.socket.Protocol.*;
import com.sun.midp.io.InternalConnector; //
import com.sun.midp.*;
import com.sun.midp.lcdui.*;
import com.sun.midp.io.*;
import com.sun.midp.security.*;
import com.sun.cldc.io.*;

/*import com.sun.kssl.Record;
import com.sun.kssl.Handshake;
import com.sun.ksecurity.MD5;
import com.sun.ksecurity.PRand;
import com.sun.kssl.Session;
import com.sun.kssl.X509Certificate;*/
//import com.sun.midp.lcdui.Resource;
// code modified on may 30 2002
public class j2meKssl extends MIDlet implements CommandListener {
// public static void main(String[] args) {
//InputStream in = null;
DataInputStream in = null;
OutputStream out = null;
StreamConnection sc1 = null;
HttpConnection htp, sc = null;
int i = 0;

private Form formSettings;
private Command CommandSubmit = new Command("Connect ",Command.SCREEN,0);
Displaydisp;

public j2meKssl() { }

public void pauseApp() { }
public void destroyApp(boolean unconditional) { }
StringBuffer response = null;
byte[] data;
public void startApp()
{
disp = Display.getDisplay(this);
formSettings = new Form("Settings");
formSettings.append("Server Config. Dtls");
formSettings.addCommand(CommandSubmit);
formSettings.setCommandListener(this);
disp.setCurrent(formSettings);
}
public void commandAction(Command c, Displayable s) {
connect();
}
public void connect() {
//j2meKssl j2me = new j2meKssl();
data = new byte[5000];
response = new StringBuffer();
try {
// Connector.open("https://192.168.1.61:443/index.htm", Connector.READ_WRITE); IP adrress at MIDC
//htp = (HttpConnection) Connector.open("https://172.18.1.75:443/index.htm", Connector.READ_WRITE); // process 2
//"https://banking.wellsfargo.com/ "https://172.18.1.75:443/index.htm"
// added www to connection string to try setting problem for bad certificate exception
// when www was given bad certificate type error not thrown, but other error persists
//sc = (HttpConnection) Connector.open("https://banking.wellsfargo.com", Connector.READ_WRITE); // process 1
//sc = (HttpConnection) Connector.open("https://www.verisign.com", Connector.READ_WRITE); // works fine
//sc = (HttpConnection) Connector.open("https://localhost:8443/index.html", Connector.READ_WRITE); // got entire page when no GET command was used below
// inethttps for palm
//sc = (HttpConnection) Connector.open("inethttps://vijayp:8443/index.html", Connector.READ_WRITE); // got entire page when no GET command was used below

// https for j2me and palm ask ?
sc = (HttpConnection) Connector.open("https://vijayp:8443/index.html", Connector.READ_WRITE); // got entire page when no GET command was used below
//sc = (HttpConnection) Connector.open("http://192.168.1.139:8080/midp/TestServlet"); // manish
//sc = (HttpConnection) Connector.open("https://localhost:8443/index.html", Connector.READ_WRITE); // could not send close_notify error
//sc = (HttpConnection) Connector.open("https://naresh:7002/", Connector.READ_WRITE); // works fine
/*if( htp != null )
System.out.println("Got https connection"); */

sc.setRequestMethod(HttpConnection.GET);
sc.setRequestProperty("IF-Modified-Since","20 Jan 2001 16:19:14 GMT");
sc.setRequestProperty("User-Agent","Profile/MIDP-1.0 Configuration/CLDC-1.0");
sc.setRequestProperty("Content-Language", "en-CA");
sc.setRequestProperty("content-type", "plain/text");
sc.setRequestProperty("Connection", "close");
/*out = sc.openOutputStream();

if( out != null )
System.out.println("output stream opened "+out);

try // get statement marked because of ERRORS
{
out.write( "abc1223464362463426432643246342643264326456575348".getBytes() ); // no problem
out.close();
System.out.println("Written success"+out);
} catch (IOException ioo) { System.out.println("Internal IOEx"); ioo.printStackTrace(); }*/
try
{
System.out.println("Stream Connection sc again "+sc);
in = sc.openInputStream();

} catch(IOException iox) { System.out.println("error caught prateek"); iox.printStackTrace(); }


/*int actual = in.read(data);
System.out.println("Len "+actual);
for ( i=0; i < actual; i++ ) { response.append((char)data[i]); } */

/*in = htp.openDataInputStream(); process 2
if( in != null )
System.out.println("got instream OBJECT");

System.out.println("After read operation");*/
int ch;
// receive response and display it in a textbox.
while ((ch = in.read()) != -1) {
response.append((char) ch);
}
System.out.println("After read operation");
if(in != null) { in.close(); }
if(sc != null) { sc.close(); }
System.out.println("Response From Server"+response.toString());
} catch(IOException io) { System.out.println("caught io exp "); io.printStackTrace(); }
// + ";CertificateErrorHandling=warn" + ";HandshakeCommentary=on"
// sc = (StreamConnection) (HttpConnection)

//sc = (StreamConnection) Connector.open("https://192.168.1.61:443/index.htm", Connector.READ_WRITE);
//sc.setRequestMethod(HttpConnection.GET);
//} catch( SSLException bdex ) { System.out.println("Bad Certificate exception"); }
// Before any application data is sent or received SSL handshake is done to set security attributes
// SSLHandshake();
/*out = sc.openOutputStream();
if( out != null )
System.out.println("output stream");
// GET http://www.verisign.com/index.html HTTP/1.1
out.write( "GET /index.htm HTTP/1.1".getBytes() );*/
/*in = sc.openInputStream();
int actual = in.read(data);
System.out.println("Len "+actual);
for ( i=0; i < actual; i++ ) { response.append((char)data[i]); }
System.out.println("Result" + response.toString());
System.out.println("OK");

} catch ( java.io.IOException iox ) { System.out.println("Caught IO exception 1"); } */
// send data by writing to out, receive by
// reading from in

/*try {
if( in != null ) {
System.out.println("Closed successfully");
in.close();
}
if( out != null )
out.close();
if( sc != null )
sc.close();
} catch ( java.io.IOException iox ) { System.out.println("Caught IO exception again"); } */
} // startapp ends
// } main ends
}
********************************************************
Thanks in Advance
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, what is your question? Did inethttps work for you? To run HTTPS on Palm, you need a MIDP.prc that is capable of doing that.
I do not think J2MEWTK 1.0.3 has v1.0.3 MIDP VM for Palm. I think they only updated the VM for sun's emulators. I might be wrong though.
But in any case, inethttps should be supported on Palm.
cheers
 
Vijay Pat
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael
No inethttps did not work on Palm, i had already
mentioned the exceptions i get on device and
emulator.Also there is an updated VM MIDP_g.prc
on which i tested the above program.
When i use https:// i get error :-
No such field default_port

Now i have to try on midp.prc and this and that
R n D Continues
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic