blob: c37afcef73bcc64c92e4ea199ffa8822c23dc066 [file] [log] [blame]
<?xml version="1.0"?>
<!DOCTYPE project [
<!--
Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception, which is available at
https://www.gnu.org/software/classpath/license.html.
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-->
<!ENTITY commonSetup SYSTEM "file:./../../../config/properties.xml">
<!ENTITY commonBuild SYSTEM "file:./../../../config/common.xml">
<!ENTITY commonRun SYSTEM "file:./../../../config/run.xml">
<!ENTITY testProperties SYSTEM "./build.properties">
]>
<project name="LDAPrealmperapp" basedir="." default="usage">
&commonSetup;
&commonBuild;
&commonRun;
&testProperties;
<target name="all">
<antcall target="build"/>
<antcall target="create-ldap-usrgrps" />
<antcall target="setup"/>
<antcall target="deploy"/>
<antcall target="run"/>
<antcall target="unsetup"/>
<antcall target="sslsetup"/>
<antcall target="run"/>
<antcall target="undeploy"/>
<antcall target="delete-ldap-usrgrps" />
<antcall target="sslunsetup"/>
</target>
<target name="plainldaprealm" depends="build, create-ldap-usrgrps, setup, deploy, run, undeploy, delete-ldap-usrgrps, unsetup"/>
<target name="sslldaprealm" depends="build, create-ldap-usrgrps, sslsetup, deploy, run, undeploy, delete-ldap-usrgrps, sslunsetup"/>
<target name="clean" depends="init-common">
<delete dir="${build.classes.dir}"/>
<delete dir="${assemble.dir}"/>
</target>
<target name="setup" depends="init-common">
<property name="directory.server.url" value="ldap://${directory.server.host}:${directory.server.port}"/>
<echo message="directory=${directory.server.url}" file="temp.txt"/>
<replace file="temp.txt" token=":" value="\\:"/>
<loadproperties srcFile="temp.txt"/>
<delete file="temp.txt"/>
<echo message="base-dn=${directory.server.basedn}" file="temp.txt"/>
<replace file="temp.txt" token="dc=" value="dc\\="/>
<loadproperties srcFile="temp.txt"/>
<delete file="temp.txt"/>
<echo message="url=${directory}"/>
<echo message="base-dn=${base-dn}"/>
<antcall target="asadmin-common">
<param name="admin.command" value="create-auth-realm" />
<param name="operand.props" value="--classname com.sun.enterprise.security.auth.realm.ldap.LDAPRealm --property directory=${directory}:base-dn=${base-dn}:jaas-context=ldapRealm:com.sun.jndi.ldap.connect.pool.debug=fine:com.sun.jndi.ldap.connect.pool.maxsize=2 ldap"/>
</antcall>
</target>
<target name="sslsetup" depends="init-common">
<property name="directory.server.sslurl" value="ldaps://${directory.server.host}:${directory.server.sslport}"/>
<echo message="ssldirectory=${directory.server.sslurl}" file="temp.txt"/>
<replace file="temp.txt" token=":" value="\\:"/>
<loadproperties srcFile="temp.txt"/>
<delete file="temp.txt"/>
<echo message="base-dn=${directory.server.basedn}" file="temp.txt"/>
<replace file="temp.txt" token="dc=" value="dc\\="/>
<loadproperties srcFile="temp.txt"/>
<delete file="temp.txt"/>
<echo message="sslurl=${ssldirectory}"/>
<echo message="base-dn=${base-dn}"/>
<antcall target="asadmin-common">
<param name="admin.command" value="create-auth-realm" />
<param name="operand.props" value="--classname com.sun.enterprise.security.auth.realm.ldap.LDAPRealm --property directory=${ssldirectory}:base-dn=${base-dn}:jaas-context=ldapRealm:com.sun.jndi.ldap.connect.pool.debug=fine:com.sun.jndi.ldap.connect.pool.maxsize=2 ldap"/>
</antcall>
</target>
<target name="compile" depends="clean">
<antcall target="compile-common">
<param name="src" value="shopping"/>
</antcall>
<antcall target="compile-common">
<param name="src" value="client"/>
</antcall>
</target>
<target name="build" depends="compile">
<antcall target="build-ear-common"/>
</target>
<target name="deploy" depends="init-common">
<antcall target="deploy-common"/>
</target>
<target name="run" depends="init-common">
<echo message="PASSWORD=j2ee/shingwai" file="${build.classes.dir}/passfile.txt" />
<exec executable="${APPCLIENT}">
<arg line="-client ${assemble.dir}/${appname}AppClient.jar"/>
<arg line="-textauth" />
<arg line="-user j2ee/shingwai"/>
<arg line="-passwordfile ${build.classes.dir}/passfile.txt"/>
</exec>
<delete file="${build.classes.dir}/passfile.txt" />
</target>
<target name="undeploy" depends="init-common">
<antcall target="undeploy-common"/>
</target>
<target name="unsetup" depends="init-common">
<antcall target="asadmin-common">
<param name="admin.command" value="delete-auth-realm" />
<param name="operand.props" value="ldap" />
</antcall>
</target>
<target name="sslunsetup" depends="init-common">
<antcall target="asadmin-common">
<param name="admin.command" value="delete-auth-realm" />
<param name="operand.props" value="ldap" />
</antcall>
</target>
<target name="create-ldap-usrgrps" depends="init-common">
<copy file="${create.ldif.file}" tofile="temp.ldif" overwrite="true" failonerror="false"/>
<echo message="Creating ldap test users and groups at ldap://${directory.server.host}:${directory.server.port}/?${directory.server.basedn}"/>
<antcall target="execute-ldap-ldif">
<param name="ldif.file.path" value="temp.ldif"/>
</antcall>
<echo message="deleting temp file..."/>
<delete file="temp.ldif"/>
</target>
<target name="delete-ldap-usrgrps" depends="init-common">
<copy file="${delete.ldif.file}" tofile="temp.ldif" overwrite="true" failonerror="false"/>
<echo message="Deleting ldap test users and groups at ldap://${directory.server.host}:${directory.server.port}/?${directory.server.basedn}"/>
<antcall target="execute-ldap-ldif">
<param name="ldif.file.path" value="temp.ldif"/>
</antcall>
<echo message="deleting temp file..."/>
<delete file="temp.ldif"/>
</target>
<target name="execute-ldap-ldif" depends="init-common">
<java classname="LDAPModify" fork="true" failonerror="false">
<arg line="-h ${directory.server.host}"/>
<arg line="-p ${directory.server.port}"/>
<arg line="-D &quot;${directory.manager.dn}&quot;"/>
<arg line="-w ${directory.manager.passwd}"/>
<arg line="-f ${ldif.file.path}"/>
<classpath>
<pathelement path="${env.APS_HOME}/lib/ldapjdk.jar"/>
</classpath>
</java>
</target>
<target name="usage">
<antcall target="usage-common"/>
</target>
<target name="restart">
<antcall target="restart-server-instance-common"/>
</target>
</project>