1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package edu.internet2.middleware.shibboleth.common.config.security;
18
19 import java.io.FileInputStream;
20 import java.io.IOException;
21
22 import javax.xml.namespace.QName;
23
24 import org.springframework.beans.FatalBeanException;
25
26
27
28
29 public class FilesystemX509CredentialBeanDefinitionParser extends AbstractX509CredentialBeanDefinitionParser {
30
31
32 public static final QName SCHEMA_TYPE = new QName(SecurityNamespaceHandler.NAMESPACE, "X509Filesystem");
33
34
35 protected byte[] getEncodedCRL(String certCRLContent) {
36 try {
37 FileInputStream ins = new FileInputStream(certCRLContent);
38 byte[] encoded = new byte[ins.available()];
39 ins.read(encoded);
40 return encoded;
41 } catch (IOException e) {
42 throw new FatalBeanException("Unable to read CRL(s) from file " + certCRLContent, e);
43 }
44 }
45
46
47 protected byte[] getEncodedCertificate(String certConfigContent) {
48 try {
49 FileInputStream ins = new FileInputStream(certConfigContent);
50 byte[] encoded = new byte[ins.available()];
51 ins.read(encoded);
52 return encoded;
53 } catch (IOException e) {
54 throw new FatalBeanException("Unable to read certificate(s) from file " + certConfigContent, e);
55 }
56 }
57
58
59 protected byte[] getEncodedPrivateKey(String keyConfigContent) {
60 try {
61 FileInputStream ins = new FileInputStream(keyConfigContent);
62 byte[] encoded = new byte[ins.available()];
63 ins.read(encoded);
64 return encoded;
65 } catch (IOException e) {
66 throw new FatalBeanException("Unable to read private key from file " + keyConfigContent, e);
67 }
68 }
69 }