Symantec Access Management

 View Only
  • 1.  SmResponseAttr Return of Existing Response Attribute - Java

    Broadcom Employee
    Posted Oct 06, 2016 07:04 PM

    Hi All,

     

    Wondering if anyone has had any success with achieving the following. I am trying to retrieve and programmatically modify an existing Response Attribute value. Things I am able to do successfully currently are:

     

    result = policyapi.getDomainObjectNames("Responses", domain, responseVector);

     

    This will populate the response Vector with the current responses for the specified domain.

     

    I can also then bring back either a Map or a Vector containing the "Response Attributes"

    result = policyapi.getResponseAttrs(response, domain, responseMap);

    result = policyapi.getResponseAttrs(response, domain, responseAttrVector);

     

    My issue is when trying to create a SmResponseAttr object using the constructor

    SmResponseAttr(java.lang.String value)

    Here is the attribute list of the response on the AdminUI

    My attempts are like this:

    SmResponseAttr myAttr = new SmResponseAttr("Test=<% userattr=\"TestBlah\" %>);

       -note the java.util.string wants to escape the " character

     

    or 

    SmResposneAttr myAttr = new SmResponseAttr(https://oel3.rusniaklab.com/sendmehere.html");

     

     

    The Java Doc state the value needs to be in the format:

    public SmResponseAttr(java.lang.String value)
    Constructs a Response attribute object with the specified response attribute type.
    Parameters:
    value - Contains a response attribute type in one of the following formats:
    Note: The non-alphanumeric characters in the format examples are required characters.
    • Static A string that is part of a SiteMinder response, in the following format: 
      variable-name=variable-value
      In the example, variable-name is the name for the name/value pair that this response attribute will return to the Web Agent. variable-value is the static text that will be returned as the second half of the name/value pair.
    • User Attribute A string containing profile information from a user's entry in a user directory, in the following format: 
      User-Attribute-variable-name=<%userattr= "user-attribute-name"%>
      In the example, User-Attribute-variable-name is the name for the name/value pair that this response attribute will return to the Web Agent. user-attribute-name is a user attribute that can be retrieved from an LDAP, WinNT, or ODBC user directory. 
    • DN Attribute A string containing profile information from a directory object in an LDAP or ODBC user directory, in the following format: 
      DN-Variable-Name=<#dn="DN-Spec" attr= "DN-Attribute-Name"#> 
      In the example, DN-Variable-Name is the name for the name/value pair that this response attribute will return to the Web Agent. DN-Spec is the distinguished name of the user group that you want to retrieve the user attribute from. DN-Attribute-Name is an attribute associated with an LDAP or ODBC directory object to which the user is related, such as a group or an organizational unit (OU). 
    • Active Response An active expression associated with the response attribute. The expression is a string of variable definitions in the following format: 
      "varName"=<@lib="LibName" func="FuncName" param="Param"@> 
      In the example, "varName" is the name for the name/value pair that this response attribute will return to the Web Agent. "LibName" is the name of the shared library that supports the active response. "FuncName" is the name of the function in the shared library that implements the active response. "Param" is an optional list of parameters to be passed to the function in the shared library.

     

     

    Has anyone had luck with creating a response attr object from an existing one?

     

    Thanks for your time,

     

    Adam Rusniak



  • 2.  Re: SmResponseAttr Return of Existing Response Attribute - Java

    Posted Oct 07, 2016 01:44 AM

    Hi,

     

    You mentioned

    @@@

    My issue is when trying to create a SmResponseAttr object using the constructor

    @@@

    I'm not quite sure what issue that you encounter with SmResponseAttr constructor.

    Are you getting error return with following constructor? If there is error, please share what you have.

     

    SmResponseAttr myAttr = new SmResponseAttr("Test=<% userattr=\"TestBlah\" %>);
    SmResposneAttr myAttr = new SmResponseAttr(https://oel3.rusniaklab.com/sendmehere.html);

     

    I suggest start wit the simple static message first.

     

     

     

    In above example,

    SmResponseAttr myAttr = new SmResponseAttr(static_response=This is static message);

     

    Check if it print out value.

    ie:

    System.err.println ("This is attribute value: "+myAttr.getAttrValue());

     

    Regards,

    Kar Meng



  • 3.  Re: SmResponseAttr Return of Existing Response Attribute - Java

    Broadcom Employee
    Posted Oct 07, 2016 09:27 AM

    Hi Karmeng,

    Thank you for the response. I should have been more specific with the issues I am having with this particular class.

    I have recreated the same response as above:

    Here is some output from a test:

    SOURCE:

    SmResponseAttr myAttr = new SmResponseAttr("static_response=This is static message");

    System.out.println("Message: " + myAttr.getAttrValue());

    myAttr.setValue("static_response=This is a Java modification test");

    result = policyapi.modifyResponseAttr(myAttr);

    System.out.println("Value modify success: " + result.isSuccess());

     

    OUTPUT:

    Message: This is static message

    Value modify success: false

    AttrType_Static

     

    The modify call always fails to modify the object. 

     

    Here is a screen shot of the parameters that are dumped when I call the method "writeProperties" and dumb them to a hash table:

     

    myAttr.writeProperties(responseAttrProps);

     

     

    I have then modified elements in the value of the hash table and called the method on the modified hash table.

    myAttr.readProperties(responseAttrProps);

    result = policyapi.modifyResponseAttr(myAttr);

     

    This does not do anything either. It produces no errors but the call to result.isSuccess() is false.

     

    Thank you for your time,

     

    Adam



  • 4.  Re: SmResponseAttr Return of Existing Response Attribute - Java
    Best Answer

    Posted Oct 10, 2016 01:14 AM

    Hi Adam,

     

    Try this. I think the problem with your code is you are creating new object of type SmResponseAttr instead of retrieving the existing object and modifying it.

     

    private void testModifyResponseAttribute (SmPolicyApi policyapi) {

    try {

    //Fetch Response Attribute.
    Hashtable hashTable = new Hashtable();
    SmApiResult result = policyapi.getResponseAttrs("jsdksample-response", "jsdksample-domain" , hashTable);
    Set keys = hashTable.keySet();
    String oid = null;
    Iterator iter = keys.iterator();
    if(iter.hasNext())
    {
    oid = iter.next().toString();
    }

    SmResponseAttr respAttr = new SmResponseAttr();

     

    //retrieve Response Attribute Object from policy store
    result = policyapi.getObject(oid, respAttr);

    // Modify First Response Attribute.
    respAttr.setValue("varName = MODIFIEDvarValue");
    result= policyapi.modifyResponseAttr(respAttr);
    }catch (SmApiException Ex){
    Ex.printStackTrace();

    }



  • 5.  Re: SmResponseAttr Return of Existing Response Attribute - Java

    Broadcom Employee
    Posted Oct 10, 2016 11:06 AM

    Ujwol,

     

    Thank you very much! This helped me and now I am properly bringing back the response attribute and the right values and the modify call is successful.

     

    I appreciate your help as always.

     

    Adam



  • 6.  Re: SmResponseAttr Return of Existing Response Attribute - Java

    Posted Oct 10, 2016 11:10 AM
    Glad it worked !!