Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Adding example of how to get caller's principal from an EJB

  • Loading branch information...
commit b453ac7b72ab87639d920ddca31971d7a21b6e81 1 parent 10a8319
Kyle Lape authored
4 getCallerPrincipalEjb.jar/META-INF/MANIFEST.MF
... ... @@ -0,0 +1,4 @@
  1 +Manifest-Version: 1.0
  2 +Ant-Version: Apache Ant 1.8.2
  3 +Created-By: 1.6.0_37-b06-434-11M3909 (Apple Inc.)
  4 +Dependencies: org.apache.cxf
3  getCallerPrincipalEjb.jar/README.md
Source Rendered
... ... @@ -0,0 +1,3 @@
  1 +### Example of how to get caller's principal in an EJB
  2 +
  3 +This EJB has one method that simply returns the caller's `Principal` via `EJBContext.getCallerPrincipal()`. It's also exposed as a webservice using basic HTTP authentication. The EJB uses the `other` security domain, so you can use the `add-user.sh` script to control access to the EJB.
722 getCallerPrincipalEjb.jar/build.xml
... ... @@ -0,0 +1,722 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!--
  3 +author: Brad Maxwell
  4 +Simplified Build
  5 +version 0.4 May 28, 2010
  6 +Added Help
  7 +Adding custom lib directory in build.properties
  8 +-->
  9 +
  10 +<project name="simplified-build" default="all">
  11 + <!-- ===== PROPERTIES ===== -->
  12 + <property environment="env"/>
  13 + <!-- <basename property="dirName" file="${env.PWD}"/> -->
  14 + <!-- <dirname property="script-dir" file="${ant.file.main}"/> --> <!-- same as env.BUILD_SCRIPTS -->
  15 +
  16 + <basename property="dirName" file="${basedir}"/>
  17 +
  18 + <!-- <available property="unified-build-exists" file="${basedir}/unified-build.xml" value="true"/> -->
  19 + <property name="parentDir" location="${basedir}/.."/>
  20 +
  21 + <property file="build.properties"/> <!-- Include build.properties -->
  22 +
  23 + <!-- environment variables that need to be set -->
  24 + <condition property="jboss-home" value="${JBOSS_HOME}" else="${env.JBOSS_HOME}"><isset property="JBOSS_HOME"/></condition>
  25 +
  26 + <!-- init method will verify they are set -->
  27 +
  28 + <!-- AS7 / EAP6 -->
  29 + <available file="${jboss-home}/modules" property="AS7"/>
  30 +
  31 + <!-- use default if env.JBOSS_PROFILE is not set and not specified in build.properties -->
  32 + <condition property="JBOSS_PROFILE" value="standalone" else="default"><isset property="AS7"/></condition>
  33 +
  34 + <!-- <condition property="jboss-server" value="${JBOSS_PROFILE}" else="${env.JBOSS_PROFILE}"><isset property="JBOSS_PROFILE"/></condition> -->
  35 + <condition property="jboss-server" value="${env.JBOSS_PROFILE}" else="${JBOSS_PROFILE}"><isset property="env.JBOSS_PROFILE"/></condition>
  36 +
  37 +
  38 + <condition property="jboss-server-dir" value="${jboss-home}/${jboss-server}" else="${jboss-home}/server/${jboss-server}"><isset property="AS7"/></condition>
  39 +
  40 + <condition property="jboss-deploy-dir" value="${jboss-server-dir}/deployments/" else="${jboss-server-dir}/deploy/"><isset property="AS7"/></condition>
  41 + <!-- <property name="jboss-endorsed-dir" location="${jboss-home}/lib/endorsed/"/> -->
  42 +
  43 + <condition property="lib" value="${jboss-home}/modules/" else="${jboss-server-dir}/lib"><isset property="AS7"/></condition>
  44 + <property name="ant.project.name" value="${dirName}" />
  45 + <property name="archive.name" value="${dirName}" />
  46 + <property name="dist" value="dist"/>
  47 +
  48 + <condition property="debuglevel" value="${debuglevel}" else="lines,vars,source"><isset property="debuglevel"/></condition>
  49 + <condition property="debug" value="${debug}" else="on"><isset property="debug"/></condition>
  50 +
  51 + <!-- can set property, then use condition value="", if condition is not satisfied, it will not change the property -->
  52 +
  53 + <!-- ===== ARCHIVE-TYPE ===== -->
  54 + <condition property="archive-type" value="jar"><matches string="${dirName}" pattern="^.*\.jar$"/></condition>
  55 + <condition property="archive-type" value="sar"><matches string="${dirName}" pattern="^.*\.sar$"/></condition>
  56 + <condition property="archive-type" value="war"><matches string="${dirName}" pattern="^.*\.war$"/></condition>
  57 + <condition property="archive-type" value="ear"><matches string="${dirName}" pattern="^.*\.ear$"/></condition>
  58 + <condition property="archive-type" value="aop"><matches string="${dirName}" pattern="^.*\.aop$"/></condition>
  59 + <condition property="archive-type" value="beans"><matches string="${dirName}" pattern="^.*\.beans$"/></condition>
  60 +
  61 + <!-- this is the name of the ear/war/jar/... without the extension -->
  62 + <basename property="archive-name" file="${basedir}" suffix=".${archive-type}"/>
  63 +
  64 + <!-- this property checks to see if it is an ear, and if so it will prevent the build target being called on the ear -->
  65 + <condition property="build" value="true">
  66 + <not><matches string="${archive-type}" pattern="ear"/></not>
  67 + </condition>
  68 +
  69 + <!-- used to determine if ear needs to be packaged -->
  70 + <condition property="ear" value="true">
  71 + <matches string="${archive-type}" pattern="ear"/>
  72 + </condition>
  73 +
  74 +<!--
  75 + <condition property="manifest-class-path" value=""><not><isset property="manifest-class-path"/></not></condition>
  76 +-->
  77 + <condition property="main-class" value=""><not><isset property="main-class"/></not></condition>
  78 +
  79 + <condition property="earLib" value="${parentDir}/lib/" else="">
  80 + <and>
  81 + <matches string="${parentDir}" pattern="^.*\.ear$"/>
  82 + <available file="${parentDir}/lib" type="dir"/>
  83 + </and>
  84 + </condition>
  85 +
  86 + <condition property="apiJarEarLib" value="../" else="">
  87 + <!-- for api-jar in lib dir -->
  88 + <and>
  89 + <!-- <matches string="${parentDir}" pattern="^.*/lib$"/> --> <!-- TODO this doesn't work on win -->
  90 + <matches string="${dirName}" pattern="^.*-api.jar$"/>
  91 + </and>
  92 + </condition>
  93 +
  94 + <condition property="buildPath" value="WEB-INF/classes" else="">
  95 + <matches string="${archive-type}" pattern="^war$"/>
  96 + </condition>
  97 + <condition property="buildPath" value="" else=".">
  98 + <matches string="${archive-type}" pattern="^ear$"/>
  99 + </condition>
  100 +
  101 + <!-- this should be . if in ear or .. if in sub dir -->
  102 + <condition property="ear-sub-archives-dir" value="." else="..">
  103 + <matches string="${archive-type}" pattern="^ear$"/>
  104 + </condition>
  105 + <condition property="ear-lib-dir" value="./lib" else="../lib">
  106 + <matches string="${archive-type}" pattern="^ear$"/>
  107 + </condition>
  108 +
  109 + <condition property="include-build-classpath" value="">
  110 + <not><isset property="include-build-classpath"/></not>
  111 + </condition>
  112 +
  113 + <!-- ===== PATHS / SETS ===== -->
  114 +
  115 + <fileset dir="${basedir}" id="war.package.fileset">
  116 + <exclude name="**/*.java"/>
  117 + <exclude name="dist/"/>
  118 + <exclude name="build.xml"/>
  119 + <exclude name="build.properties"/>
  120 + <exclude name=".*"/>
  121 + </fileset>
  122 +
  123 + <fileset dir="${basedir}" id="jar.package.fileset">
  124 + <exclude name="**/*.java"/>
  125 + <exclude name="bin/"/>
  126 + <exclude name="dist/"/>
  127 + <exclude name="build.xml"/>
  128 + <exclude name="build.properties"/>
  129 + </fileset>
  130 +
  131 + <path id="classpath">
  132 + <!-- <path refid="user-classpath"/> -->
  133 + <pathelement location="${buildPath}" />
  134 +
  135 + <fileset dir="${include-build-classpath}" includes="**/*.jar"/>
  136 +
  137 + <dirset dir="${earLib}">
  138 + <include name="*-api.jar"/>
  139 + </dirset>
  140 +
  141 + <!-- include jar,sar,war buildpaths in classpath -->
  142 + <dirset dir="${ear-sub-archives-dir}">
  143 + <include name="*.jar"/>
  144 + <include name="*.sar"/>
  145 + <include name="*.war/WEB-INF/classes"/>
  146 + </dirset>
  147 +
  148 +<!-- duplicate
  149 + <fileset dir="${ear-sub-archives-dir}">
  150 + <include name="*.jar"/>
  151 + </fileset>
  152 +-->
  153 +
  154 + <fileset dir="${jboss-home}/" includes="common/lib/**/*.jar"/> <!-- eap 5 -->
  155 + <fileset dir="${jboss-home}/" includes="lib/**/*.jar"/>
  156 + <fileset dir="${jboss-home}/" includes="client/**/*.jar"/>
  157 + <fileset dir="${jboss-server-dir}/" includes="lib/**/*.jar"/>
  158 + <fileset dir="${jboss-deploy-dir}/" includes="**/jsf*.jar"/>
  159 + <fileset dir="${jboss-deploy-dir}/" includes="**/portal-*.jar"/>
  160 + <fileset dir="${jboss-deploy-dir}/" includes="**/portlet-*.jar"/>
  161 + <fileset dir="${jboss-deploy-dir}/" includes="*jboss-portal*/**/*.jar"/>
  162 + <fileset dir="${jboss-deploy-dir}/" includes="*ejb3.deployer*/**/*.jar"/>
  163 + <fileset dir="${jboss-server-dir}/" includes="deployers/**/*.jar"/>
  164 +
  165 + <!-- if parent dir is an EAR and contains a lib dir then add to classpath -->
  166 + <fileset dir="${earLib}">
  167 + <type type="file"/>
  168 + <include name="**/*.jar"/>
  169 + </fileset>
  170 + <fileset dir="${apiJarEarLib}">
  171 + <include name="**/*.jar"/>
  172 + </fileset>
  173 +
  174 + <!-- add support for lib declared in build.properties -->
  175 + <fileset dir="${lib}">
  176 + <include name="**/*.jar"/>
  177 + </fileset>
  178 +
  179 + </path>
  180 +
  181 + <!-- =============================== -->
  182 + <path id="ordered-dirs">
  183 + <fileset dir="${basedir}" includes="lib/*-api.jar/build.xml" id="lib-api-dirs"/>
  184 + <fileset dir="${basedir}" includes="lib/*.jar/build.xml" excludes="*-api.jar/build.xml" id="lib-api-dirs2"/>
  185 + <fileset dir="${basedir}" includes="*-api.jar/build.xml" id="api-dirs"/>
  186 + <fileset dir="${basedir}" includes="*.jar/build.xml" id="jar-dirs">
  187 + <and>
  188 + <filename name="*.jar/build.xml"/>
  189 + <filename name="*-api.jar/build.xml" negate="true"/>
  190 + <filename name="*-ejb.jar/build.xml" negate="true"/>
  191 + </and>
  192 + </fileset>
  193 + <fileset dir="${basedir}" includes="*.sar/build.xml" id="sar-dirs"/>
  194 + <fileset dir="${basedir}" includes="*-ejb.jar/build.xml" id="ejb-dirs"/>
  195 + <fileset dir="${basedir}" includes="*.aop/build.xml" id="aop-dirs"/>
  196 + <fileset dir="${basedir}" includes="*.war/build.xml" id="war-dirs"/>
  197 + </path>
  198 +
  199 +<!-- =============================== -->
  200 +
  201 + <!-- ===== MACRODEFS ===== -->
  202 + <macrodef name="iterate">
  203 + <attribute name="target"/>
  204 + <sequential>
  205 + <subant target="@{target}" inheritall="false" inheritrefs="false" verbose="false">
  206 + <!-- <reference refid="user-classpath" torefid="user-classpath"/> -->
  207 + <property name="caller" location="."/>
  208 + <property name="main.build" location="${ant.file.main}"/>
  209 + <path refid="ordered-dirs"/>
  210 + </subant>
  211 + </sequential>
  212 + </macrodef>
  213 +
  214 + <macrodef name="check-env-set">
  215 + <attribute name="var"/>
  216 + <sequential>
  217 + <fail message="Please set the environment variable @{var}" unless="@{var}"/>
  218 + </sequential>
  219 + </macrodef>
  220 +
  221 +
  222 + <!-- ===== TARGETS ===== -->
  223 +
  224 + <!-- [SB2] requires inits for everything -->
  225 + <!-- BEGIN OF INITS -->
  226 + <!-- this property will allow only *-init methods needed to be created, all other will direct to jar-init -->
  227 + <condition property="init-type" value="jar" else="${archive-type}"><not><matches string="${archive-type}" pattern="^[ew]ar$"/></not></condition>
  228 +
  229 + <macrodef name="init">
  230 + <sequential>
  231 + <check-env-set var="env.JBOSS_HOME"/>
  232 + <check-env-set var="jboss-server"/>
  233 +
  234 + <echo>Running ${archive-type} build scripts : ${ant.file}</echo>
  235 + <fail message="Unable to build ${dirName}. It should be a jar, war, ear, ..."
  236 + unless="archive-type"/>
  237 +
  238 + <antcall target="${init-type}-init"/>
  239 + </sequential>
  240 + </macrodef>
  241 +
  242 + <target name="ear-init">
  243 + <!-- [SB1] - create ear's META-INF & lib & touch application.xml if it does not exist -->
  244 + <!-- moved to ear-init instead of package, because war build requires war-init to be called before packaging & all builds use jar build now -->
  245 + <mkdir dir="${basedir}/META-INF/"/>
  246 + <mkdir dir="${basedir}/lib/"/>
  247 + <touch file="${basedir}/META-INF/application.xml"/>
  248 + </target>
  249 +
  250 + <target name="jar-init">
  251 + <mkdir dir="${basedir}/META-INF/"/>
  252 + <touch file="${basedir}/META-INF/MANIFEST.MF"/>
  253 + </target>
  254 +
  255 + <target name="war-init">
  256 + <!-- [SB2] - create WEB-INF/classes, WEB-INF/lib if it does not exist -->
  257 + <mkdir dir="${basedir}/META-INF/"/>
  258 + <mkdir dir="${basedir}/WEB-INF/classes/"/>
  259 + <mkdir dir="${basedir}/WEB-INF/lib/"/>
  260 + <touch file="${basedir}/META-INF/MANIFEST.MF"/>
  261 + </target>
  262 +
  263 + <!-- END OF INITS -->
  264 +
  265 + <target name="all">
  266 + <antcall target="build"/>
  267 + <antcall target="package"/>
  268 + </target>
  269 +
  270 + <target name="clean">
  271 + <init/>
  272 +
  273 + <delete dir="dist" includeemptydirs="true" quiet="true"/>
  274 +
  275 + <delete verbose="true">
  276 + <fileset dir="." includes="**/*.class" />
  277 + </delete>
  278 +
  279 + <!-- <antcall target="${archive-type}-clean"/> --> <!-- Removed individual cleans -->
  280 +
  281 + <iterate target="clean"/>
  282 + </target>
  283 +
  284 + <target name="build" if="build">
  285 + <build/>
  286 + <!-- <property name="build" value="false"/> -->
  287 + </target>
  288 +
  289 + <macrodef name="build">
  290 + <sequential>
  291 + <init/>
  292 + <iterate target="build"/>
  293 +
  294 +<!-- <antcall target="${archive-type}-build"/> -->
  295 +
  296 + <!-- everything except war and ear -->
  297 +<!--
  298 + <property name="srcpath" value="${basedir}"/>
  299 + <property name="destdir" value="${basedir}"/>
  300 +-->
  301 +
  302 + <!-- if war -->
  303 +<!--
  304 + <property name="srcpath" value="${basedir}/WEB-INF/classes"/>
  305 + <property name="destdir" value="${basedir}/WEB-INF/classes"/>
  306 +-->
  307 +
  308 + <condition property="srcpath" value="${basedir}/WEB-INF/classes" else="${basedir}"><matches string="${archive-type}" pattern="war"/></condition>
  309 + <condition property="destdir" value="${basedir}/WEB-INF/classes" else="${basedir}"><matches string="${archive-type}" pattern="war"/></condition>
  310 +
  311 + <echo>PROPS: ${srcpath} ${destdir}</echo>
  312 +
  313 + <javac destdir="${destdir}" debug="${debug}" debuglevel="${debuglevel}">
  314 + <src path="${srcpath}"/>
  315 + <classpath refid="classpath"/>
  316 + </javac>
  317 + </sequential>
  318 + </macrodef>
  319 +
  320 + <target name="package" depends="build">
  321 + <mkdir dir="dist"/>
  322 + <iterate target="package"/>
  323 +
  324 + <antcall target="${archive-type}-package"/>
  325 +
  326 + </target>
  327 +
  328 +<!-- JAR Build -->
  329 +
  330 +<!--
  331 + <target name="jar-build">
  332 + <sequential>
  333 + <javac destdir="." debug="${debug}" debuglevel="${debuglevel}">
  334 + <src path="${basedir}"/>
  335 + <classpath refid="classpath"/>
  336 + </javac>
  337 + </sequential>
  338 + </target>
  339 +-->
  340 + <target name="jar-package">
  341 + <jar-package/>
  342 + </target>
  343 +
  344 + <target name="aop-package">
  345 + <jar-package/>
  346 + </target>
  347 +
  348 + <target name="beans-package">
  349 + <jar-package/>
  350 + </target>
  351 +
  352 + <target name="sar-package">
  353 + <jar-package/>
  354 + </target>
  355 +
  356 + <macrodef name="jar-package">
  357 + <sequential>
  358 +<!--
  359 + <manifest file="META-INF/MANIFEST.MF" mode="update">
  360 + <attribute name="Class-Path" value="${manifest-class-path}"/>
  361 + <attribute name="Main-Class" value="${main-class}"/>
  362 + </manifest>
  363 +-->
  364 +
  365 + <jar destfile="dist/${archive.name}" manifest="META-INF/MANIFEST.MF">
  366 + <fileset refid="jar.package.fileset"/>
  367 + </jar>
  368 + </sequential>
  369 + </macrodef>
  370 +
  371 +<!-- WAR -->
  372 +<!--
  373 + <target name="war-all" depends="war-build, war-package"> </target>
  374 +
  375 + <target name="war-clean"> </target>
  376 +-->
  377 +
  378 + <target name="war-build">
  379 +
  380 + <javac destdir="WEB-INF/classes/" debug="${debug}" debuglevel="${debuglevel}">
  381 + <src path="WEB-INF/classes"/>
  382 + <classpath refid="classpath"/>
  383 + </javac>
  384 + </target>
  385 +
  386 + <target name="war-package">
  387 + <mkdir dir="dist"/>
  388 +
  389 +<!--
  390 + <manifest file="META-INF/MANIFEST.MF" mode="update">
  391 + <attribute name="Class-Path" value="${manifest-class-path}"/>
  392 + </manifest>
  393 +-->
  394 +
  395 +
  396 + <war destfile="dist/${archive.name}" needxmlfile="false" manifest="META-INF/MANIFEST.MF">
  397 + <fileset refid="war.package.fileset"/>
  398 + </war>
  399 + </target>
  400 +
  401 +<!-- SAR & rar same as jar-->
  402 +
  403 +<!-- EAR -->
  404 + <uptodate property="ear-package.notrequired" targetfile="dist/${archive.name}" >
  405 + <srcfiles dir= "${basedir}" includes="**/dist/*"/>
  406 + </uptodate>
  407 +
  408 + <target name="ear-all" depends="">
  409 + <echo>Calling sub archives build</echo>
  410 + <!--<antcall target="ear-build"/>-->
  411 + <antcall target="ear-package"/>
  412 + </target>
  413 +
  414 +<!--
  415 + <target name="ear-build">
  416 + </target>
  417 +-->
  418 +
  419 + <target name="ear-package" if="ear">
  420 + <sequential>
  421 + <!-- call it here, b/c ear does not have build called on it, putting it in package would be duplicated by the depends=build -->
  422 + <init/>
  423 + <!-- call herre, b/c depends would delete the dist files before checking ear-package.notrequired -->
  424 + <delete dir="dist" includeemptydirs="true" quiet="true" includes="**/*"/>
  425 +
  426 + <mkdir dir="packaging"/>
  427 + <mkdir dir="packaging/lib/"/>
  428 +
  429 + <copy flatten="true" todir="packaging">
  430 + <fileset dir="${basedir}">
  431 + <include name="*/dist/*"/>
  432 + </fileset>
  433 + </copy>
  434 +
  435 + <copy flatten="true" todir="packaging/lib/">
  436 + <fileset dir="${basedir}/lib">
  437 + <include name="*.jar/dist/*.jar"/> <!-- include dirs *.jar/dist/*.jar and any jar files in the lib -->
  438 + <include name="*.jar"/>
  439 + <type type="file"/>
  440 + </fileset>
  441 + </copy>
  442 +
  443 + <ear destfile="dist/${archive.name}" appxml="META-INF/application.xml">
  444 +<!--
  445 + <manifest>
  446 + <attribute name="Class-Path" value="${manifest-class-path}"/>
  447 + </manifest>
  448 +-->
  449 + <fileset dir="${basedir}">
  450 + <include name="*"/>
  451 + <type type="file"/>
  452 + <exclude name="build.xml"/>
  453 + <exclude name="build.properties"/>
  454 + <exclude name=".*"/>
  455 + </fileset>
  456 + <fileset dir="${basedir}" includes="META-INF/**/*"/>
  457 + <fileset dir="${basedir}/packaging/" includes="**/*"/>
  458 + </ear>
  459 + <delete dir="packaging" includeemptydirs="true" quiet="true"/>
  460 + </sequential>
  461 + </target>
  462 +
  463 + <property name="distDir" location="./dist/"/>
  464 +
  465 + <target name="deploy" depends="all">
  466 + <copy todir="${jboss-deploy-dir}" verbose="true">
  467 + <fileset dir="${distDir}" includes="**/*"/>
  468 + </copy>
  469 + </target>
  470 +
  471 + <target name="undeploy">
  472 + <pathconvert property="undeploy.files" pathsep=" ">
  473 + <mapper type="regexp" from="^${distDir}/(.*)$" to="${jboss-deploy-dir}/\1"/>
  474 + <fileset dir="${distDir}" includes="**/*"/>
  475 + </pathconvert>
  476 + <echo>Undeploy ${undeploy.files}</echo>
  477 + <delete includeemptydirs="true" verbose="true">
  478 + <filelist files="${undeploy.files}" />
  479 + </delete>
  480 + </target>
  481 +
  482 +
  483 + <target name="test" depends="build">
  484 + <echo>${jboss-endorsed-dir}</echo>
  485 + <java classname="${test-client}" fork="true">
  486 + <jvmarg value="-Djava.endorsed.dirs=${jboss-endorsed-dir}"/>
  487 + <jvmarg value="-Djava.security.policy=${auth-conf}"/>
  488 +<!--
  489 + -Djava.security.manager -Djava.security.policy=$JBOSS_HOME/bin/java.policy"
  490 +-->
  491 + <classpath>
  492 + <path refid="classpath"/>
  493 + </classpath>
  494 + </java>
  495 + </target>
  496 +
  497 + <target name="junit" depends="build">
  498 + <!-- <echo>security-policy: ${security-policy}</echo> -->
  499 + <junit fork="false" showoutput="true" printsummary="true" filtertrace="false"
  500 + haltonfailure="false"
  501 + outputtoformatters="false">
  502 +<!--
  503 + <jvmarg value="-Djava.rmi.server.logCalls=true"/>
  504 + <jvmarg value="-Djava.security.policy=${security-policy}"/>
  505 + <sysproperty key="java.security.policy" value="${security-policy}"/>
  506 +
  507 + <jvmarg value="-Djava.security.auth.login.config=${auth-conf}"/>
  508 + <sysproperty key="java.security.auth.login.config" value="${auth-conf}"/>
  509 +-->
  510 +
  511 + <classpath refid="classpath"/>
  512 + <formatter type="plain" usefile="false"/>
  513 + <test name="${test-case}"/>
  514 + </junit>
  515 + </target>
  516 +
  517 + <target name="export-zip" depends="clean">
  518 + <mkdir dir="${dist}"/>
  519 + <zip destfile="${dist}/${archive-name}-src.zip">
  520 + <fileset dir="../">
  521 + <include name="${archive.name}/**/*"/>
  522 + <exclude name="${dist}"/>
  523 + </fileset>
  524 + </zip>
  525 + </target>
  526 +
  527 + <target name="export-testcase" depends="clean">
  528 + <echo>This target will split this deployment up into java files and resources which is useful when moving it to the JBoss testsuite</echo>
  529 + <input message="Enter java source directory:" addproperty="testcase.source.dir"/>
  530 + <input message="Enter resource directory:" addproperty="testcase.resource.dir"/>
  531 +
  532 + <echo>Copying java source to ${testcase.source.dir}</echo>
  533 + <mkdir dir="${testcase.source.dir}"/>
  534 + <copy todir="${testcase.source.dir}">
  535 + <fileset dir=".">
  536 + <include name="**/*.java"/>
  537 + </fileset>
  538 + </copy>
  539 +
  540 + <echo>Copying resources to ${testcase.resource.dir}</echo>
  541 + <mkdir dir="${testcase.resource.dir}"/>
  542 + <copy todir="${testcase.resource.dir}">
  543 + <fileset dir=".">
  544 + <exclude name="**/*.java"/>
  545 + <exclude name="**/build.xml"/>
  546 + <exclude name="**/build.properties"/>
  547 + </fileset>
  548 + </copy>
  549 + </target>
  550 +
  551 + <target name="help">
  552 + <echo>archive-name = ${archive-name}</echo>
  553 + <echo>all - builds and packages the archive in the dist/ directory</echo>
  554 + <echo>build - builds the *.java files</echo>
  555 + <echo>clean - deletes the compiled classes *.java and the dist/ directory</echo>
  556 + <echo>deploy - deploys the archive in $JBOSS_HOME/server/$JBOSS_PROFILE - defaults to default, can be set in env variables or build.properties</echo>
  557 + <echo>export-zip - cleans then zips up the source in a zip file in dist/ directory</echo>
  558 + <echo>test - calls build, then runs a test client, the test client class is defined in build.properties property name: test-client</echo>
  559 + <echo>undeploy - undeploys the archive in $JBOSS_HOME/server/$JBOSS_SERVER - defaults to default, can be set in env variables or build.properties</echo>
  560 + </target>
  561 +
  562 + <target name="mavenize-package" if="ear">
  563 + <sequential>
  564 + <!-- call it here, b/c ear does not have build called on it, putting it in package would be duplicated by the depends=build -->
  565 + <init/>
  566 + <!-- call herre, b/c depends would delete the dist files before checking ear-package.notrequired -->
  567 + <!-- <delete dir="dist" includeemptydirs="true" quiet="true" includes="**/*"/> -->
  568 +
  569 + <!-- <copy flatten="true" todir="${dist}"> -->
  570 + <copy todir="${dist}">
  571 + <fileset dir="${basedir}/">
  572 + <include name="*/dist/**/*"/>
  573 + </fileset>
  574 + <regexpmapper from="^.*/dist/(.*)$$" to="\1"/>
  575 + </copy>
  576 +
  577 +<!--
  578 + <copy flatten="true" todir="packaging/lib/">
  579 + <fileset dir="${basedir}/lib">
  580 + <include name="*.jar/dist/*.jar"/>
  581 + <include name="*.jar"/>
  582 + <type type="file"/>
  583 + </fileset>
  584 + </copy>
  585 +-->
  586 +<!--
  587 + <ear destfile="dist/${archive.name}" appxml="META-INF/application.xml">
  588 + <fileset dir="${basedir}">
  589 + <include name="*"/>
  590 + <type type="file"/>
  591 + <exclude name="build.xml"/>
  592 + <exclude name="build.properties"/>
  593 + <exclude name=".*"/>
  594 + </fileset>
  595 + <fileset dir="${basedir}" includes="META-INF/**/*"/>
  596 + <fileset dir="${basedir}/packaging/" includes="**/*"/>
  597 + </ear>
  598 +-->
  599 + </sequential>
  600 + </target>
  601 +
  602 + <macrodef name="mavenize-ejb-template">
  603 + <attribute name="outputFile"/>
  604 +
  605 + <attribute name="project-groupId"/>
  606 + <attribute name="project-artifactId"/>
  607 + <attribute name="project-version"/>
  608 + <attribute name="project-name"/>
  609 + <attribute name="project-description"/>
  610 +
  611 + <attribute name="parent-groupId"/>
  612 + <attribute name="parent-artifactId"/>
  613 + <attribute name="parent-version"/>
  614 + <attribute name="parent-relativePath"/>
  615 +
  616 + <attribute name="build-finalName"/>
  617 + <sequential>
  618 + <copy tofile="@{outputFile}/" file="ejb-pom.xml">
  619 + <filterset>
  620 + <filter token="project-groupId" value="@{project-groupId}"/>
  621 + <filter token="project-artifactId" value="@{project-artifactId}"/>
  622 + <filter token="project-version" value="@{project-version}"/>
  623 + <filter token="project-name" value="@{project-name}"/>
  624 + <filter token="project-description" value="@{project-description}"/>
  625 +
  626 + <filter token="parent-groupId" value="@{parent-groupId}"/>
  627 + <filter token="parent-artifactId" value="@{parent-artifactId}"/>
  628 + <filter token="parent-version" value="@{parent-version}"/>
  629 + <filter token="parent-relativePath" value="@{parent-relativePath}"/>
  630 +
  631 + <filter token="build-finalName" value="@{build-finalName}"/>
  632 + </filterset>
  633 + </copy>
  634 + </sequential>
  635 + </macrodef>
  636 +
  637 + <target name="mavenize" depends="clean">
  638 + <mkdir dir="${dist}"/>
  639 +
  640 + <iterate target="mavenize"/>
  641 +
  642 + <!-- create a top level parent directory for the example that will have a pom.xml to call all the others ? -->
  643 +
  644 + <!-- create directory without extension for each -->
  645 + <!-- using iterate, create them using archive-name in dist -->
  646 + <mkdir dir="${dist}/${archive-name}-${archive-type}"/>
  647 +
  648 + <!-- note only jars that do not have a build.xml should be copied, everything else should be done via maven dependency -->
  649 + <!-- how to deal with jars in ear/lib, war/WEB-INF/lib ? Does maven structure have a lib directory to avoid pom.xml settings ? -->
  650 + <!-- war has my-webapp/src/main/webapp/WEB-INF , it looks like creating a lib dir and copying jars may work -->
  651 + <!-- ear has my-earapp/src/main/application/lib, it looks like creating a lib dir and copying jars may work -->
  652 +
  653 + <echo>mavenize ${dist}/${archive-name}-${archive-type}/pom.xml</echo>
  654 + <mavenize-ejb-template outputFile="${dist}/${archive-name}-${archive-type}/pom.xml"
  655 + project-groupId="org.jboss.as.quickstarts" project-artifactId="${archive-name}-${archive-type}"
  656 + project-version="7.1.2.Final-redhat-1" project-name="${archive-name}-${archive-type}"
  657 + project-description="${archive-name}-${archive-type} description"
  658 + parent-groupId="org.jboss.as.quickstarts" parent-artifactId="${archive-name}"
  659 + parent-version="7.1.2.Final-redhat-1" parent-relativePath="../pom.xml"
  660 + build-finalName="${archive-name}-${archive-type}"/>
  661 +
  662 + <!-- copy META-INF to resources -->
  663 + <mkdir dir="${dist}/${archive-name}-${archive-type}/src/main/resources/"/>
  664 + <copy todir="${dist}/${archive-name}-${archive-type}/src/main/resources/">
  665 + <fileset dir="${basedir}">
  666 + <include name="META-INF/**/*"/>
  667 + </fileset>
  668 + </copy>
  669 +
  670 + <mkdir dir="${dist}/${archive-name}-${archive-type}/src/main/java/"/>
  671 + <copy todir="${dist}/${archive-name}-${archive-type}/src/main/java/">
  672 + <fileset dir="${basedir}">
  673 + <exclude name="dist/**/*"/>
  674 + <exclude name="dist/"/>
  675 + <exclude name="META-INF/"/>
  676 + <exclude name="META-INF/**/*"/>
  677 + <exclude name="build.xml"/>
  678 + <exclude name="build.properties"/>
  679 + <exclude name="*pom.xml"/>
  680 + <exclude name="*.sh"/>
  681 + </fileset>
  682 + </copy>
  683 +
  684 +<!--
  685 + It looks like each module just needs to specify parent, packaging type, and artifact, then have the ear declare dependencies on the sub modules
  686 + <parent>
  687 + <artifactId>ejb-remote-eap6</artifactId>
  688 + <groupId>ejb-remote-eap6</groupId>
  689 + <version>7.1.1.CR2</version>
  690 + </parent>
  691 +
  692 + <artifactId>ejb-remote-eap6-ear</artifactId>
  693 + <packaging>ear</packaging>
  694 +
  695 + <name>ejb-remote-eap6 EAR module</name>
  696 +
  697 + <dependencies>
  698 +
  699 + <dependency>
  700 + <groupId>ejb-remote-eap6</groupId>
  701 + <artifactId>ejb-remote-eap6-web</artifactId>
  702 + <type>war</type>
  703 + </dependency>
  704 + <dependency>
  705 + <groupId>ejb-remote-eap6</groupId>
  706 + <artifactId>ejb-remote-eap6-ejb</artifactId>
  707 + <type>ejb</type>
  708 + </dependency>
  709 + </dependencies>
  710 +-->
  711 +
  712 +
  713 + <!-- copy appropriate pom.xml, use the @ replace against a template -->
  714 + <touch file="${dist}/${archive-name}-${archive-type}/pom.xml"/>
  715 +
  716 + <!-- create .project ? -->
  717 +
  718 + <!-- This will only get called for an ear currently -->
  719 + <antcall target="mavenize-package"/>
  720 + </target>
  721 +
  722 +</project>
21 getCallerPrincipalEjb.jar/com/redhat/gss/ejb/CallerAuthEjb.java
... ... @@ -0,0 +1,21 @@
  1 +package com.redhat.gss.ejb;
  2 +
  3 +import java.security.Principal;
  4 +
  5 +@javax.ejb.Stateless
  6 +@javax.jws.WebService
  7 +@org.jboss.ws.api.annotation.WebContext(authMethod="BASIC")
  8 +@org.jboss.security.annotation.SecurityDomain("other")
  9 +@org.apache.cxf.annotations.Logging(pretty=true)
  10 +@javax.annotation.security.PermitAll
  11 +public class CallerAuthEjb
  12 +{
  13 + @javax.annotation.Resource
  14 + javax.ejb.EJBContext context;
  15 +
  16 + public String getCaller()
  17 + {
  18 + Principal p = context.getCallerPrincipal();
  19 + return p.getName();
  20 + }
  21 +}

0 comments on commit b453ac7

Please sign in to comment.
Something went wrong with that request. Please try again.