Good Day,
I am trying to use the DtdMarshaller to marshal the PolicyConfig to the login-config.xml,
but the attributes are not being set in the XML. I have tried the ObjectModelProvider and
here I am trying the GenericObjectModelProvider.
| public class LoginConfigObjectModelProvider implements GenericObjectModelProvider {
|
| public Object getRoot(Object o, MarshallingContext ctx, String namespaceURI, String
localName) {
| return o;
| }
| public Object getChildren(Object o, MarshallingContext ctx, String namespaceURI,
String localName) {
| if (o instanceof PolicyConfig) {
| if ("application-policy".equals(localName)) {
|
| List<AuthenticationInfo> infos = new ArrayList<AuthenticationInfo>();
| Set<String> keys = ((PolicyConfig) o).getConfigNames();
| for (String name : keys) {
| infos.add(((PolicyConfig) o).get(name));
| }
| return infos;
| }
| }
| return null;
| }
| public Object getAttributeValue(Object o, MarshallingContext ctx, String
namespaceURI, String localName) {
|
| if (o instanceof AuthenticationInfo) {
| if ("name".equals(localName)) {
| return ((AuthenticationInfo) o).getName();
| }
| }
| return null;
| }
|
| public Object getElementValue(Object o, MarshallingContext ctx, String namespaceURI,
String localName) {
| return null;
| }
| }
|
| 13:46:37,358 WARN @main [JBossEntityResolver] Cannot load publicId from resource:
security_config.dtd
| <?xml version="1.0" encoding="UTF-8"?>
| <!DOCTYPE policy PUBLIC "-//JBoss//DTD JBOSS Security Config 3.0//EN"
"http://www.jboss.org/j2ee/dtd/security_config.dtd">
|
| <policy>
| <application-policy></application-policy>
| <application-policy></application-policy>
| <application-policy></application-policy>
| <application-policy></application-policy>
| <application-policy></application-policy>
| <application-policy></application-policy>
| <application-policy></application-policy>
| <application-policy></application-policy>
| <application-policy></application-policy>
| <application-policy></application-policy>
| <application-policy></application-policy>
| <application-policy></application-policy>
| </policy>
|
| StringWriter xmlOutput = new StringWriter();
|
| System.setProperty(Marshaller.PROP_MARSHALLER, DtdMarshaller.class.getName());
|
| AbstractMarshaller marshaller = (AbstractMarshaller) Marshaller.FACTORY
| .getInstance();
|
| marshaller.mapPublicIdToSystemId("-//JBoss//DTD JBOSS Security Config
3.0//EN", "http://www.jboss.org/j2ee/dtd/security_config.dtd");
| LoginConfigObjectModelProvider provider = new LoginConfigObjectModelProvider();
| marshaller.marshal(
| "http://www.jboss.org/j2ee/dtd/security_config.dtd",
| provider,
| config,
| xmlOutput);
|
| System.out.println(xmlOutput.getBuffer());
|
Regards,
Mark P Ashworth
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3968343#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...