8 Replies Latest reply on Mar 27, 2012 2:30 AM by Vin Prabhu

    Any alternative for <application-managed-security/> in AS 7

    Vin Prabhu Newbie

      Hi,

       

      We are upgrading our application from JbossAS5.1 to JbossAS7.

       

      In AS5, ds.xml files we used specify an property <application-managed-security/>.

       

      But AS7, doesnt support this xml tag. How this is supported in AS7? Any alternative?

       

      Regards,

      Vinayak Prabhu

        • 1. Re: Any alternative for <application-managed-security/> in AS 7
          Stephen Coy Master

          The portable way to do this has always been to declare it in a resource-ref:

          <resource-ref>
               <res-ref-name>jdbc/myDataSource</res-ref-name>
               <res-type>javax.sql.DataSource</res-type>
               <res-auth>Application</res-auth>
          </resource-ref>

           

          Your code would then be looking up

           

                 java:comp/env/jdbc/myDataSource

           

          to access the connection.

          • 2. Re: Any alternative for <application-managed-security/> in AS 7
            Vin Prabhu Newbie

            Hi Stephen,

             

            Thanks for the suggestion. But <resource-ref> tag is not supported in standalone.xml.

            This tag could have been used in any Web applications, which has we.xml file. But my applciation is a server and it doesnt have any such files.

             

            https://docs.jboss.org/author/display/AS7/Resource+adapters

            JBoss doc for Resource adapters says, it has such kind of support for having <application/> tag like

                            <security>

                               <application/>

                            </security>

            But I could not use this in my datasource configuration.

             

            Following is my datasource configuration in standalone.xml. I would like to know how can I relate

            <res-auth>Application</res-auth> 

            with this configuration. How can I do that??

             

                    <subsystem xmlns="urn:jboss:domain:datasources:1.0">

                        <datasources>

                            <datasource jndi-name="java:jboss/mydatabase" pool-name="mypoolname" enabled="true" jta="true" use-java-context="true" spy="true" use-ccm="true">

                                <connection-url>

                                    jdbc:oracle:thin:@mydburl:1234:mydbsid

                                </connection-url>

                                <driver>

                                    oracle

                                </driver>

                                <pool>

                                    <min-pool-size>

                                        0

                                    </min-pool-size>

                                    <max-pool-size>

                                        100

                                    </max-pool-size>

                                    <prefill>

                                        false

                                    </prefill>

                                    <use-strict-min>

                                        false

                                    </use-strict-min>

                                    <flush-strategy>

                                        EntirePool

                                    </flush-strategy>

                                </pool>

                                <timeout>

                                    <blocking-timeout-millis>

                                        30000

                                    </blocking-timeout-millis>

                                    <idle-timeout-minutes>

                                        1

                                    </idle-timeout-minutes>

                                </timeout>

                            </datasource>

                        </datasources>

             

            Thanks alot in advance.

            • 3. Re: Any alternative for <application-managed-security/> in AS 7
              Stephen Coy Master

              Vin Prabhu wrote:

               

              But my applciation is a server and it doesnt have any such files.

               

               

              What kind of server?

               

              How is it packaged?

              • 4. Re: Any alternative for <application-managed-security/> in AS 7
                Vin Prabhu Newbie

                I have deployed ear in standalone/deployment/appname.ear and sar within this standalone/deployment/appname.ear/appname.sar with which all application specific jars and config files.

                 

                My server doesnt have EJB, Webservices etc.

                My server is written in Core Java to handle login, get database Connections, execute transactions etc.

                • 5. Re: Any alternative for <application-managed-security/> in AS 7
                  Stephen Coy Master

                  I can't help with changes to the datasource configuration.

                   

                  However, you might want to consider CDI enabling your jar(s) and then injecting your datasource with

                   

                  @Resource(authenticationType = APPLICATION, lookup=..)
                  private DataSource myDataSource;

                   

                  CDI makes things really easy and you should check it out if you haven't already.

                  • 6. Re: Any alternative for <application-managed-security/> in AS 7
                    Vin Prabhu Newbie
                    @Resource(authenticationType = APPLICATION) 

                    This is supported. This is new feature in Java6.

                     

                    But I want to know more about @Resource annotation. Can you please explain about authenticationType?

                    How exactly authenticationType = APPLICATION affects on DataSource? How to verify this?

                    What is difference between AuthenticationType.APPLICATION and AuthenticationType.CONTAINER?

                    Any other configurations needed for @Resource to work for DataSource??

                    • 7. Re: Any alternative for <application-managed-security/> in AS 7
                      Stephen Coy Master

                      Sigh.

                       

                      Have a look in §5.7 of the Java EE 6 Specification. It explains it all in gruesome detail.

                      • 8. Re: Any alternative for <application-managed-security/> in AS 7
                        Vin Prabhu Newbie

                        Is the same tag <application-managed-security> supported in AS7.1 ??