Clover Coverage Report - Implementation 2.0.0-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
../../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
13   65   6   3.25
4   34   0.46   4
4     1.5  
1    
 
  ResponseHeaderDigitalSigner       Line # 32 13 0% 6 21 0% 0.0
 
No Tests
 
1    /*
2    * Copyright 2005-2007 The Kuali Foundation
3    *
4    *
5    * Licensed under the Educational Community License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    *
9    * http://www.opensource.org/licenses/ecl2.php
10    *
11    * Unless required by applicable law or agreed to in writing, software
12    * distributed under the License is distributed on an "AS IS" BASIS,
13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    * See the License for the specific language governing permissions and
15    * limitations under the License.
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    * A DigitalSinger which places the alias and digital signature into the response headers of an HttpServletResponse.
29    *
30    * @author Kuali Rice Team (rice.collab@kuali.org)
31    */
 
32    public class ResponseHeaderDigitalSigner extends AbstractDigitalSigner {
33   
34    private String alias;
35    private Certificate certificate;
36    private HttpServletResponse response;
37   
 
38  0 toggle public ResponseHeaderDigitalSigner(Signature signature, String alias, HttpServletResponse response) {
39  0 super(signature);
40  0 this.alias = alias;
41  0 this.response = response;
42    }
43   
 
44  0 toggle public ResponseHeaderDigitalSigner(Signature signature, String alias, Certificate certificate, HttpServletResponse response) {
45  0 this(signature, alias, response);
46  0 this.certificate = certificate;
47    }
48   
 
49  0 toggle public ResponseHeaderDigitalSigner(Signature signature, Certificate certificate, HttpServletResponse response) {
50  0 super(signature);
51  0 this.certificate = certificate;
52  0 this.response = response;
53    }
54   
 
55  0 toggle 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    }
64   
65    }