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
12   68   6   4
4   37   0.5   3
3     2  
1    
 
  SignatureSigningResponseWrapper       Line # 35 12 0% 6 19 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.io.IOException;
20    import java.io.PrintWriter;
21    import java.security.Signature;
22   
23    import javax.servlet.ServletOutputStream;
24    import javax.servlet.http.HttpServletResponse;
25    import javax.servlet.http.HttpServletResponseWrapper;
26   
27    import org.kuali.rice.ksb.service.KSBServiceLocator;
28   
29    /**
30    * An HttpServletResponseWrapper which wraps the underlying response's OutputStream in a
31    * SignatureSingingOutputStream which will generate a digital signature for the outgoing message.
32    *
33    * @author Kuali Rice Team (rice.collab@kuali.org)
34    */
 
35    public class SignatureSigningResponseWrapper extends HttpServletResponseWrapper {
36   
37    private DigitalSigner signer;
38    private ServletOutputStream outputStream;
39    private PrintWriter writer;
40   
 
41  0 toggle public SignatureSigningResponseWrapper(HttpServletResponse response) {
42  0 super(response);
43  0 try {
44  0 Signature signature = KSBServiceLocator.getDigitalSignatureService().getSignatureForSigning();
45  0 String alias = KSBServiceLocator.getJavaSecurityManagementService().getModuleKeyStoreAlias();
46  0 this.signer = new ResponseHeaderDigitalSigner(signature, alias, response);
47    } catch (Exception e) {
48  0 throw new RuntimeException("Failed to initialize digital signature verification.", e);
49    }
50    }
51   
 
52  0 toggle @Override
53    public ServletOutputStream getOutputStream() throws IOException {
54  0 if (this.outputStream == null) {
55  0 this.outputStream = new SignatureSigningOutputStream(this.signer, super.getOutputStream(), true);
56    }
57  0 return this.outputStream;
58    }
59   
 
60  0 toggle @Override
61    public PrintWriter getWriter() throws IOException {
62  0 if (this.writer == null) {
63  0 this.writer = new PrintWriter(getOutputStream());
64    }
65  0 return this.writer;
66    }
67   
68    }