26 |
26 |
27 import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithm; |
27 import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithm; |
28 import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException; |
28 import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException; |
29 |
29 |
30 /** |
30 /** |
31 * @author raul |
|
32 * |
31 * |
33 */ |
32 */ |
34 public class SignerOutputStream extends ByteArrayOutputStream { |
33 public class SignerOutputStream extends ByteArrayOutputStream { |
35 private static java.util.logging.Logger log = |
34 private static final com.sun.org.slf4j.internal.Logger LOG = |
36 java.util.logging.Logger.getLogger(SignerOutputStream.class.getName()); |
35 com.sun.org.slf4j.internal.LoggerFactory.getLogger(SignerOutputStream.class); |
37 |
36 |
38 final SignatureAlgorithm sa; |
37 final SignatureAlgorithm sa; |
39 |
38 |
40 /** |
39 /** |
41 * @param sa |
40 * @param sa |
42 */ |
41 */ |
43 public SignerOutputStream(SignatureAlgorithm sa) { |
42 public SignerOutputStream(SignatureAlgorithm sa) { |
44 this.sa = sa; |
43 this.sa = sa; |
45 } |
44 } |
46 |
45 |
47 /** @inheritDoc */ |
46 /** {@inheritDoc} */ |
48 public void write(byte[] arg0) { |
47 public void write(byte[] arg0) { |
49 try { |
48 try { |
50 sa.update(arg0); |
49 sa.update(arg0); |
51 } catch (XMLSignatureException e) { |
50 } catch (XMLSignatureException e) { |
52 throw new RuntimeException("" + e); |
51 throw new RuntimeException("" + e); |
53 } |
52 } |
54 } |
53 } |
55 |
54 |
56 /** @inheritDoc */ |
55 /** {@inheritDoc} */ |
57 public void write(int arg0) { |
56 public void write(int arg0) { |
58 try { |
57 try { |
59 sa.update((byte)arg0); |
58 sa.update((byte)arg0); |
60 } catch (XMLSignatureException e) { |
59 } catch (XMLSignatureException e) { |
61 throw new RuntimeException("" + e); |
60 throw new RuntimeException("" + e); |
62 } |
61 } |
63 } |
62 } |
64 |
63 |
65 /** @inheritDoc */ |
64 /** {@inheritDoc} */ |
66 public void write(byte[] arg0, int arg1, int arg2) { |
65 public void write(byte[] arg0, int arg1, int arg2) { |
67 if (log.isLoggable(java.util.logging.Level.FINE)) { |
66 if (LOG.isDebugEnabled()) { |
68 log.log(java.util.logging.Level.FINE, "Canonicalized SignedInfo:"); |
67 LOG.debug("Canonicalized SignedInfo:"); |
69 StringBuilder sb = new StringBuilder(arg2); |
68 StringBuilder sb = new StringBuilder(arg2); |
70 for (int i = arg1; i < (arg1 + arg2); i++) { |
69 for (int i = arg1; i < (arg1 + arg2); i++) { |
71 sb.append((char)arg0[i]); |
70 sb.append((char)arg0[i]); |
72 } |
71 } |
73 log.log(java.util.logging.Level.FINE, sb.toString()); |
72 LOG.debug(sb.toString()); |
74 } |
73 } |
75 try { |
74 try { |
76 sa.update(arg0, arg1, arg2); |
75 sa.update(arg0, arg1, arg2); |
77 } catch (XMLSignatureException e) { |
76 } catch (XMLSignatureException e) { |
78 throw new RuntimeException("" + e); |
77 throw new RuntimeException("" + e); |