Платформа MIDP-2.0, но сейчас уже подумываю переписать под MIDP-1.0. На данный момент есть это:
| Код | StreamConnection sc = (StreamConnection) Connector.open("socket://77.120.121.228:9090"); KeyStore cs = new KeyStore() { public Enumeration aliases() { throw new UnsupportedOperationException("Not supported yet."); }
public Certificate getCertificate(String string) { try { InputStream is = this.getClass().getResourceAsStream("/terminal.cer"); byte[] data = new byte[is.available()]; is.read(data); return X509Certificate.generateCertificate(data, 0, data.length); } catch (Exception ex) { ex.printStackTrace(); return null; } }
public boolean containsAlias(String string) { throw new UnsupportedOperationException("Not supported yet."); }
public int size() { throw new UnsupportedOperationException("Not supported yet."); }
public String getType() { throw new UnsupportedOperationException("Not supported yet."); } };
SSLStreamConnection.setTrustedKeyStore(cs); SSLStreamConnection sslsc = new SSLStreamConnection("77.120.121.228", 9090, sc.openInputStream(), sc.openOutputStream()); sc.close();
InputStream is = sslsc.openInputStream(); OutputStream os = sslsc.openOutputStream();
os.write(("Hello!").getBytes());
is.close(); os.close(); sslsc.close();
|
Использую классы com.sun.ksecurity.Certificate и com.sun.ksecurity.KeyStore, но, к сожалению, вываливает Exception NoClassDefFound для KeyStore :( |