Skip to content

Commit

Permalink
Add Elytron configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
jimma committed Dec 20, 2016
1 parent 008936f commit 85b90a4
Show file tree
Hide file tree
Showing 4 changed files with 210 additions and 1 deletion.
88 changes: 88 additions & 0 deletions modules/testsuite/cxf-tests/pom.xml
Expand Up @@ -376,6 +376,94 @@
</plugins>
</build>
</profile>
<profile>
<id>elytron</id>
<activation>
<property>
<name>elytron</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<executions>
<execution>
<id>elytron-testsuite-default</id>
<phase>pre-integration-test</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>${basedir}/src/test/scripts/jbws-testsuite-default-elytron.groovy</source>
<properties>
<inputFile>${jboss.home}/standalone/configuration/standalone-elytron.xml</inputFile>
<outputFile>${jboss.home}/standalone/configuration/jbws-testsuite-default.xml</outputFile>
<serverLog>jbws-testsuite-default.log</serverLog>
<usersPropFile>${project.build.directory}/test-classes/jbossws-users.properties</usersPropFile>
<rolesPropFile>${project.build.directory}/test-classes/jbossws-roles.properties</rolesPropFile>
<keystorePath>${project.build.directory}/test-classes/test.keystore</keystorePath>
<testResourcesDir>${project.build.directory}/test-resources</testResourcesDir>
</properties>
</configuration>
</execution>
<!--execution>
<id>testsuite-ssl-mutual-auth</id>
<phase>pre-integration-test</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>${basedir}/src/test/scripts/jbws-testsuite-ssl-mutual-auth-elytron.groovy</source>
<properties>
<inputFile>${jboss.home}/standalone/configuration/standalone-elytron.xml</inputFile>
<outputFile>${jboss.home}/standalone/configuration/jbws-testsuite-ssl-mutual-auth.xml</outputFile>
<serverLog>jbws-testsuite-ssl-mutual-auth.log</serverLog>
<keystorePath>${project.build.directory}/test-classes/test.keystore</keystorePath>
<truststorePath>${project.build.directory}/test-classes/test.truststore</truststorePath>
</properties>
</configuration>
</execution>
<execution>
<id>testsuite-default-config-tests</id>
<phase>pre-integration-test</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>${basedir}/src/test/scripts/jbws-testsuite-default-config-tests-elytron.groovy</source>
<properties>
<inputFile>${jboss.home}/standalone/configuration/standalone-elytron.xml</inputFile>
<outputFile>${jboss.home}/standalone/configuration/jbws-testsuite-default-config-tests.xml</outputFile>
<serverLog>jbws-testsuite-default-config-tests.log</serverLog>
</properties>
</configuration>
</execution>
<execution>
<id>testsuite-jms</id>
<phase>pre-integration-test</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>${basedir}/src/test/scripts/jbws-testsuite-jms-${jbossws.integration.target}.groovy</source>
<properties>
<inputFile>${jboss.home}/standalone/configuration/standalone-full.xml</inputFile>
<outputFile>${jboss.home}/standalone/configuration/jbws-testsuite-jms-${jbossws.integration.target}.xml</outputFile>
<serverLog>jbws-testsuite-jms.log</serverLog>
<srcUsersProperties>${project.build.directory}/test-classes/jbws-application-users.properties</srcUsersProperties>
<destUsersProperties>${jboss.home}/standalone/configuration/jbws-application-users.properties</destUsersProperties>
<srcRolesProperties>${project.build.directory}/test-classes/jbws-application-roles.properties</srcRolesProperties>
<destRolesProperties>${jboss.home}/standalone/configuration/jbws-application-roles.properties</destRolesProperties>
</properties>
</configuration>
</execution-->
</executions>
</plugin>
</plugins>
</build>
</profile>

</profiles>

Expand Down
@@ -1,2 +1,4 @@
# A sample users.properties file for use with the UsersRolesLoginModule
kermit=thefrog
#Elytron requires this
#$REALM_NAME=JBOSSWS$ This line is used by the add-user utility to identify the realm name already used in this file.
kermit=thefrog
@@ -1 +1,2 @@
#$REALM_NAME=ws-basic-domain$ This line is used by the add-user utility to identify the realm name already used in this file.
jbossws=jbossws
@@ -0,0 +1,118 @@
def root = new XmlParser().parse(project.properties['inputFile'])

/**
* Fix logging: optionally remove CONSOLE handler and set a specific log file
*
*/

def logHandlers = root.profile.subsystem.'root-logger'.handlers[0]
def consoleHandler = logHandlers.find{it.@name == 'CONSOLE'}
if (!project.properties['enableServerLoggingToConsole']) logHandlers.remove(consoleHandler)
def file = root.profile.subsystem.'periodic-rotating-file-handler'.file[0]
file.attributes()['path'] = project.properties['serverLog']

/**
* Add a security-domain block like this:
*
* <subsystem xmlns="urn:wildfly:elytron:1.0">
* <security-domains>
* <security-domain name="JBossWS" default-realm="JBossWS" permission-mapper="login-permission-mapper" role-mapper="combined-role-mapper">
* <realm name="JBossWS" role-decoder="groups-to-roles"/>
* </security-domain>
* <security-domain name="ws-basic-domain" default-realm="ws-basic-domain" permission-mapper="login-permission-mapper" role-mapper="combined-role-mapper">
* <realm name="ws-basic-domain" role-decoder="groups-to-roles"/>
* </security-domain>
* </security-domains>
*
*
*/

def securityDomains = root.profile.subsystem.'security-domains'[0]
def securityDomain = securityDomains.appendNode('security-domain', ['name':'JBossWS','default-realm':'JBossWS','permission-mapper':'login-permission-mapper','role-mapper':'combined-role-mapper'])
def realm = securityDomain.appendNode('realm',['name':'JBossWS','role-decoder':'groups-to-roles'])

def basicsecurityDomain = securityDomains.appendNode('security-domain', ['name':'ws-basic-domain','default-realm':'ws-basic-domain','permission-mapper':'login-permission-mapper','role-mapper':'combined-role-mapper'])
def basicrealm = basicsecurityDomain.appendNode('realm',['name':'ws-basic-domain','role-decoder':'groups-to-roles'])


/**
* <security-realms>
* <properties-realm name="JBossWS">
* <users-properties path="/mnt/ssd/jbossws/stack/cxf/trunk/modules/testsuite/cxf-tests/target/test-classes/jbossws-users.properties"/>
* <groups-properties path="application-roles.properties" relative-to="jboss.server.config.dir"/>
* </properties-realm>
* <properties-realm name="ws-basic-domain">
* <users-properties path="/mnt/ssd/jbossws/stack/cxf/trunk/modules/testsuite/cxf-tests/target/test-classes/ws-users.properties"/>
* <groups-properties path="application-roles.properties"/>
* </properties-realm>
* </security-realms>
*
*
*/
def securityRealms = root.profile.subsystem.'security-realms'[0]
def propertiesRealm = securityRealms.appendNode('properties-realm', ['name':'JBossWS'])
def usersProperties = propertiesRealm.appendNode('users-properties',['path':project.properties['usersPropFile']])
def groupsProperties = propertiesRealm.appendNode('groups-properties',['path':project.properties['rolesPropFile']])


def basicPropertiesRealm = securityRealms.appendNode('properties-realm', ['name':'ws-basic-domain'])
def basicUsersProperties = basicPropertiesRealm.appendNode('users-properties',['path': project.properties['testResourcesDir'] + '/jaxws/cxf/httpauth/WEB-INF/ws-users.properties'])
def basicGroupsProperties = basicPropertiesRealm.appendNode('groups-properties',['path': project.properties['testResourcesDir'] + '/jaxws/cxf/httpauth/WEB-INF/ws-roles.properties'])




/**
* <http>
* <http-authentication-factory name="JBossWS" http-server-mechanism-factory="global" security-domain="JBossWS">
* <mechanism-configuration>
* <mechanism mechanism-name="BASIC">
* <mechanism-realm realm-name="JBossWS Realm"/>
* </mechanism>
* </mechanism-configuration>
* </http-authentication-factory>
* <http-authentication-factory name="ws-basic-domain" http-server-mechanism-factory="global" security-domain="ws-basic-domain">
* <mechanism-configuration>
* <mechanism mechanism-name="BASIC">
* <mechanism-realm realm-name="ws-basic-domain Realm"/>
* </mechanism>
* </mechanism-configuration>
* </http-authentication-factory>
*
*
*/

def httpAuthen = root.profile.subsystem.'http'[0]
def httpAuthenticationFactory = httpAuthen.appendNode('http-authentication-factory', ['name':'JBossWS','http-server-mechanism-factory':'global', 'security-domain':'JBossWS'])
def mechanismConfiguration = httpAuthenticationFactory.appendNode('mechanism-configuration')
def mechanism = mechanismConfiguration.appendNode('mechanism',['mechanism-name':'BASIC'])
def mechanismRealm=mechanism.appendNode('mechanism-realm',['realm-name':'JBossWS Realm'])


def basicHttpAuthenticationFactory = httpAuthen.appendNode('http-authentication-factory', ['name':'ws-basic-domain','http-server-mechanism-factory':'global', 'security-domain':'ws-basic-domain'])
def basicMechanismConfiguration = basicHttpAuthenticationFactory.appendNode('mechanism-configuration')
def basicMechanism = basicMechanismConfiguration.appendNode('mechanism',['mechanism-name':'BASIC'])
def basicmechanismRealm = basicMechanism.appendNode('mechanism-realm',['realm-name':'ws-basic-domain Realm'])


/**
* <application-security-domains>
* <application-security-domain name="JBossWS" http-authentication-factory="JBossWS"/>
* <application-security-domain name="ws-basic-domain" http-authentication-factory="JBossWS"/>
* </application-security-domains>
*/
def appSecurityDomains = root.profile.subsystem.'application-security-domains'[1]
def appSecurityDomain = appSecurityDomains.appendNode('application-security-domain', ['name':'JBossWS','http-authentication-factory':'JBossWS'])

def basicAppSecurityDomain = appSecurityDomains.appendNode('application-security-domain', ['name':'ws-basic-domain','http-authentication-factory':'ws-basic-domain'])

/**
* Save the configuration to a new file
*/

def writer = new StringWriter()
writer.println('<?xml version="1.0" encoding="UTF-8"?>')
new XmlNodePrinter(new PrintWriter(writer)).print(root)
def f = new File(project.properties['outputFile'])
f.write(writer.toString())

0 comments on commit 85b90a4

Please sign in to comment.