in jaas/jaas-config/src/main/java/org/apache/servicemix/kernel/jaas/config/impl/ConfigParser.java [46:101]
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
String name = element.getAttribute("name");
if (name == null || name.length() == 0) {
name = element.getAttribute("id");
}
builder.addPropertyValue("name", name);
String rank = element.getAttribute("rank");
if (rank != null && rank.length() > 0) {
builder.addPropertyValue("rank", Integer.parseInt(rank));
}
List childElements = DomUtils.getChildElementsByTagName(element, "module");
if (childElements != null && childElements.size() > 0) {
ManagedList children = new ManagedList(childElements.size());
for (int i = 0; i < childElements.size(); ++i) {
Element childElement = (Element) childElements.get(i);
BeanDefinitionBuilder bd = BeanDefinitionBuilder.genericBeanDefinition(Module.class);
bd.addPropertyValue("className", childElement.getAttribute("className"));
if (childElement.getAttribute("flags") != null) {
bd.addPropertyValue("flags", childElement.getAttribute("flags"));
}
String options = DomUtils.getTextValue(childElement);
if (options != null && options.length() > 0) {
Properties props = new Properties();
try {
props.load(new ByteArrayInputStream(options.getBytes()));
} catch (IOException e) {
throw new IllegalStateException("Can not load options for JAAS module "
+ childElement.getAttribute("className") + " in config " + name);
}
bd.addPropertyValue("options", props);
}
children.add(bd.getBeanDefinition());
}
builder.addPropertyValue("modules", children);
}
// Publish to OSGi
String publish = element.getAttribute("publish");
if (Boolean.valueOf(publish)) {
// Publish Config
BeanDefinitionBuilder bd = BeanDefinitionBuilder.genericBeanDefinition(OsgiServiceFactoryBean.class);
bd.addPropertyValue("target", builder.getBeanDefinition());
bd.addPropertyValue("interfaces", new Class[] { JaasRealm.class });
Map<String,String> props = new HashMap<String,String>();
props.put(ProxyLoginModule.PROPERTY_MODULE, name);
bd.addPropertyValue("serviceProperties", props);
BeanDefinition def = bd.getBeanDefinition();
String id = parserContext.getReaderContext().generateBeanName(def);
BeanDefinitionHolder holder = new BeanDefinitionHolder(def, id);
registerBeanDefinition(holder, parserContext.getRegistry());
if (shouldFireEvents()) {
BeanComponentDefinition componentDefinition = new BeanComponentDefinition(holder);
postProcessComponentDefinition(componentDefinition);
parserContext.registerComponent(componentDefinition);
}
}
}