1

I'm using htmlunit to do some browser testing of my application. As part of that, I'd like to compare the contents of the screen to what the apps service layer returns. I'm using Wildfly 8, Java 7, and annotations. I'm running htmlunit through Eclipse. I'm storing passwords in my database using MD5 and base64. I can log into the app through the website just fine using my JAAS module, but when I try to run my tests, I get JBAS013323: Invalid User.

Here's the relevant files.

jboss-ejb-client.properties

remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=localhost
remote.connection.default.port=8080
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=true
remote.connection.default.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS=JBOSS-LOCAL-USER
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT=false
remote.connection.default.username=mywildflyusername
remote.connection.default.password=password

jndi.properties

java.naming.factory.url.pkgs=org.jboss.ejb.client.naming
java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory
java.naming.provider.url=http-remoting://localhost:8080
java.naming.security.principal=myappusername
java.naming.security.credentials=password
java.naming.security.authentication=simple
jboss.naming.client.ejb.context=true

excerpts from standalone.xml. For http-remoting-connector, I've tried ApplicationRealm, CampaignerRealm and CampaignerJaasRealm with no luck.

     <security-realms>
        <security-realm name="CampaignerRealm">
            <authentication>
                <properties path="campaigner-users.properties" relative-to="jboss.server.config.dir"/>
            </authentication>
            <authorization>
                <properties path="campaigner-groups.properties" relative-to="jboss.server.config.dir"/>
            </authorization>
        </security-realm>
        <security-realm name="CampaignerJaasRealm">
            <authentication>
                <jaas name="campaigner-policy"/>
            </authentication>
        </security-realm>
        <security-realm name="ApplicationRealm">
            <authentication>
                <local default-user="$local" allowed-users="*" skip-group-loading="true"/>
                <properties path="application-users.properties" relative-to="jboss.server.config.dir"/>
            </authentication>
            <authorization>
                <properties path="application-roles.properties" relative-to="jboss.server.config.dir"/>
            </authorization>
        </security-realm>
    </security-realms>
    <subsystem xmlns="urn:jboss:domain:ejb3:2.0">
        <default-security-domain value="campaigner-policy"/>
    </subsystem>
    <subsystem xmlns="urn:jboss:domain:remoting:2.0">
        <endpoint worker="default"/>
        <http-connector name="http-remoting-connector" connector-ref="default" security-realm="ApplicationRealm"/>
    </subsystem>
    <subsystem xmlns="urn:jboss:domain:security:1.2">
        <security-domains>
            <security-domain name="campaigner-policy" cache-type="default">
                <authentication>
                    <login-module code="Database" flag="required">
                        <module-option name="dsJndiName" value="java:/jdbc/CampaignerDS"/>
                        <module-option name="principalsQuery" value="SELECT ..."/>
                        <module-option name="hashAlgorithm" value="MD5"/>
                        <module-option name="hashEncoding" value="base64"/>
                        <module-option name="rolesQuery" value="SELECT ..."/>
                    </login-module>
                </authentication>
            </security-domain>
        </security-domains>
    </subsystem>

The EJB method:

@Transactional
@EnableTransactionManagement
@TransactionManagement(value = TransactionManagementType.CONTAINER)
@TransactionAttribute(value = TransactionAttributeType.REQUIRED)
@Stateless
@Interceptors(SpringBeanAutowiringInterceptor.class)
@DeclareRoles("Security Admin")
public class SecurityServiceBean extends AbstractCampaignerServiceImpl implements
    SecurityServiceLocal, SecurityServiceRemote
{
  @Override
  @RolesAllowed("Security Admin")
  public QueryResults<UserRegistrationQueryResult> find(
    UserRegistrationResultQuery query) throws ApplicationException
  {
  }
}

What am I missing?

Gary Kephart
  • 4,860
  • 5
  • 39
  • 52

0 Answers0