Delete Attribute
This section provides developers with information on how to delete an attribute. Documentation for the REST protocol, as well as samples for Java, PHP, and cURL, are provided below.
REST
The REST noun (and associated message content) for deleting an attribute is as follows:
- Relative Noun: AuthenticatedSession/$sessionID/Entity/$entityID/Attribute/$attrID. This is the relative path of the URL that should appear after the OTIS server application name. Below is an example of deleting the phoneNumber attribute on the john.doe entity:
AuthenticatedSession/78BD660E0E5F673378BD660E0E5F6733/Entity/john.doe/Attribute/phoneNumber
NOTE: Actual attribute IDs are likely to be full URIs, and would need to be URL encoded. For example, the attribute:
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname
would be encoded as
.../Attribute/http%3A%252F%252Fschemas.xmlsoap.org%252Fws%252F2005%252F05%252Fidentity%252Fclaims%252Fgivenname
IMPORTANT NOTE ON ENCODING: Characters which have special meanings in URLs (such as '/', '?', and '&') might need to be double encoded in order to ensure that they arrive at OTIS still encoded. This is because web servers often decode the URL before handing it to a web service application (like OTIS). In the example above you see some %252F encodings. If a web server decodes this before handing it to OTIS, it appears in the URL as %2F (because %25 decodes to %). If you simply put %2F in the URL, the web server decodes it to '/', which causes OTIS to improperly parse the URL's path component. Similar arguments can be made about encodings for the '?' and '&' characters.
- HTTP Method: DELETE.
- Request/Response message details: none.
- Description: Removes the specified attribute from the specified entity.
Java
The following is example Java code that demonstrates how to delete an attribute from a specified entity:
//remove a specific attribute: The URI is the unique identifier for the attribute
example = session.getEntity("example");
example.removeAttribute(new URI("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/stateorprovince"));
To view the complete Java sample code for Attribute/Entity nouns, see the Entity/Attribute Java Sample Code page.
The OTIS client Java library may be downloaded from the OTIS download page.
PHP
The following is example PHP code that demonstrates how to delete an attribute from a specified entity:
//You can delete an attribute directly:
echo "\n\n" . deleteRequest($sessionURL, $sessionSecret, "Entity/example?attr=http://schemas.xmlsoap.org/ws/2005/05/identity/claims/stateorprovince");
//OR.....
//You can delete an attribute while updating an entity:
echo updateRequest($sessionURL, $sessionSecret, "Entity/example");
function updateRequest($URL, $secret, $URI){
$xml =
'<tns:EntityChange xmlns:tns="http://www.eclipse.org/higgins/idas/rest-xml/2008/6">
<!-- Remove an entire attribute and all its values -->
<tns:AttributeRemove>http://schemas.xmlsoap.org/ws/2005/05/identity/claims/stateorprovince</tns:AttributeRemove>
</tns:EntityChange>';
$length = strlen($xml);
$updateHeader =
"PUT $URL/$URI HTTP/1.1\n".
"Host: wag. bandit-project.org\n".
(($secret) ? ("SessionSecret: " . $secret . "\n") : "") .
"Content-Type: application/x-www-form-urlencoded\n".
"Content-Length: $length\n".
"Connection: Close\n\n".
"$xml\n";
$socket = fsockopen("wag.bandit-project.org", 80);
fputs($socket, $updateHeader);
$content = "";
while(!feof($socket)) $content .= fgets($socket, 2048);
return $content;
}
To view the complete PHP sample code for Attribute/Entity nouns, see the Entity/Attribute PHP Sample Code page.
cURL
The following command deletes the email address attribute from the "otistest" entity:
if [ -e secret.hdr ] ; then secret=`cat secret.hdr` ; else secret="nosecret: none" ; fi
curl -b cookies.txt -H "${secret}" -X DELETE https://wag.bandit-project.org/otis/Entity/otistest/Attribute/http%3A%252F%252Fschemas.xmlsoap.org%252Fws%252F2005%252F05%252Fidentity%252Fclaims%252Femailaddress
See the Attribute Delete Request documentation for further details including expected response codes and message body.