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