1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ksb.security;
17
18 import java.security.Signature;
19 import java.security.cert.Certificate;
20
21 import org.apache.commons.codec.binary.Base64;
22
23
24
25
26
27
28
29 public abstract class AbstractDigitalSigner implements DigitalSigner {
30
31 private Signature signature;
32
33 public AbstractDigitalSigner(Signature signature) {
34 this.signature = signature;
35 }
36
37 public Signature getSignature() {
38 return this.signature;
39 }
40
41 protected byte[] getSignatureBytes() throws Exception {
42 return getSignature().sign();
43 }
44
45 protected String getEncodedSignature() throws Exception {
46 return new String(Base64.encodeBase64(getSignatureBytes()), "UTF-8");
47 }
48
49 protected String getEncodedCertificate(Certificate certificate) throws Exception {
50 return new String(Base64.encodeBase64(certificate.getEncoded()), "UTF-8");
51 }
52
53 }