realm.setName(data.getName());
realm.setClass1("org.apache.geronimo.security.realm.GenericSecurityRealm");
AttributeType realmName = realm.addNewAttribute();
realmName.setName("realmName");
realmName.setStringValue(data.getName());
ReferenceType serverInfo = realm.addNewReference();
serverInfo.setName2("ServerInfo");
serverInfo.setName((String) PortletManager.getNameFor(request, PortletManager.getCurrentServer(request).getServerInfo()).getName().get("name"));
ReferenceType loginService = realm.addNewReference();
loginService.setName2("LoginService");
loginService.setName((String) PortletManager.getNameFor(request, PortletManager.getCurrentServer(request).getLoginService()).getName().get("name"));
XmlAttributeType config = realm.addNewXmlReference();
// Construct the content to put in the XmlAttributeType
GerLoginConfigDocument lcDoc = GerLoginConfigDocument.Factory.newInstance();
GerLoginConfigType login = lcDoc.addNewLoginConfig();
for (int i = 0; i < data.getModules().length; i++) {