Get a list of access control rules for a given public key

@param {String} publicKey
@param {Boolean} expandGroups
@param {Function} callback
@return {ImboClient}
550141
function(publicKey, expandGroups, callback) {
        var qs = '';
        if (!callback && typeof expandGroups === 'function') {
            callback = expandGroups;
        } else if (expandGroups) {
            qs = '?expandGroups=1';
        }

        request.get(
            this.getResourceUrl({ path: '/keys/' + publicKey + '/access' + qs, user: null }),
            function onAccessControlRulesResponse(err, res, body) {
                callback(err, body, res);
            }
        );
        return this;
    }
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;
    }
912925
def public_key
      keys = Array(@options[:ssh][:keys])
      keys << '~/.ssh/id_rsa'
      keys << '~/.ssh/id_dsa'
      key_file = keys.find do |key|
        key_pub = key + '.pub'
        File.exist?(File.expand_path(key_pub)) && File.exist?(File.expand_path(key))
      end

      if key_file
        @logger.debug("Using public key: #{key_file}")
      else
        raise RuntimeError, "Expected to find a public key, but couldn't in #{keys}"
      end
      File.read(File.expand_path(key_file + '.pub'))
    end
1179663
function findPublicKey(context) {
    var fingerprints = context.resPQ.server_public_key_fingerprints.getList();
    if (logger.isDebugEnabled()) {
        logger.debug('Public keys fingerprints from server: %s', fingerprints);
    }
    for (var i = 0; i < fingerprints.length; i++) {
        var fingerprint = fingerprints[i];
        if (logger.isDebugEnabled()) {
            logger.debug('Searching fingerprint %s in store', fingerprint);
        }
        var publicKey = security.PublicKey.retrieveKey(fingerprint);
        if (publicKey) {
            if (logger.isDebugEnabled()) {
                logger.debug('Fingerprint %s found in keyStore.', fingerprint);
            }
            context.fingerprint = fingerprint;
            context.publicKey = publicKey;
            return context;
        }
    }
    throw createError('Fingerprints from server not found in keyStore.', 'EFINGERNOTFOUND');
}
1206905
public static BaseResult groupsMembersUpdate(String access_token,String openid,String to_groupid){
		String groupJson = "{\"openid\":\""+openid+"\",\"to_groupid\":"+to_groupid+"}";
		HttpUriRequest httpUriRequest = RequestBuilder.post()
										.setHeader(jsonHeader)
										.setUri(BASE_URI+"/cgi-bin/groups/members/update")
										.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
										.setEntity(new StringEntity(groupJson,Charset.forName("utf-8")))
										.build();
		return LocalHttpClient.executeJsonResult(httpUriRequest,BaseResult.class);
	}
663185
function listKeys(args) {
    return new Promise((rslv) => {
        const bInfo = (args && args.info === 'true');
        const re = {};
        if (bInfo) re._info={leaf: false};
        for (let i=0; i<localStorage.length; i++) {
            const key = localStorage.key(i);
            if (key == 'MACtoIP') continue;
            re[key] = {};
            if (bInfo) {
                const size = localStorage.getItem(key).length;
                re[key]._info = {
                    doc: {
                        short: size + ' byte',
                        // ,long : 'Optional long message'
                    },
                    leaf: true,
                };
            }
        }
        rslv(re);
    });
}
497655
@SuppressWarnings("unchecked")
    protected void handleGroupPrincipalCallback(GroupPrincipalCallback callback) throws CustomRegistryException, EntryNotFoundException, RemoteException {
        Subject clientSubject = callback.getSubject();
        Hashtable<String, Object> credData = null;
        if (clientSubject != null) {
            String[] groupsFromCallback = callback.getGroups();
            if (groupsFromCallback != null && groupsFromCallback.length > 0) {
                if (tc.isDebugEnabled()) {
                    Tr.debug(tc, "Group names in Callback: ", Arrays.asList(groupsFromCallback));
                }
                credData = getSubjectCustomData(clientSubject);
                List<String> groupsFromSubject = (List<String>) credData.get(AttributeNameConstants.WSCREDENTIAL_GROUPS);
                if (groupsFromSubject == null) {
                    groupsFromSubject = new ArrayList<String>();
                    credData.put(AttributeNameConstants.WSCREDENTIAL_GROUPS, groupsFromSubject);
                }

                for (int i = 0; i < groupsFromCallback.length; i++) {
                    String groupFromCallback = groupsFromCallback[i];
                    if (groupFromCallback == null || groupFromCallback.isEmpty()) {
                        if (tc.isDebugEnabled()) {
                            Tr.debug(tc, "Group is null or an empty string, it has been ignored.");
                        }
                        continue;
                    }

                    String group = mapGroup(groupFromCallback);

                    if (!groupsFromSubject.contains(group)) {
                        groupsFromSubject.add(group);
                        if (tc.isDebugEnabled()) {
                            Tr.debug(tc, "Added groupId: " + group);
                        }
                    } else {
                        if (tc.isDebugEnabled()) {
                            Tr.debug(tc, group + " already exists in custom credential data, avoid duplicates.");
                        }
                    }
                }
            } else {
                if (tc.isDebugEnabled()) {
                    Tr.debug(tc, "Callback has no groups.");
                }
            }
        }
        if (tc.isDebugEnabled()) {
            Tr.debug(tc, "handleGroupPrincipalCallback", credData);
        }
    }
1271251
function getFormApps(connections, options, cb) {
  var validate = validation(options);
  function validateParams(cb) {
    validate.has("formId",cb);
  }
  validateParams(function(err) {
    if (err) {
      return cb(err);
    }
    var conn = connections.mongooseConnection;
    var appFormsModel = models.get(conn, models.MODELNAMES.APP_FORMS);
    var formId = options.formId;
    var restrictToUser = options.restrictToUser;

    groups.validateFormAllowedForUser(connections, restrictToUser, formId, function(err) {
      if (err) {
        return cb(err);
      }

      groups.getAppsForUser(connections, restrictToUser, function(err, allowedApps) {
        var query = {forms: formId};
        if (allowedApps) {
          query.apps = {$in: allowedApps};
        }
        appFormsModel.find(query).exec(function(err, apps) {
          if (err) {
            return cb(err);
          }
          return cb(null, apps);
        });
      });

    });
  });
}
918421
private Promise<UserKeys> fetchUserGroups(final int uid) {

        User user = users().getValue(uid);
        if (user == null) {
            throw new RuntimeException("Unable to find user #" + uid);
        }

        final UserKeys userKeys = getCachedUserKeys(uid);
        if (userKeys != null) {
            return Promise.success(userKeys);
        }

        return api(new RequestLoadPublicKeyGroups(new ApiUserOutPeer(uid, user.getAccessHash())))
                .map(new Function<ResponsePublicKeyGroups, ArrayList<UserKeysGroup>>() {
                    @Override
                    public ArrayList<UserKeysGroup> apply(ResponsePublicKeyGroups response) {
                        ArrayList<UserKeysGroup> keysGroups = new ArrayList<>();
                        for (ApiEncryptionKeyGroup keyGroup : response.getPublicKeyGroups()) {
                            UserKeysGroup validatedKeysGroup = validateUserKeysGroup(uid, keyGroup);
                            if (validatedKeysGroup != null) {
                                keysGroups.add(validatedKeysGroup);
                            }
                        }
                        return keysGroups;
                    }
                })
                .map(new Function<ArrayList<UserKeysGroup>, UserKeys>() {
                    @Override
                    public UserKeys apply(ArrayList<UserKeysGroup> userKeysGroups) {
                        UserKeys userKeys = new UserKeys(uid, userKeysGroups.toArray(new UserKeysGroup[userKeysGroups.size()]));
                        cacheUserKeys(userKeys);
                        return userKeys;
                    }
                });
    }
427553
function(bucket, keys, cb){
		contract(arguments)
			.params('string', 'array', 'function')
			.end()
		;
		
		var table = '';
		if (bucket.indexOf('allows') != -1) {
			table = this.prefix + this.buckets.permissions;
			this.db
				.select('key', 'value')
				.from(table)
				.where({'key': bucket})
				.then(function(results) {
					if (results.length && results[0].value) {
						var keyArrays = [];
						_.each(keys, function(key) {
							keyArrays.push.apply(keyArrays, results[0].value[key]);
						});
						cb(undefined, _.union(keyArrays));
					} else {
						cb(undefined, []);
					}
					
				})
			;
		} else {
			table = this.prefix + bucket;
			this.db
				.select('key', 'value')
				.from(table)
				.whereIn('key', keys)
				.then(function(results) {
					if (results.length) {
						var keyArrays = [];
						_.each(results, function(result) {
							keyArrays.push.apply(keyArrays, result.value);
						});
						cb(undefined, _.union(keyArrays));
					} else {
						cb(undefined, []);
					}
				})
			;
		}
	}
826180
public function deleteAccessControlRule($publicKey, $ruleId) {
        $this->validatePublicKeyName($publicKey);

        return $this->getCommand('DeleteAccessControlRule', array(
            'publicKey' => $publicKey,
            'id' => $ruleId,
        ))->execute();
    }
296052
function ImmutableAccessControlAudit (args) {
    // require access control id
    assert.ok(defined(args.accessControlId), 'accessControlId required')
    // require valid allow type
    assert.ok(defined(validAllowTypes[args.allowType]), `invalid allowType ${args.allowType}`)
    // initialize aduit record
    this.accessControlId = args.accessControlId
    this.allowArgs = args.allowArgs
    this.allowType = args.allowType
    // list of evaluated rules
    this.rules = []
    // optional boolean for whether or not access allowed
    this.allow = undefined
    // optional scope that access allowed for
    this.scope = undefined
    // set to true when allow request resolved
    this.complete = false
}
1225157
private static String mapXmlAclsToCannedPolicy(
            AccessControlPolicy policy) throws S3Exception {
        if (!policy.owner.id.equals(FAKE_OWNER_ID)) {
            throw new S3Exception(S3ErrorCode.NOT_IMPLEMENTED);
        }

        boolean ownerFullControl = false;
        boolean allUsersRead = false;
        if (policy.aclList != null) {
            for (AccessControlPolicy.AccessControlList.Grant grant :
                    policy.aclList.grants) {
                if (grant.grantee.type.equals("CanonicalUser") &&
                        grant.grantee.id.equals(FAKE_OWNER_ID) &&
                        grant.permission.equals("FULL_CONTROL")) {
                    ownerFullControl = true;
                } else if (grant.grantee.type.equals("Group") &&
                        grant.grantee.uri.equals("http://acs.amazonaws.com/" +
                                "groups/global/AllUsers") &&
                        grant.permission.equals("READ")) {
                    allUsersRead = true;
                } else {
                    throw new S3Exception(S3ErrorCode.NOT_IMPLEMENTED);
                }
            }
        }

        if (ownerFullControl) {
            if (allUsersRead) {
                return "public-read";
            }
            return "private";
        } else {
            throw new S3Exception(S3ErrorCode.NOT_IMPLEMENTED);
        }
    }
133916
function buildBastionSecurityGroup(sourceIp = '0.0.0.0/0', { name = 'BastionSecurityGroup' } = {}) {
  return {
    [name]: {
      Type: 'AWS::EC2::SecurityGroup',
      Properties: {
        GroupDescription: 'Bastion Host',
        VpcId: {
          Ref: 'VPC',
        },
        SecurityGroupIngress: [
          {
            Description: 'Allow inbound SSH access to the bastion host',
            IpProtocol: 'tcp',
            FromPort: 22,
            ToPort: 22,
            CidrIp: sourceIp,
          },
          {
            Description: 'Allow inbound ICMP to the bastion host',
            IpProtocol: 'icmp',
            FromPort: -1,
            ToPort: -1,
            CidrIp: sourceIp,
          },
        ],
        Tags: [
          {
            Key: 'Name',
            Value: {
              'Fn::Join': [
                '-',
                [
                  {
                    Ref: 'AWS::StackName',
                  },
                  'bastion',
                ],
              ],
            },
          },
        ],
      },
    },
  };
}
579339
function (handler, group, callback) {

    if (typeof group === 'function') {
      callback = group;
      group = undefined;
    }

    const validation = cache.get(constant.SYSTEM_DB_VALIDATOR).filter(item => {
      return item.group === (group || handler.req.path);
    });

    async.mapSeries(validation, (item, next) => {

      const func = rule[item.rule];
      if (func) {
        return func.call(this, handler, item, next);
      }

      log.debug('Rule does not define : ' + item.rule);
      next();
    }, (err, result) => {
      if (err) {
        return callback(err);
      }

      result = _.compact(_.flatten(result));
      if (_.isEmpty(result)) {
        return callback();
      }

      log.info(result);
      callback(new error.ParamError(), result);
    });
  }
583900
def get_securitygroup(self, group_id, **kwargs):
        
        if 'mask' not in kwargs:
            kwargs['mask'] = (
                'id,'
                'name,'
                'description,'
                '''rules[id, remoteIp, remoteGroupId,
                         direction, ethertype, portRangeMin,
                         portRangeMax, protocol, createDate, modifyDate],'''
                '''networkComponentBindings[
                    networkComponent[
                        id,
                        port,
                        guest[
                            id,
                            hostname,
                            primaryBackendIpAddress,
                            primaryIpAddress
                        ]
                    ]
                ]'''
            )

        return self.security_group.getObject(id=group_id, **kwargs)
962483
function () {
			var aOutput = [];

			_aRuns.forEach(function (oRun) {
				var oTmp = _generateRootLevelKeys(oRun);

				for (var sLibraryName in oRun.rules) {
					_generateLibraryStructure(oTmp, sLibraryName, oRun);

					for (var sRuleName in oRun.rules[sLibraryName]) {
						_generateRuleStructure(oTmp, sLibraryName, sRuleName, oRun);
					}
				}

				aOutput.push(oTmp);
			});

			return aOutput;
		}