IC5Notice: We have upgraded developerWorks Community to the latest version of IBM Connections. For more information, read our upgrade FAQ.
Topic
  • 5 replies
  • Latest Post - ‏2013-02-04T20:32:16Z by Doyler86
SystemAdmin
SystemAdmin
6772 Posts

Pinned topic XSL Transformation that inserts a generic password

‏2013-02-01T14:34:59Z |
Hello,

Here’s what I’m trying to do: I have clients that need to authenticate through Datapower, and just before passing them to the backend, I need to change their password to a generic password that never changes. The backend system will use the userid and generic password to identify the user.

So far, I have created a MPGW in Datapower (XI50) that authenticates the user using LDAP. So far, so good. Now I need an XSL transformation that will change their password to the generic. I'm rather new to XSL and was wondering if some could give me a XSL example that would do this transformation.

Here is what's coming in:

authz<container>
<mapped-credentials type="none" au-success="true">
<entry type="ldap">cn=userid,ou=dept,ou=dept,ou=division,o=company</entry>
</mapped-credentials>
<mapped-resource type="none">
<resource>
<item type="original-url">/jboss-net/services/application</item>
</resource>
</mapped-resource>
<identity>
<entry type="http-basic-auth">
<username>testuser</username>
<password sanitize="true">********</password>
<configured-realm>login</configured-realm>
</entry>
<entry type="wssec-username"><username/>
<password sanitize="true">********</password>
</entry>
</identity>
<au-ancillary-info/>
<az-ancillary-info/>
</container>authz' method='anyauthenticated'

Any help would be much appreciated!
Updated on 2013-02-04T20:32:16Z at 2013-02-04T20:32:16Z by Doyler86
  • Liv2luv
    Liv2luv
    573 Posts

    Re: XSL Transformation that inserts a generic password

    ‏2013-02-01T14:46:32Z  
    I believe a sample XML message for inserting the password will be helpful to be able to create a transformation.
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: XSL Transformation that inserts a generic password

    ‏2013-02-01T15:46:01Z  
    • Liv2luv
    • ‏2013-02-01T14:46:32Z
    I believe a sample XML message for inserting the password will be helpful to be able to create a transformation.
    I'm sorry, I don't think I understand what you mean?
  • Liv2luv
    Liv2luv
    573 Posts

    Re: XSL Transformation that inserts a generic password

    ‏2013-02-01T16:15:52Z  
    I'm sorry, I don't think I understand what you mean?
    Hope this helps:

    Sample XML:

    
    <container> <mapped-credentials type=
    "none" au-success=
    "true"> <entry type=
    "ldap">cn=userid,ou=dept,ou=dept,ou=division,o=company</entry> </mapped-credentials> <mapped-resource type=
    "none"> <resource> <item type=
    "original-url">/jboss-net/services/application</item> </resource> </mapped-resource> <identity> <entry type=
    "http-basic-auth"> <username>testuser</username> <password sanitize=
    "true">********</password> <configured-realm>login</configured-realm> </entry> <entry type=
    "wssec-username"><username/> <password sanitize=
    "true">********</password> </entry> </identity> <au-ancillary-info/> <az-ancillary-info/> </container>
    


    XSLT

    
    <?xml version=
    "1.0" encoding=
    "UTF-8"?> <xsl:stylesheet xmlns:xsl=
    "http://www.w3.org/1999/XSL/Transform" version=
    "1.0"> <xsl:template match=
    "node()|@*"> <xsl:copy> <xsl:apply-templates select=
    "node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match=
    "password/text()"> <xsl:text>NEW_PASSWORD</xsl:text> </xsl:template> </xsl:stylesheet>
    


    Output

    
    <?xml version=
    "1.0" encoding=
    "UTF-8"?><container> <mapped-credentials type=
    "none" au-success=
    "true"> <entry type=
    "ldap">cn=userid,ou=dept,ou=dept,ou=division,o=company</entry> </mapped-credentials> <mapped-resource type=
    "none"> <resource> <item type=
    "original-url">/jboss-net/services/application</item> </resource> </mapped-resource> <identity> <entry type=
    "http-basic-auth"> <username>testuser</username> <password sanitize=
    "true">NEW_PASSWORD</password> <configured-realm>login</configured-realm> </entry> <entry type=
    "wssec-username"><username/> <password sanitize=
    "true">NEW_PASSWORD</password> </entry> </identity> <au-ancillary-info/> <az-ancillary-info/> </container>
    


    The above transformation does not modify the user name.
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: XSL Transformation that inserts a generic password

    ‏2013-02-01T19:25:47Z  
    • Liv2luv
    • ‏2013-02-01T16:15:52Z
    Hope this helps:

    Sample XML:

    <pre class="jive-pre"> <container> <mapped-credentials type= "none" au-success= "true"> <entry type= "ldap">cn=userid,ou=dept,ou=dept,ou=division,o=company</entry> </mapped-credentials> <mapped-resource type= "none"> <resource> <item type= "original-url">/jboss-net/services/application</item> </resource> </mapped-resource> <identity> <entry type= "http-basic-auth"> <username>testuser</username> <password sanitize= "true">********</password> <configured-realm>login</configured-realm> </entry> <entry type= "wssec-username"><username/> <password sanitize= "true">********</password> </entry> </identity> <au-ancillary-info/> <az-ancillary-info/> </container> </pre>

    XSLT

    <pre class="jive-pre"> <?xml version= "1.0" encoding= "UTF-8"?> <xsl:stylesheet xmlns:xsl= "http://www.w3.org/1999/XSL/Transform" version= "1.0"> <xsl:template match= "node()|@*"> <xsl:copy> <xsl:apply-templates select= "node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match= "password/text()"> <xsl:text>NEW_PASSWORD</xsl:text> </xsl:template> </xsl:stylesheet> </pre>

    Output

    <pre class="jive-pre"> <?xml version= "1.0" encoding= "UTF-8"?><container> <mapped-credentials type= "none" au-success= "true"> <entry type= "ldap">cn=userid,ou=dept,ou=dept,ou=division,o=company</entry> </mapped-credentials> <mapped-resource type= "none"> <resource> <item type= "original-url">/jboss-net/services/application</item> </resource> </mapped-resource> <identity> <entry type= "http-basic-auth"> <username>testuser</username> <password sanitize= "true">NEW_PASSWORD</password> <configured-realm>login</configured-realm> </entry> <entry type= "wssec-username"><username/> <password sanitize= "true">NEW_PASSWORD</password> </entry> </identity> <au-ancillary-info/> <az-ancillary-info/> </container> </pre>

    The above transformation does not modify the user name.
    Thanks! This seems to be working!
  • Doyler86
    Doyler86
    91 Posts

    Re: XSL Transformation that inserts a generic password

    ‏2013-02-04T20:32:16Z  
    Since it looks to be basic auth, could a potential solution be to add an entry in the user agent to present the generic username and password for a specific backend url?

    just curious..

    thanks,

    Doyle