2 Replies Latest reply on Jul 9, 2012 6:28 PM by James Fellows

    AS7 Configuration/ CLI - How best to represent an array attribute

    James Fellows Newbie

      HI

       

      I have a custom LoginModule which accepts an array (of Strings) as one of its module-options, but am not sure on the best way to store this array in the configuration (using the CLI).  I've found three ways and none is ideal:

       

        * I've found that i can add multiple module-option name/value pairs with the same name - but only the last one to be added is passed through to the LoginModule's initialize method. 

        * I can also add what looks like an array through the jboss_cli, but it's actually stored as a single String with the quote marks translated to @ quot; and the comma in the middle of the string.

        * I've fallen-back to passing-in all of the parameters concatenated together, delimited by pipes.  However, the array values can each be quite long, and it's not possible to view/ edit the string through the web interface, only replace the whole thing.

        * I guess I could go with a list of module-options with numbered names, and pull all of them from the map and build the array that way, but it's likely to be error-prone when users miss a number in the sequence etc.

       

      Is there a better way to pass/ store an array of attributes in the jboss config?


      Thank you

        • 1. Re: AS7 Configuration/ CLI - How best to represent an array attribute
          Tomaz Cerar Master

          Hi,

           

          there are many ways if you are refering to DMR model. it can be list of strings or map<String,String>

          but to better help you can you provide bit more context as atm i cannot tell what exacly are you trying to do and where.

           

           

          --

          tomaz

          • 2. Re: AS7 Configuration/ CLI - How best to represent an array attribute
            James Fellows Newbie

            Thanks for the quick reply.  I'm not sure what DMR model is I'm afraid. 

             

            I thought the question might be generic to any attribute, but in my case specifically, the attribute can be queried using the following command in the CLI:

             

            /subsystem=security/security-domain=my-auth/authentication=classic/:read-attribute(name=login-modules,include-defaults=true)

             

            This command returns the following:

            {

                "outcome" => "success",

                "result" => [{

                    "code" => "com.me.MyLoginModule",

                    "flag" => "required",

                    "module-options" => [

                        ("cookie-names" => "Cookie1|Cookie2"),

                        ("session-type" => "EITHER")

                    ]

                }]

            }

             

            And I would like to be able to set "cookie-names" to be an array (or List!) of Strings, rather than a pipe-delimited String.

             

            The LoginModule extends org.jboss.security.auth.spi.AbstractServerLoginModule.  The method initialize has a parameter Map<String,?> options  that is set by JBoss based on the contents of the module-options part of the JBoss config file.  I would like to know how to set the module-options in the config file so that I can retrieve one from the Map as a List<?> or array please.

             

            Hope that's clearer - happy to provide more info if not