Add one or more access control rules to the given public key

@param {String} publicKey The public key to add rules to
@param {Array} rules Array of access control rules to add
@param {Function} callback
@return {ImboClient}
424907
function(publicKey, rules, callback) {
        if (!Array.isArray(rules)) {
            rules = [rules];
        }

        if (!publicKey) {
            throw new Error('Public key must be a valid string');
        }

        var url = this.getResourceUrl({ path: '/keys/' + publicKey + '/access', user: null });

        request({
            method: 'POST',
            uri: this.getSignedResourceUrl('POST', url),
            json: rules,
            onComplete: function(err, res, body) {
                callback(err, body, res);
            }
        });

        return this;
    }
334402
function addProtectedCallback(eventName, callback) {
    oboeBus(eventName).on(protectedCallback(callback), callback);
    return oboeApi; // chaining
  }
129018
def add_public_key(self, did, public_key):
        
        logger.debug(f'Adding public key {public_key} to the did {did}')
        self._public_keys.append(
            PublicKeyBase(did, **{"owner": public_key, "type": "EthereumECDSAKey"}))
826180
public function deleteAccessControlRule($publicKey, $ruleId) {
        $this->validatePublicKeyName($publicKey);

        return $this->getCommand('DeleteAccessControlRule', array(
            'publicKey' => $publicKey,
            'id' => $ruleId,
        ))->execute();
    }
1294839
function(request, username, password, callback) {
    const user = users[username];
    if (!user) {
        return callback(null, false);
    }
    const isValid = password === user.password;
    callback(null, isValid, { id: user.id, name: user.name });
}
1134366
def create_public_key_from_json(values):
        """"""
        # currently we only support RSA public keys
        _id = values.get('id')
        if not _id:
            # Make it more forgiving for now.
            _id = ''
            # raise ValueError('publicKey definition is missing the "id" value.')

        if values.get('type') == PUBLIC_KEY_TYPE_RSA:
            public_key = PublicKeyRSA(_id, owner=values.get('owner'))
        else:
            public_key = PublicKeyBase(_id, owner=values.get('owner'), type='EthereumECDSAKey')

        public_key.set_key_value(values)
        return public_key
49229
function(publicKey, privateKey, callback) {
        this.publicKeyExists(publicKey, function onPubKeyExistsResponse(err, exists) {
            if (err) {
                return callback(err);
            }

            if (exists) {
                return callback(new Error(
                    'Public key `' + publicKey + '` already exists'
                ));
            }

            this.editPublicKey(publicKey, privateKey, callback);
        }.bind(this));

        return this;
    }
719227
function(err, privkey, pubkey) {
      if (err) throw err;
      this.pubkey = pubkey;
      this.privkey = privkey;
      this.user_host_field = pubkey.split(' ')[2].trim();
      console.log("Adding Heroku SSH keypair via API");
      add_ssh_key(api_key, pubkey, this);
    }
1110890
function OAuthToken( key, secret ){
    if( ! key || ! secret ){
        throw new Error('OAuthToken params must not be empty');
    }
    this.key = key;
    this.secret = secret;
}
1271223
def create_key(kwargs=None, call=None):
    '''
    
    '''
    if call != 'function':
        log.error(
            'The create_key function must be called with -f or --function.'
        )
        return False

    try:
        result = query(
            method='account',
            command='keys',
            args={'name': kwargs['name'],
                  'public_key': kwargs['public_key']},
            http_method='post'
        )
    except KeyError:
        log.info('`name` and `public_key` arguments must be specified')
        return False

    return result
862962
function(inputValue, ruleValue, attribute, callback) {
    var _this = this;
    this._setValidatingData(attribute, inputValue, ruleValue);
    if (typeof callback === 'function') {
      this.callback = callback;
      var handleResponse = function(passes, message) {
        _this.response(passes, message);
      };

      if (this.async) {
        return this._apply(inputValue, ruleValue, attribute, handleResponse);
      } else {
        return handleResponse(this._apply(inputValue, ruleValue, attribute));
      }
    }
    return this._apply(inputValue, ruleValue, attribute);
  }
1230726
function accessControlOwn (accessControl) {
    // if session has accessId set and it is used for model then use it
    if (defined(this.session.accessId) && this.session.accessIdName === this.model.accessIdName) {
        // add access id to args
        this.args.accessIdName = this.session.accessIdName
        this.args.accessId = this.session.accessId
    }
    // otherwise try account id
    else if (defined(this.session.accountId) && this.model.defaultColumnsInverse.accountId) {
        // add access id to args
        this.args.accessIdName = 'accountId'
        this.args.accessId = this.session.accountId
    }
    // otherwise deny access because no access id available
    else {
        httpError(403, null, accessControl.audit)
    }
}
64438
function setRuleModel (roles, rule, rules, origRule) {
    // allow/deny is last element of rule
    var allow = rule.pop()
    // blanket rule for all models
    if (rule.length === 0) {
        // create role access rule map
        if (!rules.allow) {
            rules.allow = {}
        }
        // set rule for each role
        _.each(roles, role => {
            rules.allow[role] = allow
        })
        // break
        return
    }

    // model name is first clause of rule
    var model = rule.shift()
    // create map of models
    if (!rules.model) {
        rules.model = {}
    }
    // create entry for model
    if (!rules.model[model]) {
        rules.model[model] = {}
    }

    // blanket rule for single model
    if (rule.length === 0) {
        // create role access rule map
        if (!rules.model[model].allow) {
            rules.model[model].allow = {}
        }
        // set rule for each role
        _.each(roles, role => {
            rules.model[model].allow[role] = allow
        })
        // break
        return
    }

    // action follows model name
    var action = rule.shift()
    // create map of actions
    if (!rules.model[model].action) {
        rules.model[model].action = {}
    }
    // create entry for action
    if (!rules.model[model].action[action]) {
        rules.model[model].action[action] = {}
    }

    // create action does not have any options
    if (action === 'create') {
        // there should be no more rule clauses
        if (rule.length === 0) {
            // create role access rule map
            if (!rules.model[model].action[action].allow) {
                rules.model[model].action[action].allow = {}
            }
            // set rule for each role
            _.each(roles, role => {
                rules.model[model].action[action].allow[role] = allow
            })
            // break
            return
        }
        else {
            throw new Error('invalid rule '+origRule)
        }
    }
    // all other actions apply to existing model instances and can
    // apply either to any instance or to instances owned by session
    else {
        // if there are two rule clauses then next is a state
        if (rule.length === 2) {
            var state = rule.shift()
            // create map of states
            if (!rules.model[model].action[action].state) {
                rules.model[model].action[action].state = {}
            }
            // create entry for state
            if (!rules.model[model].action[action].state[state]) {
                rules.model[model].action[action].state[state] = {}
            }
            // own/any clause follows state
            rules = rules.model[model].action[action].state[state]
        }
        // otherwise own/any clause follows action
        else {
            rules = rules.model[model].action[action]
        }
        // there must be one additional rule clause
        if (rule.length === 1) {
            var scope = rule.shift()
            // scope must be own or any
            assert.ok(scope === 'own' || scope === 'any', 'invalid rule '+origRule)
            // create map for scope
            if (!rules[scope]) {
                rules[scope] = {}
            }
            // create role access rule map
            if (!rules[scope].allow) {
                rules[scope].allow = {}
            }
            // set rule for each role
            _.each(roles, role => {
                rules[scope].allow[role] = allow
            })
        }
        else {
            throw new Error('invalid rule '+origRule)
        }
    }
}
1185388
function (property, callback) {
        // if only one arg we count the collection
        if ([].slice.call(arguments).length === 1) {
            callback = property 
            property = 'key'
        } 
        var c = 0 
        this.each(function(e){
            if (e[property]) c++
        })
        this.fn('count', callback).call(this, c)
    }
942988
function (_callback)
    {
        Strophe.error("Server did not send any auth methods");
        this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "Server did not send any auth methods");
        if (_callback) {
            _callback = _callback.bind(this._conn);
            _callback();
        }
        this._conn._doDisconnect();
    }
271009
public function setPublicKey(\OAuth2\ServerBundle\Entity\ClientPublicKey $public_key = null)
    {
        $this->public_key = $public_key;

        return $this;
    }
1005488
function(args) {
        var result = [], callback;
        var rules = build_rules(this.filters, this._rules);
        var tokens = args.concat([]);
        var token;
        while(this._halt == false && (token = tokens.shift())) {
            if(LONG_SWITCH_RE.test(token) || SHORT_SWITCH_RE.test(token)) {
                var arg = undefined;
                // The token is a long or a short switch. Get the corresponding
                // rule, filter and handle it. Pass the switch to the default
                // handler if no rule matched.
                for(var i = 0; i < rules.length; i++) {
                    var rule = rules[i];
                    if(rule.long == token || rule.short == token) {
                        if(rule.filter !== undefined) {
                            arg = tokens.shift();
                            if(!LONG_SWITCH_RE.test(arg) && !SHORT_SWITCH_RE.test(arg)) {
                                try {
                                    arg = rule.filter(arg);
                                } catch(e) {
                                    throw OptError(token + ': ' + e.toString());
                                }
                            } else if(rule.optional_arg) {
                                tokens.unshift(arg);
                            } else {
                                throw OptError('Expected switch argument.');
                            }
                        }
                        callback = this.on_switches[rule.name];
                        if (!callback) callback = this.on_switches['*'];
                        if(callback) callback.apply(this, [rule.name, arg]);
                        break;
                    }
                }
                if(i == rules.length) this.default_handler.apply(this, [token]);
            } else {
                // Did not match long or short switch. Parse the token as a
                // normal argument.
                callback = this.on_args[result.length];
                result.push(token);
                if(callback) callback.apply(this, [token]);
            }
        }
        return this._halt ? this.on_halt.apply(this, [tokens]) : result;
    }