*/
package org.apache.xml.security.signature;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.io.FileInputStream;
}
private void setDigestValueBase64Encoded(String value) {
- this.digestValueBase64Encoded = value;
+ this.digestValueBase64Encoded = value;
}
public String getDigestValueBase64Encoded() {
- return this.digestValueBase64Encoded;
+ return this.digestValueBase64Encoded;
}
/**
}
/*
- * 정성근 선임에 의해 추가되었다.
+ * INFO: this is added by sunggun.jung
*/
public void generateDigestValue(String targetValue)
throws XMLSignatureException, ReferenceNotInitializedException {
- this.setDigestValueElement(targetValue);
+ this.setDigestValueElement(targetValue);
}
mda.reset();
DigesterOutputStream diOs = new DigesterOutputStream(mda);
os = new UnsyncBufferedOutputStream(diOs);
- XMLSignatureInput output = this.dereferenceURIandPerformTransforms(os);
+ XMLSignatureInput output = this.dereferenceURIandPerformTransforms(os);
// if signing and c14n11 property == true explicitly add
// C14N11 transform if needed
if (Reference.useC14N11 && !validating && !output.isOutputStreamSet()
}
/*
- * 정성근 선임에 의해 추가되었다.
+ * INFO: this is added by sunggun.jung
*/
/**
* Method calculateDigest
* @throws XMLSignatureException
*/
public String calculateDigestBase64Endoed(String absoulteUrl) throws IOException {
- String SHA = "";
-
- FileInputStream fis = null;
-
- try{
- MessageDigest sha = MessageDigest.getInstance("SHA-256");
-
- fis = new FileInputStream(absoulteUrl);
-
- byte[] dataBytes = new byte[1024];
-
- int nread = 0;
-
- while ((nread = fis.read(dataBytes)) != -1)
- {
- sha.update(dataBytes, 0, nread);
- }
-
- byte[] shabytes = sha.digest();
-
-// StringBuffer sb = new StringBuffer();
-// for (int i = 0 ; i < shabytes.length ; i++) {
-// sb.append(Integer.toString((shabytes[i]&0xff) + 0x100, 16).substring(1));
-// }
-
-// System.out.println("Hex format : " + sb.toString());
- SHA = Base64.encode(shabytes);
-// System.out.println("Base64 format : " + SHA);
-
- fis.close();
-
- } catch (NoSuchAlgorithmException e) {
- e.printStackTrace();
- SHA = null;
- } finally {
- try {
- if (fis != null) {
- fis.close();
- }
- } catch (IOException ex) {
- if (log.isDebugEnabled()) {
- log.debug(ex);
- }
- }
- }
- return SHA;
+ String SHA = "";
+
+ FileInputStream fis = null;
+
+ try{
+ MessageDigest sha = MessageDigest.getInstance("SHA-256");
+
+ fis = new FileInputStream(absoulteUrl);
+
+ byte[] dataBytes = new byte[1024];
+
+ int nread = 0;
+
+ while ((nread = fis.read(dataBytes)) != -1)
+ {
+ sha.update(dataBytes, 0, nread);
+ }
+
+ byte[] shabytes = sha.digest();
+
+// StringBuffer sb = new StringBuffer();
+// for (int i = 0 ; i < shabytes.length ; i++) {
+// sb.append(Integer.toString((shabytes[i]&0xff) + 0x100, 16).substring(1));
+// }
+
+// System.out.println("Hex format : " + sb.toString());
+ SHA = Base64.encode(shabytes);
+// System.out.println("Base64 format : " + SHA);
+
+ fis.close();
+
+ } catch (NoSuchAlgorithmException e) {
+ e.printStackTrace();
+ SHA = null;
+ } finally {
+ try {
+ if (fis != null) {
+ fis.close();
+ }
+ } catch (IOException ex) {
+ if (log.isDebugEnabled()) {
+ log.debug(ex);
+ }
+ }
+ }
+ return SHA;
}
OutputStream so = null;
try {
// initialize SignatureAlgorithm for signing
- sa.initSign(signingKey);
+ sa.initSign(signingKey);
// generate digest values for all References in this SignedInfo
si.generateDigestValues();
so = new UnsyncBufferedOutputStream(new SignerOutputStream(sa));
// get the canonicalized bytes from SignedInfo
- si.signInOctetStream(so);
+ si.signInOctetStream(so);
} catch (XMLSecurityException ex) {
throw ex;
} finally {
try {
//Create a SignatureAlgorithm object
- SignedInfo si = this.getSignedInfo();
+ SignedInfo si = this.getSignedInfo();
SignatureAlgorithm sa = si.getSignatureAlgorithm();
OutputStream so = null;
try {
// initialize SignatureAlgorithm for signing
- sa.initSign(signingKey);
+ sa.initSign(signingKey);
/*
* INFO: for RDS
*/
// generate digest values for all References in this SignedInfo
try {
- if (isRDS == true)
- si.generateDigestValuesForRDS(dirPath);
- else
- si.generateDigestValuesAndWriteSnapshot(dirPath);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ if (isRDS == true)
+ si.generateDigestValuesForRDS(dirPath);
+ else
+ si.generateDigestValuesAndWriteSnapshot(dirPath);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
so = new UnsyncBufferedOutputStream(new SignerOutputStream(sa));
// get the canonicalized bytes from SignedInfo
- si.signInOctetStream(so);
+ si.signInOctetStream(so);
} catch (XMLSecurityException ex) {
throw ex;
} finally {