WAS v8.5 > Script the application serving environment (wsadmin) > Scripting for security > Configure security with scripting

Enable and disable Java 2 security using scripting

We can enable or disable Java 2 security with scripting and wsadmin.

There are two ways to enable or disable Java 2 security. We can use the commands for the AdminConfig object, or we can use the setAdminActiveSecuritySettings command for the AdminTask object.

  1. Use the setAdminActiveSecuritySettings command for AdminTask to enable or disable Java 2 security.

    1. Launch the wsadmin scripting tool using the Jython scripting language. See the Starting the wsadmin scripting client article for more information.

    2. Use the getActiveSecuritySettings command to display the current security settings, including custom properties for global security, as the following example demonstrates:

      • Jacl:

          $AdminTask getActiveSecuritySettings
      • Using Jython:

          AdminTask.getActiveSecuritySettings()

    3. Use the setAdminActiveSecuritySettings command to enable or disable Java 2 security.

      The following examples enable Java 2 security:

      • Jacl:

          $AdminTask setAdminActiveSecuritySettings {-enforceJava2Security true}
      • Using Jython:

          AdminTask.setAdminActiveSecuritySettings('-enforceJava2Security true')

      The following examples disable Java 2 security:

      • Jacl:

          $AdminTask setAdminActiveSecuritySettings {-enforceJava2Security false}
      • Using Jython:

          AdminTask.setAdminActiveSecuritySettings('-enforceJava2Security false')

    4. Save the configuration changes.

      Use the following command example to save your configuration changes:

        AdminConfig.save()

  2. Use the AdminConfig object to enable Java 2 security.

    1. Start the wsadmin scripting tool.

    2. Identify the security configuration object and assign it to the security variable, as the following example demonstrates:

      • Jacl:

          set security [$AdminConfig list Security]
      • Jython:

        security = AdminConfig.list('Security')
        print security

        Example output:

          (cells/mycell|security.xml#Security_1)

    3. Modify the enforceJava2Security attribute to enable or disable Java 2 security, as the following examples demonstrates:

      • To enable Java 2 security:

        • Jacl:

            $AdminConfig modify $security {{enforceJava2Security true}}
        • Jython:

            AdminConfig.modify(security, [['enforceJava2Security', 'true']])

      • To disable Java 2 security:

        • Jacl:

            $AdminConfig modify $security {{enforceJava2Security false}}
        • Jython:

            AdminConfig.modify(security, [['enforceJava2Security', 'false']])

    4. Save the configuration changes.

      Use the following command example to save your configuration changes:

        AdminConfig.save()


Related


Use the wsadmin scripting AdminConfig object for scripted administration
Start the wsadmin scripting client using wsadmin.sh


Reference:

Commands for the AdminConfig object using wsadmin.sh
AdminTask SecurityConfigurationCommands


+

Search Tips   |   Advanced Search