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 javax.servlet.http.HttpServletResponse; |
22 | |
|
23 | |
import org.apache.commons.lang.StringUtils; |
24 | |
import org.kuali.rice.ksb.util.KSBConstants; |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
public class ResponseHeaderDigitalSigner extends AbstractDigitalSigner { |
32 | |
|
33 | |
private String alias; |
34 | |
private Certificate certificate; |
35 | |
private HttpServletResponse response; |
36 | |
|
37 | |
public ResponseHeaderDigitalSigner(Signature signature, String alias, HttpServletResponse response) { |
38 | 0 | super(signature); |
39 | 0 | this.alias = alias; |
40 | 0 | this.response = response; |
41 | 0 | } |
42 | |
|
43 | |
public ResponseHeaderDigitalSigner(Signature signature, String alias, Certificate certificate, HttpServletResponse response) { |
44 | 0 | this(signature, alias, response); |
45 | 0 | this.certificate = certificate; |
46 | 0 | } |
47 | |
|
48 | |
public ResponseHeaderDigitalSigner(Signature signature, Certificate certificate, HttpServletResponse response) { |
49 | 0 | super(signature); |
50 | 0 | this.certificate = certificate; |
51 | 0 | this.response = response; |
52 | 0 | } |
53 | |
|
54 | |
public void sign() throws Exception { |
55 | 0 | if (StringUtils.isNotBlank(this.alias) ) { |
56 | 0 | this.response.setHeader(KSBConstants.KEYSTORE_ALIAS_HEADER, this.alias); |
57 | |
} |
58 | 0 | if (this.certificate != null) { |
59 | 0 | this.response.setHeader(KSBConstants.KEYSTORE_CERTIFICATE_HEADER, getEncodedCertificate(this.certificate)); |
60 | |
} |
61 | 0 | this.response.setHeader(KSBConstants.DIGITAL_SIGNATURE_HEADER, getEncodedSignature()); |
62 | 0 | } |
63 | |
|
64 | |
} |