1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package edu.internet2.middleware.shibboleth.common.config;
19
20 import java.util.List;
21
22 import org.opensaml.Configuration;
23 import org.opensaml.DefaultBootstrap;
24 import org.opensaml.util.resource.Resource;
25 import org.opensaml.xml.XMLConfigurator;
26 import org.opensaml.xml.parse.ParserPool;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29 import org.springframework.beans.factory.InitializingBean;
30
31
32
33
34 public class OpensamlConfigBean implements InitializingBean {
35
36
37 private final Logger log = LoggerFactory.getLogger(OpensamlConfigBean.class);
38
39
40 private List<Resource> configResources;
41
42
43 private ParserPool parserPool;
44
45
46
47
48
49
50 public ParserPool getParserPool() {
51 return parserPool;
52 }
53
54
55
56
57
58
59 public void setParserPool(ParserPool newParserPool) {
60 parserPool = newParserPool;
61 }
62
63
64
65
66
67
68 public OpensamlConfigBean(List<Resource> configs){
69 configResources = configs;
70 }
71
72
73 public void afterPropertiesSet() throws Exception {
74 DefaultBootstrap.bootstrap();
75
76 if(configResources != null && !configResources.isEmpty()){
77 XMLConfigurator configurator = new XMLConfigurator();
78 for(Resource config : configResources){
79 try{
80 log.debug("Loading OpenSAML configuration file: {}", config.getLocation());
81 configurator.load(config.getInputStream());
82 }catch(Exception e){
83 log.error("Unable to load OpenSAML configuration file: " + config.getLocation());
84 }
85 }
86 }
87
88 if (getParserPool() != null) {
89 Configuration.setParserPool(getParserPool());
90 }
91
92 }
93 }