1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.microemu.cldc;
21
22 import javax.microedition.io.SecurityInfo;
23 import javax.microedition.pki.Certificate;
24 import org.microemu.log.Logger;
25
26 public class SecurityInfoImpl implements SecurityInfo {
27
28 private String cipherSuite;
29 private String protocolName;
30 private Certificate certificate;
31
32 public SecurityInfoImpl(String cipherSuite, String protocolName, Certificate certificate) {
33 this.cipherSuite = cipherSuite;
34 this.protocolName = protocolName;
35 this.certificate = certificate;
36 }
37
38 public String getCipherSuite() {
39 return cipherSuite;
40 }
41
42 public String getProtocolName() {
43 if (protocolName.startsWith("TLS")) {
44 return "TLS";
45 } else if (protocolName.startsWith("SSL")) {
46 return "SSL";
47 } else {
48
49 try {
50 throw new RuntimeException();
51 } catch (RuntimeException ex) {
52 Logger.error(ex);
53 throw ex;
54 }
55 }
56 }
57
58 public String getProtocolVersion() {
59 if (protocolName.startsWith("TLS")) {
60 return "3.1";
61 } else if (getProtocolName().equals("SSL")) {
62 return "3.0";
63 } else {
64
65 try {
66 throw new RuntimeException();
67 } catch (RuntimeException ex) {
68 Logger.error(ex);
69 throw ex;
70 }
71 }
72 }
73
74 public Certificate getServerCertificate() {
75 return certificate;
76 }
77
78 }