Attaches the policy to the user
340503
def _attach_inline_policy(self, username, policy_document):
        """"""
        response = self.client.put_user_policy(
            UserName=username,
            PolicyName="threatresponse-temporal-key-revocation",
            PolicyDocument=policy_document
        )
        logger.info(
            'An inline policy has been attached for'
            ' {u} revoking sts tokens.'.format(u=username)
        )
        return response
1010420
def update_snapshot_policy(self, name, policy):
    
    return self._put("snapshots/policies/%s" % name, ApiSnapshotPolicy, data=policy,
        api_version=6)
380804
def detach_user_policy(policy_name, user_name,
                  region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

    policy_arn = _get_policy_arn(policy_name, region, key, keyid, profile)
    try:
        conn.detach_user_policy(policy_arn, user_name)
        log.info('Detached %s policy from IAM user %s.', policy_name, user_name)
    except boto.exception.BotoServerError as e:
        log.debug(e)
        log.error('Failed to detach %s policy from IAM user %s.', policy_name, user_name)
        return False
    return True
480166
def update_storage_policy(profile_manager, policy, policy_spec):
    '''
    
    '''
    try:
        profile_manager.Update(policy.profileId, policy_spec)
    except vim.fault.NoPermission as exc:
        log.exception(exc)
        raise VMwareApiError('Not enough permissions. Required privilege: '
                             '{0}'.format(exc.privilegeId))
    except vim.fault.VimFault as exc:
        log.exception(exc)
        raise VMwareApiError(exc.msg)
    except vmodl.RuntimeFault as exc:
        log.exception(exc)
        raise VMwareRuntimeError(exc.msg)
667728
def _make_policies(self):
        
        self.policies = [AutoScalePolicy(self.manager, dct, self)
                for dct in self.scalingPolicies]
1250450
private function registerPolicyMakeCommand()
    {
        $this->app->bindShared('command.make.package.policy', function ($app)
        {
            return new PolicyMakeCommand($app['files'], $app['packages']);
        });

        $this->commands('command.make.package.policy');
    }
433040
def _put_bucket_policy(self):
        """"""
        if self.s3props['bucket_policy']:
            policy_str = json.dumps(self.s3props['bucket_policy'])
            _response = self.s3client.put_bucket_policy(Bucket=self.bucket, Policy=policy_str)
        else:
            _response = self.s3client.delete_bucket_policy(Bucket=self.bucket)
        LOG.debug('Response adding bucket policy: %s', _response)
        LOG.info('S3 Bucket Policy Attached')
1166842
public void addPolicy(Policy policy) throws PolicyException {

        // Add BlueprintPolicy
        if (policy instanceof BlueprintPolicy) {
            if (erectors.get(policy.getTarget()) == null) {
                throw new PolicyException("Blueprint does not exist for BlueprintPolicy target: " + policy.getTarget());
            }

            List<BlueprintPolicy> policies = blueprintPolicies.get(policy.getTarget());
            if (policies == null) {
                policies = new ArrayList<BlueprintPolicy>();
            }

            policies.add((BlueprintPolicy) policy);

            logger.info("Setting BlueprintPolicy {} for {}", policy, policy.getTarget());

            blueprintPolicies.put(policy.getTarget(), policies);

            // Add FieldPolicy
        } else if (policy instanceof FieldPolicy) {

            // XXX: force FieldPolicy's to be mapped to a blueprint? Limits their scope, but enables validation
            if (erectors.get(policy.getTarget()) == null) {
                throw new PolicyException("Blueprint does not exist for FieldPolicy target: " + policy.getTarget());
            }

            List<FieldPolicy> policies = fieldPolicies.get(policy.getTarget());
            if (policies == null) {
                policies = new ArrayList<FieldPolicy>();
            }

            policies.add((FieldPolicy) policy);

            logger.info("Setting FieldPolicy {} for {}", policy, policy.getTarget());

            fieldPolicies.put(policy.getTarget(), policies);
        }
    }
904468
protected function registerPolicies()
    {
        foreach ($this->policies as $model => $policy) {
            Gate::policy($model, $policy);
        }
    }
458967
@Override
    public boolean updatePolicy(String name, String newDocument)
    throws PolicyStoreException {

        String pid = this.getPID(name);

        if (!contains(name)) {
            throw new PolicyStoreException("Update:  policy " + pid
                                                 + " not found");
        }

        if (datastreamControlGroup.equals("X")) {
            // inline, modify by value
            try {
                this.apiMService
                .modifyDatastreamByValue(getContext(),
                                         pid,
                                         FESL_POLICY_DATASTREAM,
                                         null,
                                         null,
                                         null,
                                         null,
                                         new ByteArrayInputStream(newDocument
                                                                  .getBytes("UTF-8")),
                                                                  "DISABLED",
                                                                  null,
                                                                  "Modifying policy " + pid,
                                                                  null);
            } catch (Exception e) {
                throw new PolicyStoreException("Update:  error modifying datastream by value for "
                                                     + pid
                                                     + " - "
                                                     + e.getMessage(),
                                                     e);
            }

        } else if (datastreamControlGroup.equals("M")) {
            // managed, generate temp location, modify by reference
            String dsLocation = null;
            try {
                ByteArrayInputStream is =
                    new ByteArrayInputStream(newDocument.getBytes("UTF-8"));
                dsLocation = apiMService.putTempStream(getContext(), is);
            } catch (Exception e) {
                throw new PolicyStoreException("Update: error generating temp datastream location - "
                                                     + e.getMessage(),
                                                     e);
            }
            try {
                apiMService.modifyDatastreamByReference(getContext(),
                                                        pid,
                                                        FESL_POLICY_DATASTREAM,
                                                        null,
                                                        null,
                                                        null,
                                                        null,
                                                        dsLocation,
                                                        "DISABLED",
                                                        null,
                                                        "Modifying policy "
                                                        + pid,
                                                        null);
            } catch (ServerException e) {
                throw new PolicyStoreException("Update:  error modifying datastream by reference for "
                                                     + pid
                                                     + " - "
                                                     + e.getMessage(),
                                                     e);
            }

        } else {
            throw new PolicyStoreException("Update:  Invalid datastream control group "
                                                 + datastreamControlGroup + " - use M or X");
        }

        return true;
    }
83478
protected function callPolicyMethod($policy, $method, $user, array $arguments)
    {
        // If this first argument is a string, that means they are passing a class name
        // to the policy. We will remove the first argument from this argument array
        // because this policy already knows what type of models it can authorize.
        if (isset($arguments[0]) && is_string($arguments[0])) {
            array_shift($arguments);
        }

        if (! is_callable([$policy, $method])) {
            return;
        }

        if ($this->canBeCalledWithUser($user, $policy, $method)) {
            return $policy->{$method}($user, ...$arguments);
        }
    }
905706
public function registerPolicies()
    {
        foreach ($this->policies as $key => $value) {
            Gate::policy($key, $value);
        }
    }
690336
def AuthorizeUser(self, user, subject):
    """"""

    user_set = self.authorized_users.setdefault(subject, set())
    user_set.add(user)
694687
public void addPolicy(final ExpirationPolicy policy) {
        LOGGER.trace("Adding expiration policy [{}] with name [{}]", policy, policy.getName());
        this.policies.put(policy.getName(), policy);
    }
115032
def enable(self, policy):
        
        if hasattr(policy, 'href'):
            if not isinstance(policy, InterfacePolicy):
                raise LoadPolicyFailed('Invalid policy type specified. The policy'
                    'type must be InterfacePolicy')
                
        self.update(l2_interface_policy_ref=element_resolver(policy))
320790
protected function addUserRole()
    {
        $this->controlAccess('user_role_add');

        if ($this->role->add($this->getSubmitted())) {
            $this->redirect('admin/user/role', $this->text('Role has been added'), 'success');
        }

        $this->redirect('', $this->text('Role has not been added'), 'warning');
    }
584509
function (name, value) {
            var policy = this.$[name + 'UpdatePolicy'];

            if (policy === POLICY_OUT || policy === POLICY_BOTH) {
                if (value != null && value !== undefined) {
                    this.$el.style[name] = "" + value;
                }
            }

        }