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 | 0 | super(signature); |
40 | 0 | this.alias = alias; |
41 | 0 | this.response = response; |
42 | 0 | } |
43 | |
|
44 | |
public ResponseHeaderDigitalSigner(Signature signature, String alias, Certificate certificate, HttpServletResponse response) { |
45 | 0 | this(signature, alias, response); |
46 | 0 | this.certificate = certificate; |
47 | 0 | } |
48 | |
|
49 | |
public ResponseHeaderDigitalSigner(Signature signature, Certificate certificate, HttpServletResponse response) { |
50 | 0 | super(signature); |
51 | 0 | this.certificate = certificate; |
52 | 0 | this.response = response; |
53 | 0 | } |
54 | |
|
55 | |
public void sign() throws Exception { |
56 | 0 | if (StringUtils.isNotBlank(this.alias) ) { |
57 | 0 | this.response.setHeader(KSBConstants.KEYSTORE_ALIAS_HEADER, this.alias); |
58 | |
} |
59 | 0 | if (this.certificate != null) { |
60 | 0 | this.response.setHeader(KSBConstants.KEYSTORE_CERTIFICATE_HEADER, getEncodedCertificate(this.certificate)); |
61 | |
} |
62 | 0 | this.response.setHeader(KSBConstants.DIGITAL_SIGNATURE_HEADER, getEncodedSignature()); |
63 | 0 | } |
64 | |
|
65 | |
} |