Create Attribute

This section provides developers with information on how to create an attribute on a specified entity. Documentation for the REST protocol, as well as code samples for Java, PHP, and cURL, are provided below.

REST

the REST noun (and associated message content) for creating an attribute is as follows:

  • Relative Noun: AuthenticatedSession/$sessionID/Entity/$entityID/Attribute. This is the relative path of the URL that should appear after the OTIS server application name. Below is an example of the noun that would be used to add an attribute to the john.doe entity:
    AuthenticatedSession/78BD660E0E5F673378BD660E0E5F6733/Entity/john.doe/Attribute
    
  • HTTP Method: POST.
  • Request/Response message details: <Attribute> element details.
  • Description: Creates a new attribute on the specified entity.

Java

The following is example Java code that demonstrates how to create an attribute on a specified entity:

//The first 3 attributes are mandatory for creating a new entity for this session.  Each session could be different.
IAttribute FirstName = e1.addAttribute(new URI("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname"));
IAttribute LastName = e1.addAttribute(new URI("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname"));
IAttribute EmailAddress = e1.addAttribute(new URI("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"));
IAttribute State = e1.addAttribute(new URI("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/stateorprovince"));
//Add values to the 3 mandatory attributes and one to "State"
FirstName.addSimpleValue(new URI("first"), "Quin");
LastName.addSimpleValue(new URI("last"), "Williams");
EmailAddress.addSimpleValue(new URI("mail"), "qwilliams@novell.com");
State.addSimpleValue(new URI("state"), "Utah");

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 only way to create an attribute using PHP is to create it when you are creating or updating an entity. You can not do it directly. For more information, see Create Entity or Update Entity.

To view the complete PHP sample code for Attribute/Entity nouns, see the Entity/Attribute PHP Sample Code page.

cURL

The following sample code updates a user (note that this code includes line continuations that work on Linux):

if [ -e secret.hdr ] ; then secret=`cat secret.hdr` ; else secret="nosecret: none" ; fi
curl -b cookies.txt -H "${secret}" -X POST -d \
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<tns:EntityChange xmlns:tns=\"http://www.eclipse.org/higgins/idas/rest-xml/2008/6\"
        xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
        xsi:schemaLocation=\"http://www.eclipse.org/higgins/idas/rest-xml/2008/6 ../rest-xml.xsd \"
        xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">
        <tns:Attribute attrID=\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress\">
                <tns:AttributeValue valType=\"http://www.w3.org/2001/XMLSchema#string\">
                        <tns:SimpleData xsi:type=\"xsd:string\">x@yz.com</tns:SimpleData>
                </tns:AttributeValue>
                <tns:AttributeValue valType=\"http://www.w3.org/2001/XMLSchema#string\">
                        <tns:SimpleData xsi:type=\"xsd:string\">x@y.com</tns:SimpleData>
                </tns:AttributeValue>
        </tns:Attribute>
</tns:EntityChange>" \
 https://wag.bandit-project.org/otis/Entity/otistest/
This assumes you have already set up an authenticated session and are using a cookies.txt file to store/retrieve the otisSessionID cookie. It also assumes that the session secret has been stored in a file called secret.hdr (See AuthenticateUser for details).