Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Org.eclipse.higgins.js.pds.client

Revision as of 17:12, 1 September 2011 by Unnamed Poltroon (Talk) (setAttribute(agent, domain, attributes[]))

{{#eclipseproject:technology.higgins|eclipse_custom_style.css}}

Files

Design Notes for API additions to this component

Objective

Create a general purpose API that JavaScript programs executed by HBX can use to get and set attributes about the user.

getAttributes(agent, rp, audience, attributes, where, onReady)

Enables a JavaScript app to request attributes (e.g user's email address, gender, etc.) about the user. It searches the person graph to find the requested attributes. If it finds multiple, ambiguous values for one or more attributes, it returns nothing (and the "where' parameter must be used to refine the query).

  • By setting the value of the authorities = the JavaScript developer's domain (i.e. the "issuer" id of the context associated with this JavaScript) then the caller can force the selector to only read attributes from this context.
  • Depending on how the calling JavaScript is written, information about the user may remain local (i.e. within the browser and/or on the user's machine) or it may be transmitted to some external web service. The identity of the calling application and the identity of the "rp" are parameters to this call.
  • FUTURE: If the attribute release is not part of (i) an explicit pre-existing connection/relationship with the rp or (ii) an implicit relationship (e.g. form filling when the user is viewing the page) then a UI should be implemented informing the user as to the identity of the agent, the identity of rp (the "next hop" destination if any) and the set of requested (required/optional) attributes and allowing them to give consent to this attribute disclosure.

Parameters:

agent
String identifier of the software agent (e.g. JavaScript program) that is getting the attributes and forwarding them to the rp
rp
String identifier of ultimate attribute data consumer as far as this is known. It is expressed in as detailed a form as possible. If the rp is a website then the string is the website domain (e.g. "staples.com")
audience
FUTURE (ignored for now) - String. Must match either the agent or the rp parameter value or be nil. If not nil, then indicates whether to encrypt tokens for the agent or the rp.
attributes
Set of (attribute, optional, authorities) tuples where: attribute is a URI indicating the attribute type. optional is a boolean (if true then this attribute is desired but not required). authorities FUTURE: (must be nil for now) - a list of domains that are considered by the caller as authoritative WRT this attribute and thus must be used as the source of the attribute, if this list is nil then self asserted values are acceptable. The value of a member of authorities is matched against the issuer of the containing context of the entity.
where 
A set of (attribute, value-expression) tuples where: attribute is the attribute URI of the form <namespace>#localAtt and namespace is the URL of a page (or a set of pages with a consistent schema). if the entire site uses the same schema then the site domain will suffice;value-expression (for now) may be an exact value (e.g. "Alice") or may be a regex that the value must match. In the short term the so-called "regex" is just a string of one or more characters followed by an asterisk (e.g. 2*, or 25*)--meaning that the value of the attribute must start with these characters (e.g. values "290" and "250" will match "2*" and "250" (only) will match "25*")
tokenTypes
A list of token types that are understood by RP. At present this must be a JSon document
onReady
Represents name of a JS event listener. If the value of 'onready' is an empty string, then it executes an synchronous query, otherwise it does an asynchronous query. The result will be passed as a parameter to the function onReady

Returns:

  • A set of zero or more tokens (JSon documents at present). Each token encodes multiple (attribute, value(s)) tuples where:
    • Attribute is the attribute URI (note: this will be one of the attribute URIs passed in to this method)
    • Value(s) are the value(s) of the attribute (may be nil, if no values could be found). Each value may be literal or object typed.

Implementation

    • End Loop
      • pathset := mapAttribute(class, att, template))
      • attributeHolder := getAttributeHolder(person, pathset[0]) // (e.g. the entity that directly holds the vcard:given-name attribute & value) (we are assuming here that pathset.size = 1) (this function will return nil if there is ambiguity)
      • If attributeHolder = nil then continue looping
      • value := read value of attribute att from attributeHolder
      • insert value into a token (each token has a different target entity)
      • remove t from attributes[] //because for this attribute we're done


@@@@@ the rest of this document is just random, rough notes copied/pasted here from 2 years ago (plz ignore)

  1. See if connection context pair for RP already exists. If so skip to step 4
  2. Determine candidate entities by a combination of mapping and authority matching
  3. Determine best entities from redundant possible target entities
    1. Determine if we need to pop up the selector UI
    2. Pop up selector UI if necessary
    3. Else automatically select best entities
  4. Copy attributes from best entities into RP context skipping any ambiguous attributes
  5. Read attributes from the RP context, map these attributes, and
  6. Return them

setAttribute(agent, domain, attributes[])

Takes a set of attribute/value pairs. Some of these pairs are used to update existing attributes within the connection-specific context. Update means replacing the existing values of the same attribute (if they exist) or adding them if they do not. All other attributes/values are unaffected. Other pairs are used to add new person attributes (and even add new contexts to hold them) external to the connection-specific context. In the add case existing attribute values are not deleted. Whether we update or add depends on what's found when we lookup the mapping rule for the attribute within the pair. Mapping rules may or may not have non-nil roles (e.g. Buyer, Recipient, etc.). If the attribute's mapping rule has role=nil then

Parameters:

agent
ignored
domain
domain of the party providing the attribute value
attributes
And array of (attribute,value) pairs. The attribute is a URI of the form <namespace>#<localAtt>. For scraping <namespace> is the URL of the page being scraped (with query parameters removed). The value is a literal or object value.

Implementation: (1) Phase I

(2) Phase II

  • Compare newPeople to existing people and see if they are redundant. If so remove them and any dangling h:correlation link to them.

Private Functions

URI setEvalRule (string rule, URI context, value)

We evaluate the rule in "set" mode. See also "getEvalRule". Within the rule string there is the name of the rule to fire, and a set of parameter/values. We call dispatch functions by name.

  • mappingRule := getRuleName(rule) // e.g. "rolePathLiteral"
  • If (mappingRule == "rolePathLiteral") then
    • newPerson := setRolePathLiteral(context, rule, value)
    • return newPerson
  • If (mappingRule == ... ) then ...

return newPerson

URI getConnectionContext(string domain)

Return:

  • http://<servername>/<pdsuser>/domain

URI getConnectionTemplate(string domain)

Return:

  • http://<servername>/<pdsuser>/template/domain

string getLocalAtt (URI attribute)

Return everything to the right of the #. (e.g. if the input was http://staples.com/office/supplies/StaplescheckoutFlow#bFirstName then return "bFirstName").

URI getNamespace (URI attribute)

Return all but the # and beyond. (e.g. if the input was http://staples.com/office/supplies/StaplescheckoutFlow#bFirstName then return http://staples.com/office/supplies/StaplescheckoutFlow).

string getRule(URI template, URI class, string localAtt)

Find a matching mapping rule in the class entity class within this template. Look through all the values of spin:rule attribute (or sub-attribute, e.g. map:nameRule) of the entity class such that the attribute map:predicate matches localAtt (e.g. bFirstName). For example here is a match:

     map:nameRule
             [ rdf:type map:rolePathLiteral ;
               map:mappedAtt <http://www.w3.org/2006/vcard/ns#given-name> ;
               map:path <http://www.w3.org/2006/vcard/ns#n> ;
               map:predicate :bFirstName ;
               map:role p:Buyer
             ] ;

URI getTemplate (URI context)

Returns value of template attribute of context

URI setRolePathLiteral(URI context, string rule, value)

  • role := getRoleParam(rule)
  • path := getPathParam(rule)
  • mappedAtt := getMappedAtt(rule)
  • If (role == nil) then
    • if path exists from :me then follow it (if not then build it)
    • replace the value of mappedAtt with new value
  • Else
    • find a person from :me one hop out along h:correlation links who has role value of role
    • if it isn't there then build a new context and create it (and remember to return it)
    • if it is there then walk path/mappedAtt
  • EndIf

ruleSet[] mapAttribute(att, template, class)

Parameters:

att
string - short name of attribute in the original ontology
template
URI of the template context
class
- string name of the p:Person subclass (e.g. "http://staples.com/Office-supplies-StaplesCheckoutFlow")

This routine is the heart of the mapping process. It takes an short name att in one ontology (e.g. the "facebook.com" ontology) and finds an equivalent set of attribute paths in the Persona Data Model. For example it could take facebook's notion of "firstname" and find that this has the same semantics as the PDM's "vcard:given-name" attribute. Thus the string value "Alice" found on some p:Person in some context could be safely copied/used as the value of the "firstname" field on form on a facebook.com web page.

Look for a spin:rule within class such that the attribute map:predicate matches att (e.g. bFirstName). For example here is a match:

     map:nameRule
             [ rdf:type map:rolePathLiteral ;
               map:mappedAtt <http://www.w3.org/2006/vcard/ns#given-name> ;
               map:path <http://www.w3.org/2006/vcard/ns#n> ;
               map:predicate :bFirstName ;
               map:role map:roleParam
             ] ;

Return ruleSet[0] = the above rule (the part in the square brackets).

getSuggestions(attribute, onready)

Note: For privacy reasons this method may only be called by highly trusted JavaScript.

Parameters:

attribute
the attribute type string (HTML form element id)
onready
represents event listener (name of the JS function). if value of 'onready' is empty string, BX does a synchronous request, otherwise BX does an asynchronous request, the result will be passed like parameter to function 'onready'.


JS Example of asynchronous request:

 function onSuggestions(res){
 	//...
 };
 //...
 bx.getSuggestions(attribute, 'onSuggestions');

JS Example of synchronous request:

 res = bx.getSuggestions(attribute, );

Back to the top