IMO we can ask to install xmllint as a pre-requisite.

Using a regular expression to extract the values from an XML might be error
prone since the regular expression is vulnerable to spaces or lines breaks
which can be added in future releases.

But xmllint is a proper XML parser. So it will work as long the schema is
the same.



On Sat, Jan 6, 2018 at 8:48 PM, Gayan Gunawardana <ga...@wso2.com> wrote:

> Please check below approach if it works for your requirement.
>
> cmd=$(curl -k -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Content-Type:
> text/xml;charset=UTF-8" -H "SOAPAction:urn:getApplication" -d @get_sp.xml
> "https://$IP_ADDRESS:$HTTPS_PORT_IS/services/
> IdentityApplicationManagementService?wsdl")
> cp /dev/null get_sp_reponse.xml
> echo $cmd >> get_sp_reponse.xml
> applicationID=$(grep -oP '(?<=ax2199:applicationID>)[^<]+'
> "get_sp_reponse.xml")
> echo "Service Provider Application ID: $applicationID"
>
> *get_sp.xml*
>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";
> xmlns:xsd="http://org.apache.axis2/xsd";>
>    <soapenv:Header/>
>    <soapenv:Body>
>       <xsd:getApplication>
>          <!--Optional:-->
>          <xsd:applicationName>SERVICE_PROVIDER_NAME</xsd:applicationName>
>       </xsd:getApplication>
>    </soapenv:Body>
> </soapenv:Envelope>
>
> On Fri, Jan 5, 2018 at 5:08 PM, Nipuni Bhagya <nipu...@wso2.com> wrote:
>
>> Hi all,
>>
>> I'm writing shell scripts for the IAM Quick Start Guide and currently,
>> I'm working on the shell script which automates the configuration of SSO
>> with SAML2. I have encountered a problem while trying to get the
>> application Id of a service provider in order to perform an update
>> operation.
>>
>> The method I'm using to overcome this at the moment is,
>>
>> 1. I call the getApplication function in the Identity Application
>> Management API
>> 2. Write the response to a text file.
>> 3. Convert that text file into an XML file.
>> 4. grep the value of <ax2140:applicationID>
>>
>> But the problem with this approach is that I'm using a tool called xmllint to
>> convert the text to XML format. Since xmllint is not a default Unix command
>> the users will have to install it on their machines first. As it is not
>> appropriate to ask for the user's password while running a script, I can't
>> use xmllint and also most of the other approaches available.
>>
>> So I would really appreciate if someone of you could help me to find a
>> better way to achieve this task.
>>
>> Thank you in advance,
>> --
>>
>>
>>
>> *Kind Regards,Nipuni Bhagya*
>>
>> *Software Engineering Intern*
>> *WSO2*
>>
>>
>>
>> *Mobile : +94 0779028904 <+94%2077%20767%201807>*
>>
>
>
>
> --
> Gayan Gunawardana
> Senior Software Engineer; WSO2 Inc.; http://wso2.com/
> Email: ga...@wso2.com
> Mobile: +94 (71) 8020933
>



-- 
*Best Regards*

*Rushmin Fernando*
*Technical Lead*

WSO2 Inc. <http://wso2.com/> - Lean . Enterprise . Middleware

mobile : +94775615183
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to