How to use JDBC scope in embedded Glassfish

I am using the built-in Glassfish (org.glassfish.main.extras: glassfish-embedded-all: 3.1.2.2) and tried to add a JDBC scope. The application deploys normally, but when you try to log in (Basic auth. Shows the correct domain name), the following message appears:

com.sun.web.security.RealmAdapter authenticate WARNING: WEB9102: web login failure: com.sun.enterprise.security.auth.login.common.LoginException: login failure: no input modules configured for jdbcRealm

My code is as follows:

integrated glassfish

// create-jdbc-connection-pool ...    
// create-jdbc-resource ...

String realmProperties = "jaas-context=jdbcRealm:datasource-jndi=jdbc/myDB:user-table=Users:user-name-column=userid:password-column=password:group-table=Groups:group-name-column=groupid;

glassfish.getCommandRunner().run("create-auth-realm", "--classname", "com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm", "--property", realmProperties, myRealm);

web.xml deployed application

<login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>myRealm</realm-name>
</login-config>

I thought that if nothing is specified, then the LoginModule is used by default (which, in the case of not deployed Glassfish, is specified in the / conf / login.conf domain)

+5
1

, , , . , . , secure-admin , . , , , , .

: , - - Oo.

, , , . EJBContainer.createEJBContainer(props); EJBContainer, , . :

Map<String, Object> props = new HashMap<String, Object>();
props.put("org.glassfish.ejb.embedded.glassfish.instance.root", "./src/test/resources/testing-domain");

. Glassfish 3.1.2.2. , , :

testing-domain
    config
        admin-keyfile
        cacerts.jks
        domain.xml (there u can define the security-realm)
        keyfile
        keystore.jks
        logging.properties
        login.conf
        server.policy
        wss-server-config-1.0.xml
        wss-server-config-2.0.xml

GlassFishRuntime.bootstrap().newGlassFish(glassfishProperties);, domain.xml :

GlassFishProperties glassfishProperties = new GlassFishProperties();
File configFile = new File("src/test/resources/META-INF", "domain.xml");
glassfishProperties.setConfigFileURI(configFile.toURI().toString());

, , , glassfish. domain.xml .

domain.xml <security-service> - :

<auth-realm name="JDBC-AccountRealm" classname="com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm">
    <property name="jaas-context" value="jdbcRealm"></property>
    <property name="password-column" value="PASSWORD"></property>
    <property name="datasource-jndi" value="jdbc/__default"></property>
    <property name="group-table" value="ACCOUNT_GROUP"></property>
    <property name="user-table" value="ACCOUNT"></property>
    <property name="group-name-column" value="GROUPS"></property>
    <property name="group-table-user-name-column" value="EMAIL"></property>
    <property name="user-name-column" value="EMAIL"></property>
    <property name="digest-algorithm" value="SHA-256"></property>
    <property name="encoding" value="Hex"></property>
</auth-realm>

, , ?; D

. LoginModules login.conf, .

2: , myRealm ( ) ​​ ? β†’ 'glassfish.getCommandRunner(). run ( "create-auth-realm", "--classname", "com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm", "--property", realmProperties, myRealm);

0

All Articles