글 수 93
1. FORM based authentication using curl
For small command line based tools, a shell script using curl to interact with the RTC repository is often sufficient. The two common authentication options for an RTC repository setup are either Basic Auth or Form Based Auth. While Basic Auth is commonly supported by HTTP clients, Form Based Auth can be a bit trickier.
Accessing work item 1 on a server configured for Form Based Auth can be done using this shell script:
$ COOKIES=./cookies.txt
$ USER=kdyoung
$ PASSWORD=kdyoung
$ HOST="https://localhost:9443/jazz"
$ curl -k -c $COOKIES "$HOST/authenticated/identity"
... 생략
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title>濡쒕뱶 以?..</title>
... 생략
<script type="text/javascript">
/* <![CDATA[ */
dojo.addOnLoad( function() {
net.jazz.ajax.ui.PlatformUI.createAndRunWorkbench("net.jazz.web.app.authrequired");
});
/* ]]> */
</script>
</body>
</html>
$ curl -k -L -b $COOKIES -c $COOKIES -d j_username=$USER -d j_password=$PASSWORD
"$HOST/authenticated/j_security_check"
{
"userId": "kdyoung",
"roles": [
"JazzAdmins"]
}
If this line returns the JSON representation of work item 1, authentication was successful
$ curl -k -b $COOKIES "$HOST/oslc/workitems/1.json"
{
"dc:identifier":1,
"rtc_cm:state":{"rdf:resource":"https:\/\/localhost:9443\/jazz\/oslc\/workflows\/_B_3XsP2eEd6418GJ5vhuag\/states\/bugzillaWorkflow\/1"},
"rtc_cm:com.ibm.team.workitem.linktype.attachment.attachment":[],
"rtc_cm:com.ibm.team.workitem.linktype.copiedworkitem.copies":[],
"dc:creator":{"rdf:resource":"https:\/\/localhost:9443\/jazz\/oslc\/users\/_mrqmsP2dEd6418GJ5vhuag"},
"rtc_cm:modifiedBy":{"rdf:resource":"https:\/\/localhost:9443\/jazz\/oslc\/users\/_mrqmsP2dEd6418GJ5vhuag"},
"rtc_cm:com.ibm.team.workitem.linktype.copiedworkitem.copiedFrom":[],
"rtc_cm:ownedBy":{"rdf:resource":"https:\/\/localhost:9443\/jazz\/oslc\/users\/_mrqmsP2dEd6418GJ5vhuag"},
"oslc_cm:severity":{"rdf:resource":"https:\/\/localhost:9443\/jazz\/oslc\/enumerations\/_B_3XsP2eEd6418GJ5vhuag\/severity\/severity.literal.l3"},
"rdf:resource":"https:\/\/localhost:9443\/jazz\/resource\/itemOid\/com.ibm.team.workitem.WorkItem\/_C92p8P2eEd6418GJ5vhuag",
"calm:affectsExecutionResult":[],
"rtc_cm:projectArea":{"rdf:resource":"https:\/\/localhost:9443\/jazz\/oslc\/projectareas\/_B_3XsP2eEd6418GJ5vhuag"},
"rtc_cm:correctedEstimate":null,
"rtc_cm:teamArea":null,
"dc:created":"2010-01-10T04:10:13.093Z",
"rtc_cm:resolution":null,
"rtc_cm:com.ibm.team.workitem.linktype.blocksworkitem.dependsOn":[],
"dc:subject":"",
"rtc_cm:resolvedBy":{"rdf:resource":"https:\/\/localhost:9443\/jazz\/oslc\/users\/_YNh4MOlsEdq4xpiOKg5hvA"},
"rtc_cm:com.ibm.team.workitem.linktype.parentworkitem.parent":[],
"rtc_cm:filedAgainst":{"rdf:resource":"https:\/\/localhost:9443\/jazz\/resource\/itemOid\/com.ibm.team.workitem.Category\/_C9HDEv2eEd6418GJ5vhuag"},
"dc:type":{"rdf:resource":"https:\/\/localhost:9443\/jazz\/oslc\/types\/_B_3XsP2eEd6418GJ5vhuag\/task"},
"rtc_cm:com.ibm.team.workitem.linktype.relatedartifact.relatedArtifact":[],
"dc:modified":"2010-01-10T04:10:13.437Z",
"rtc_cm:estimate":null,
"rtc_cm:comments":[],
"rtc_cm:plannedFor":null,
"rtc_cm:com.ibm.team.workitem.linktype.textualReference.textuallyReferenced":[],
"rtc_cm:com.ibm.team.workitem.linktype.duplicateworkitem.duplicateOf":[],
"rtc_cm:foundIn":null,
"calm:implementsRequirement":[],
"rtc_cm:com.ibm.team.workitem.linktype.relatedworkitem.related":[],
"rtc_cm:com.ibm.team.scm.svn.linkType.workItem.s":[],
"rtc_cm:com.ibm.team.workitem.linktype.blocksworkitem.blocks":[],
"rtc_cm:com.ibm.team.build.linktype.reportedWorkItems.com.ibm.team.build.common.link.reportedAgainstBuilds":[],
"rtc_cm:com.ibm.team.workitem.linktype.parentworkitem.children":[],
"rtc_cm:due":null,"rtc_cm:com.ibm.team.filesystem.workitems.change_set.com.ibm.team.scm.ChangeSet":[],
"rtc_cm:timeSpent":null,
"rtc_cm:resolved":null,
"dc:title":"\ubc18\ubcf5 \uacc4\ud68d \uc815\uc758",
"rtc_cm:startDate":null,
"rtc_cm:com.ibm.team.build.linktype.includedWorkItems.com.ibm.team.build.common.link.includedInBuilds":[],
"oslc_cm:priority":{"rdf:resource":"https:\/\/localhost:9443\/jazz\/oslc\/enumerations\/_B_3XsP2eEd6418GJ5vhuag\/priority\/priority.literal.l1"},
"rtc_cm:subscribers":[{"rdf:resource":"https:\/\/localhost:9443\/jazz\/oslc\/users\/_mrqmsP2dEd6418GJ5vhuag"}],
"rtc_cm:com.ibm.team.workitem.linktype.duplicateworkitem.duplicates":[],
"calm:testedByTestCase":[],
"dc:description":"...생략...",
"calm:blocksTestExecutionRecord":[],
"rtc_cm:com.ibm.team.connector.ccbridge.common.act2wi.s":[],
"oslc_cm:relatedChangeManagement":[]
}
The login process (the first two curl commands in the above example) is
necessary only once per session. Any subsequent call can be made using-b $COOKIES.
The option-kis only necessary when the server has a self-signed or expired certificate.
2. BASIC authentication using curl
Using curl with a server configured for Basic Auth is straightforward. E.g. work item 1 can be accessed on the command line as:
$ curl -k -u username:password "https://localhost:9443/oslc/workitems/1.json"
To use all the script examples in this document with Basic Auth, you would typically replace -b $COOKIES with -u <user:password>.
