| 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.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 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
@author |
| 34 |
|
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 6 |
Complexity Density: 0.5 |
|
| 35 |
|
public class SignatureSigningResponseWrapper extends HttpServletResponseWrapper { |
| 36 |
|
|
| 37 |
|
private DigitalSigner signer; |
| 38 |
|
private ServletOutputStream outputStream; |
| 39 |
|
private PrintWriter writer; |
| 40 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 41 |
0
|
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 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 52 |
0
|
@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 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 60 |
0
|
@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 |
|
} |