1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.ksb.security;
18
19 import java.security.Signature;
20 import java.security.cert.Certificate;
21
22 import javax.servlet.http.HttpServletResponse;
23
24 import org.apache.commons.lang.StringUtils;
25 import org.kuali.rice.ksb.util.KSBConstants;
26
27
28
29
30
31
32 public class ResponseHeaderDigitalSigner extends AbstractDigitalSigner {
33
34 private String alias;
35 private Certificate certificate;
36 private HttpServletResponse response;
37
38 public ResponseHeaderDigitalSigner(Signature signature, String alias, HttpServletResponse response) {
39 super(signature);
40 this.alias = alias;
41 this.response = response;
42 }
43
44 public ResponseHeaderDigitalSigner(Signature signature, String alias, Certificate certificate, HttpServletResponse response) {
45 this(signature, alias, response);
46 this.certificate = certificate;
47 }
48
49 public ResponseHeaderDigitalSigner(Signature signature, Certificate certificate, HttpServletResponse response) {
50 super(signature);
51 this.certificate = certificate;
52 this.response = response;
53 }
54
55 public void sign() throws Exception {
56 if (StringUtils.isNotBlank(this.alias) ) {
57 this.response.setHeader(KSBConstants.KEYSTORE_ALIAS_HEADER, this.alias);
58 }
59 if (this.certificate != null) {
60 this.response.setHeader(KSBConstants.KEYSTORE_CERTIFICATE_HEADER, getEncodedCertificate(this.certificate));
61 }
62 this.response.setHeader(KSBConstants.DIGITAL_SIGNATURE_HEADER, getEncodedSignature());
63 }
64
65 }