Code example for X509Certificate

Methods: getEncoded

0
	private JSONObject queryCert() {
		try { 
			String userID = JSONData.getString("userID");
			CAOperator cao = new CAOperator();
			X509Certificate cert = cao.QueryCert(userID);
			byte[] bCert = cert.getEncoded();
			String sCert = DatatypeConverter.printBase64Binary(bCert); 
			String IMSI = cao.QueryIMSI(userID);
			cao.close();
			 
			JSONResult.put("TOKEN", "CERTRESP");
			JSONResult.put("userID", userID);
			JSONResult.put("cert", sCert);
			JSONResult.put("IMSI", IMSI);
		} catch (JSONException jsone) {
			jsone.printStackTrace();
		} catch (SQLException sqle) {
			sqle.printStackTrace();
		} catch (CertificateEncodingException e) {
			e.printStackTrace();
		}