Skip to content

Instantly share code, notes, and snippets.

@adilkurniaramdan
Created January 27, 2015 08:17
Show Gist options
  • Save adilkurniaramdan/b5155ad0599d3a041a03 to your computer and use it in GitHub Desktop.
Save adilkurniaramdan/b5155ad0599d3a041a03 to your computer and use it in GitHub Desktop.
class : DjpWs.class
public String ProsesXmlLengkap(String AlamatFileXML, String NPWP) {
String respon = null;
String pathKeystoreLocation = sCtx.getInitParameter("keystoreLocation");
String passwordKeystore = sCtx.getInitParameter("passwordKeystore");
logger.info("[ProsesXMLLengkap] Processing file [" + NPWP + "]");
try {
String AlamatWrapped = sCtx.getInitParameter("pathWrapped");
logger.debug("[ProsesXMLLengkap] Parent direcory wrapped XML " + AlamatWrapped);
String AlamatCSV = sCtx.getInitParameter("pathCSV");
logger.debug("[ProsesXMLLengkap] Parent directory csv " + AlamatCSV);
String AlamatPDF = sCtx.getInitParameter("pathPDF");
logger.debug("[ProsesXMLLengkap] Parent directory pdf " + AlamatPDF);
String ejbcaServiceUrl = sCtx.getInitParameter("ejbca");
logger.debug("[ProsesXMLLengkap] url dummy DJP" + ejbcaServiceUrl);
XMLProses proses = new XMLProses();
Sertifikat sert = new Sertifikat();
//verifikasi signature
logger.debug("[ProsesXMLLengkap] Getting Allias certificate ASP ..");
String AliasASP = proses.dapatkanAliasSertifikatASP(AlamatFileXML);
logger.debug("[ProsesXMLLengkap] Getting Allias certificate ASP success");
logger.debug("[ProsesXMLLengkap] Getting Allias certificate WP ..");
String AliasWP = proses.dapatkanAliasSertifikatWP(AlamatFileXML);
logger.debug("[ProsesXMLLengkap] Getting Allias certificate WP success ");
String ntpa = proses.dapatkanNTPA(AlamatFileXML);
SignatureData TandaTangan = new SignatureData();
//verifikasi signature asp
DigestData digest = new DigestData();
logger.debug("[ProsesXMLLengkap] Getting signature ASP data from XML file");
byte[] byteSignatureASP = proses.DapatkanSignatureASP(AlamatFileXML);
logger.debug("[ProsesXMLLengkap] Getting signature ASP data from XML file succes");
logger.debug("[ProsesXMLLengkap] Getting signature WP data from XML file");
byte[] byteSignatureWP = proses.DapatkanDataSignature(AlamatFileXML);
logger.debug("[ProsesXMLLengkap] Getting signature WP data from XML file success");
logger.debug("[ProsesXMLLengkap] Getting digest data signature WP data from XML file");
byte[] byteHasilDigestSignatureWP = digest.dapatkanDataDigest(byteSignatureWP);
logger.debug("[ProsesXMLLengkap] Getting digest data signature WP data from XML file success");
logger.debug("[ProsesXMLLengkap] Getting Public key ASP");
PublicKey publicKeyASP = sert.DapatkanPublicKeyASP(ejbcaServiceUrl, AliasASP); <<< Line ini
/*
*code omitted
*/
class : Sertifikat
public PublicKey DapatkanPublicKeyASP(String url, String alias) {
// PublicKey PublicKeyASP = null;
// ConnectURL http = new ConnectURL();
// HashMap<String, String> params = new HashMap<>();
// params.put("alias", alias);
// BufferedReader br = http.connectHTTP(url+"/getpublickey", params);
// //System.out.println(">> "+br.lines().toArray()[0]);
// Gson gs = new Gson();
// X509 key = gs.fromJson(br, X509.class);
// X509Certificate cert = key.getX509();
// PublicKeyASP = cert.getPublicKey();
ConnectURL crt = new ConnectURL();
HashMap<String, String> params = new HashMap<>();
System.out.println("PK ASP : "+alias);
params.put("usr", alias);
Gson gs = new Gson();
String jsonReturn = crt.connectHTTP(url+"/getpublickey", params);
System.out.println("JSON ASP : "+jsonReturn);
Response res = gs.fromJson(jsonReturn, Response.class);
PublicKey PublicKeyASP = null;
if(res.getKode().equals("PUB01")){
X509 x509 = new X509(res.getKoten());
X509Certificate cert = x509.getX509();
PublicKeyASP = cert.getPublicKey();
System.out.println("Public Key ASP : "+PublicKeyASP);
}
return PublicKeyASP;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment