<?xml version="1.0" encoding="UTF-8"?>
<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->

<!-- @version $Rev$ $Date$ -->

<application xmlns="http://geronimo.apache.org/xml/ns/j2ee/application-2.0">

    <environment xmlns="http://geronimo.apache.org/xml/ns/deployment-1.2">
        <moduleId>
            <groupId>org.apache.geronimo.testsuite</groupId>
            <artifactId>jca-cms-ear</artifactId>
            <version>2.2-SNAPSHOT</version>
            <type>ear</type>
        </moduleId>
        <dependencies>
            <dependency>
                <groupId>org.apache.geronimo.configs</groupId>
                <artifactId>system-database</artifactId>
                <type>car</type>
            </dependency>
        </dependencies>
    </environment>

    <module>
        <connector>tranql.rar</connector>
        <connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2">
            <resourceadapter>
                <outbound-resourceadapter>
                    <connection-definition>
                        <connectionfactory-interface>javax.sql.DataSource</connectionfactory-interface>
                        <connectiondefinition-instance>
                            <name>cmsds</name>
                            <!--<config-property-setting name="UserName"></config-property-setting>-->
                            <!--<config-property-setting name="Password"></config-property-setting>-->
                            <config-property-setting name="DatabaseName">TestDatabase</config-property-setting>
                            <config-property-setting name="CreateDatabase">false</config-property-setting>
                            <connectionmanager>
                                <container-managed-security/>
                                <xa-transaction>
                                    <transaction-caching/>
                                </xa-transaction>
                                <single-pool>
                                    <max-size>10</max-size>
                                    <blocking-timeout-milliseconds>5000</blocking-timeout-milliseconds>
                                    <select-one-assume-match/>
                                </single-pool>
                            </connectionmanager>
                        </connectiondefinition-instance>
                        <connectiondefinition-instance>
                            <name>configuredsecurityds</name>
                            <config-property-setting name="UserName">system</config-property-setting>
                            <config-property-setting name="Password">manager</config-property-setting>
                            <config-property-setting name="DatabaseName">TestDatabase</config-property-setting>
                            <config-property-setting name="CreateDatabase">true</config-property-setting>
                            <connectionmanager>
                                <xa-transaction>
                                    <transaction-caching/>
                                </xa-transaction>
                                <single-pool>
                                    <max-size>10</max-size>
                                    <blocking-timeout-milliseconds>5000</blocking-timeout-milliseconds>
                                    <select-one-assume-match/>
                                </single-pool>
                            </connectionmanager>
                        </connectiondefinition-instance>
                    </connection-definition>
                </outbound-resourceadapter>
            </resourceadapter>
            <gbean name="test-cms-realm" class="org.apache.geronimo.security.realm.GenericSecurityRealm">
                <attribute name="realmName">test-cms-realm</attribute>
                <xml-reference name="LoginModuleConfiguration" xmlns:lc="http://geronimo.apache.org/xml/ns/loginconfig-1.1">
                    <lc:login-config>
                        <lc:login-module-ref control-flag="REQUIRED">
                            <lc:pattern>
                                <name xmlns="http://geronimo.apache.org/xml/ns/deployment-1.2">test-cms-credentials
                                </name>
                            </lc:pattern>
                        </lc:login-module-ref>
                        <lc:login-module control-flag="REQUIRED" wrap-principals="false">
                            <lc:login-domain-name>test-app-credentials</lc:login-domain-name>
                            <lc:login-module-class>org.apache.geronimo.security.realm.providers.PropertiesFileLoginModule</lc:login-module-class>
                            <lc:option name="usersURI">var/security/demo_users.properties</lc:option>
                            <lc:option name="groupsURI">var/security/demo_groups.properties</lc:option>
                        </lc:login-module>
                    </lc:login-config>
                </xml-reference>
                <reference name="ServerInfo">
                    <name>ServerInfo</name>
                </reference>
            </gbean>
            <gbean name="test-cms-credentials"
                   class="org.apache.geronimo.connector.outbound.security.PasswordCredentialLoginModuleWrapperGBean">
                <attribute name="loginModuleClass">
                    org.apache.geronimo.connector.outbound.security.CallerIdentityPasswordCredentialLoginModule
                </attribute>
                <reference name="ManagedConnectionFactoryWrapper">
                    <name>cmsds</name>
                </reference>
                <attribute name="loginDomainName">test-cms-credentials</attribute>
            </gbean>
        </connector>
    </module>

    <module>
        <web>web.war</web>
        <web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-2.0">
            <security-realm-name>test-cms-realm</security-realm-name>
            <security xmlns="http://geronimo.apache.org/xml/ns/security-2.0">
                <credential-store-ref>
                    <name xmlns="http://geronimo.apache.org/xml/ns/deployment-1.2">test-credential-store</name>
                </credential-store-ref>
                <default-subject>
                    <realm>test-cms-realm</realm>
                    <id>test</id>
                </default-subject>
                <role-mappings>
                    <role role-name="test">
                        <principal class="org.apache.geronimo.connector.outbound.security.ResourcePrincipal" name="george"/>
                    </role>
                    <role role-name="fail">
                        <run-as-subject>
                            <realm>test-cms-realm</realm>
                            <id>fail</id>
                        </run-as-subject>
                    </role>
                </role-mappings>
            </security>
        </web-app>
    </module>

</application>
