1 /* 2 * Copyright © [2008-2009] Novell, Inc. All Rights Reserved. 3 * 4 * USE AND REDISTRIBUTION OF THIS WORK IS SUBJECT TO THE DEVELOPER LICENSE AGREEMENT 5 * OR OTHER AGREEMENT THROUGH WHICH NOVELL, INC. MAKES THE WORK AVAILABLE. THIS WORK 6 * MAY NOT BE ADAPTED WITHOUT NOVELL'S PRIOR WRITTEN CONSENT. 7 * 8 * NOVELL PROVIDES THE WORK "AS IS," WITHOUT ANY EXPRESS OR IMPLIED WARRANTY, 9 * INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR 10 * A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. NOVELL, THE AUTHORS OF THE WORK, AND THE 11 * OWNERS OF COPYRIGHT IN THE WORK ARE NOT LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER 12 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, 13 * OR IN CONNECTION WITH THE WORK OR THE USE OR OTHER DEALINGS IN THE WORK. 14 */ 15 16 /** 17 * @fileoverview This file defines the Account class. The class allows JavaScript Collectors 18 * to update accounts related to an identity. 19 * @see Identity 20 * @name Account Class 21 */ 22 23 24 /** 25 * Creates a new Account object. 26 * You can pass in a JSON string or a prototype Account object. 27 * @class 28 * The Account class represents a set of credentials that is used to access IT systems. Most 29 * users (actual people) will have several accounts associated with their computing identity. 30 * Additionally, in many cases a single account may have multiple possible representations, 31 * as for example a Windows account may have a domain notation and an LDAP notation. 32 * <p>When using Sentinel to store identity data, you can associate accounts with that 33 * identity using the Identity.attachAccounts() method. 34 * <p>Accounts are exported to a map that is used by the Mapping Service to inject identity 35 * information into real-time events. 36 * @constructor 37 * @param {JSON} properties Initial properties to define account 38 * @see Identity 39 * @see Customer 40 */ 41 function Account(properties) { 42 this.accountImpl = new AccountImpl(properties); 43 return this.accountImpl; 44 45 // Never accessed, but defined here for documentation: 46 /** 47 * Stores the UUID of the associated Identity. 48 * @type UUID 49 */ 50 this.IdentityGuid = null; 51 /** 52 * The base name (not including any authority information such as namespace/domain/container) of the account. 53 * @type String 54 */ 55 this.Name = null; 56 /** 57 * The authority (namespace/domain/container) within which this account exists. 58 * @type String 59 */ 60 this.Authority = null; 61 /** 62 * The status of the account. 63 * <ul> 64 * <li>A - Active 65 * <li>I - Inactive 66 * <li>D - Deleted (we never delete entries, but record them as deleted) 67 * <li>U - Undefined 68 * </ul> 69 * @type Enum 70 */ 71 this.Status = null; 72 /** 73 * The customer ID that owns this account. Should match the MSSP Customer information 74 * injected into event data gathered from the same customer. 75 * @type String 76 * @see Customer 77 */ 78 this.CustomerId = null; 79 } 80 81 /** 82 * This method saves the Account object. 83 * <p>Example: 84 * <pre> 85 * var myAcct = Account.find({IdentityGuid: "5CECEA10-E3DF-102A-91F5-005056C00008"}); 86 * var acct = new Account(myAcct[0]); 87 * acct["Authority"] = "New_Authority"; 88 * acct.save(); 89 * </pre> 90 * @return {Boolean} Result 91 * @throws {String} Throws an string exception describing the error. 92 */ 93 Account.prototype.save = function() { 94 return this.accountImpl.save(); 95 }; 96 97 /** 98 * Finds the account(s) with the same attributes as the passed-in filter. 99 * All attributes are matched as with an AND operator. You can pass in a string in JSON 100 * notation or a prototype Account object. 101 * <p>Example: 102 * <pre> 103 * var myAccts = Account.find({IdentityGuid: "cn=JoeSmith,ou=Active,ou=Users,o=Vault"}); 104 * var myAccts = Account.find({Name : "Joe Smith", Authority : "Novell"}); 105 * </pre> 106 * @param {JSON} params notation of the account attributes 107 * @return {Account[]} Returns an array of Accounts found. The array could be of size 0 if no accounts 108 * match the search criteria. 109 * @throws {String} Throws an string exception describing the error. 110 */ 111 Account.find = function(params){ 112 return AccountImpl.find(params); 113 }; 114 115 /** 116 * This method attaches a trust to an account. 117 * <p>Example: 118 * <pre> 119 * var myAcct = Account.find({IdentityGuid: "5CECEA10-E3DF-102A-91F5-005056C00008"}); 120 * var acct = new Account(myAcct[0]); 121 * acct.attachTrust(new Trust({Name: "Admin", Authority: "Unix", Type: "Role"}); 122 * acct.save(); 123 * </pre> 124 * @throws {String} Throws an string exception describing the error. 125 */ 126 Account.prototype.attachTrust = function(trust) { 127 this.accountImpl.attachTrust(trust); 128 }; 129 130 /** 131 * Retrieves the trust(s) currently associated with this account. If no trusts are 132 * attached, an empty array ([]) will be returned. 133 * <p>Example: 134 *<pre> 135 * var trust1 = new Trust({ 136 Name:"Developer", 137 Authority:"SAP", 138 Description:"SAP Role", 139 Type:"Role", 140 CustomerId:"345"}); 141 * trust1.save(); 142 * var acc = new Account({Name: "ssouth", 143 * Authority: "NOVELL", 144 * Status: "Active", 145 * CustomerId: 17 146 * }); 147 * acc.attachTrust(trust1); 148 * var attachedTrusts = acc.getTrusts(); 149 * </pre> 150 */ 151 Account.prototype.getTrusts = function() { 152 return this.accountImpl.getTrusts(); 153 } 154 155