Child pages
  • _Authenticating Service Calls

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebash
#!/bin/bash

#The script needs the servername:portnumber, username and password respectively to work correctly.

if [[ $# -ne 3 ]] ; then
echo 'Invalid command. Please run authenticate script in following format ./authenticateCallService <servername:port> <username> <password>'
    exit 1
fi

curl -c ~/loginRequestCookie -X POST "http://$1/$ProductAbbrevLowercase/tbl"   -D ~/firstReqHeaders > /dev/null

#The server sends a new cookie as a response to this request. Use that cookie for subsequent requests.
curl -b ~/loginRequestCookie -X POST "http://$1/$ProductAbbrevLowercase/tbl/j_security_check" -H "Context-Type: application/x-www-form-urlencoded" --data "j_username=$2&j_password=$3"  -L "http://$1/$ProductAbbrevLowercase/tbl" -c ~/loginSuccessCookie -D ~/secReqHeaders 

curl -b ~/loginSuccessCookie -X POST "http://$1/$ProductAbbrevLowercase/tbl/sparql" -G --data-urlencode "query=SELECT * WHERE{?s a <http://www.w3.org/2002/07/owl#Class>} "  --data-urlencode "default-graph-uri=http://topbraid.org/examples/kennedys" --data "format=json" -D ~/thirdReqHeaders


#Logout when done so as not to exhaust the user limit on the license
curl -b ~/loginSuccessCookie -X POST "http://$1/$ProductAbbrevLowercase/tbl/purgeuser" -D ~/logoutReqHeaders

...