Search code examples
javajbosswebsphere-liberty

What is equivalent annotation in WebSphere Liberty for Jboss EJb3 annotation @SecurityDomain("") and WebSphere annotation @Webcontext


I have Migrating Jboss application to WebSphere Liberty. I must remove all Jboss reference library. While doing that am facing issue in some annotation. Jboss application using @SecurityDomain("Authentication") and @Webcontext What is equivalent annotation in WebSphere Liberty for these two annotation.


Solution

  • Depending on your requirements (there are some defaults if omitted) , you would want to have the following in web.xml:

    1) Security constraints which describes resources of your app with mapping to roles e.g.

    <security-constraint>
        <web-resource-collection>
          <url-pattern>/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
          <role-name>testing</role-name>
        </auth-constraint>
     </security-constraint>
    

    2) Security role definitions (athough they can be done also via annotation @DeclareRoles)

    <security-role>
        <role-name>testing</role-name>
     </security-role> 
    

    3) Login config , used when want to have form login (if omitted then defaults to Basic):

    <login-config>
        <auth-method>BASIC</auth-method>
     </login-config> 
    

    Then configure user registry in Liberty. You can have file based, LDAP, or custom if needed. server.xml config depends on the type of registry used. Finally you need to bind users to security roles. It is too broad to include all options here, so just adding relevant links. (create separate questions for more detailed issues, if needed).

    Useful links: