authorizations ///////////////////////////////////////////////////////////
976373
public void fireAuthorizationProvider() {
    PropertyChange assigneePropertyChange = propertyChanges.get(ASSIGNEE);
    if (assigneePropertyChange != null) {
      String oldAssignee = assigneePropertyChange.getOrgValueString();
      String newAssignee = assigneePropertyChange.getNewValueString();
      fireAssigneeAuthorizationProvider(oldAssignee, newAssignee);
    }

    PropertyChange ownerPropertyChange = propertyChanges.get(OWNER);
    if (ownerPropertyChange != null) {
      String oldOwner = ownerPropertyChange.getOrgValueString();
      String newOwner = ownerPropertyChange.getNewValueString();
      fireOwnerAuthorizationProvider(oldOwner, newOwner);
    }
  }
979523
protected function authorization()
    {
        $this->gate();

        Telescope::auth(function ($request) {
            return app()->environment('local') ||
                   Gate::check('viewTelescope', [$request->user()]);
        });
    }
1278815
private boolean isAuthorized(EventHandler handler, Map<String,String> headers)
    throws AuthorizationException {
        // Exclude unless it is REST or SOAP (i.e. HTTP)
        if (!Listener.METAINFO_PROTOCOL_REST.equals(headers.get(Listener.METAINFO_PROTOCOL)) && !Listener.METAINFO_PROTOCOL_SOAP.equals(headers.get(Listener.METAINFO_PROTOCOL)))
            return true;

        String userId = headers.get(Listener.AUTHENTICATED_USER_HEADER);
        User user = null;

        List<String> roles = handler.getRoles();
        if (roles != null && !roles.isEmpty()) {
            if (userId != null)
                user = UserGroupCache.getUser(userId);
            if (user == null)
                throw new AuthorizationException(ServiceException.NOT_AUTHORIZED, "Event Handler " + handler.getClass().getSimpleName() + " requires authenticated user");
            for (String role : roles) {
                if (user.hasRole(role))
                    return true;
            }
            throw new AuthorizationException(ServiceException.NOT_AUTHORIZED, "User: " + userId + " not authorized for: " + handler.getClass().getSimpleName());
        }
        return true;
    }
688317
def _do_authorize(self):
        
        if self.auth_data is None:
            raise ApiwatcherClientException("You must provide authorization data.")

        r = requests.post(
            "{0}/api/token".format(self.base_url), json=self.auth_data,
            verify=self.verify_certificate, timeout=self.timeout
        )

        if r.status_code == 401:
            raise ApiwatcherClientException("Wrong credentials supplied: {0}".format(
                r.json()["message"]
            ))
        elif r.status_code != 201:
            try:
                reason = r.json()["message"]
            except:
                reason = r.text
            raise ApiwatcherClientException(
                "Authorization failed. Reason {0} {1}".format(
                    r.status_code, reason)
                )
        else:
            data = r.json()["data"]
            self.token = data["access_token"]

            if "refresh_token" in data:
                self.auth_data = {
                    "grant_type": "refresh_token",
                    "refresh_token": data["refresh_token"],
                    "client_id": self.auth_data["client_id"]
                }
1322673
function access(permission, account, callback) {
  // User #1 has all privileges:
  if (account.uid === 1) {
    callback(null, true);
    return;
  }

  // If permissions is already loaded, use them.
  if (account.permissions) {
    callback(null, account.permissions.indexOf(permission) > -1);
    return;
  }

  role_permissions(account.roles, function (err, permissions) {
    if (err) {
      callback(err);
      return;
    }

    callback(null, permissions.indexOf(permission) > -1);
  });
}
1189331
function getAuthorization(user, auth) {
    if (auth === AUTH_BASIC) {
        return 'Basic ' + btoa(user.username + ':' + user.password);
    } else if (auth === AUTH_TOKEN) {
        return 'Token token=' + user.token;
    }
}
686474
def authorized?(action, subject)
      policy = context.send :policy, subject
      ModuleUtils.try_to policy, normalize(action)
    end
297029
def authorize(self, ctx, identity, ops):
        '''
        '''
        allowed = []
        caveats = []
        for op in ops:
            ok, fcaveats = self._f(ctx, identity, op)
            allowed.append(ok)
            if fcaveats is not None:
                caveats.extend(fcaveats)
        return allowed, caveats
952359
public static void httpComponent(HttpPut request, String auth) {
        auth = auth + "password";
        request.addHeader("Authorization", Base64.encodeBase64String(auth.getBytes(StandardCharsets.UTF_8)));
    }
690336
def AuthorizeUser(self, user, subject):
    """"""

    user_set = self.authorized_users.setdefault(subject, set())
    user_set.add(user)
230491
public void setAuthorizationRules(java.util.Collection<AuthorizationRule> authorizationRules) {
        if (authorizationRules == null) {
            this.authorizationRules = null;
            return;
        }

        this.authorizationRules = new com.amazonaws.internal.SdkInternalList<AuthorizationRule>(authorizationRules);
    }
182819
def permitted_to! (privilege, options = {} )
      options = {
        :user =>  Authorization.current_user,
        :object => self
      }.merge(options)
      Authorization::Engine.instance.permit!(privilege,
          {:user => options[:user],
           :object => options[:object]})
    end
972095
def authorize(*args, **kwargs):
    """"""
    if request.method == 'GET':
        client = Client.query.filter_by(
            client_id=kwargs.get('client_id')
        ).first()

        if not client:
            abort(404)

        scopes = current_oauth2server.scopes
        ctx = dict(
            client=client,
            oauth_request=kwargs.get('request'),
            scopes=[scopes[x] for x in kwargs.get('scopes', [])],
        )
        return render_template('invenio_oauth2server/authorize.html', **ctx)

    confirm = request.form.get('confirm', 'no')
    return confirm == 'yes'
950964
static Authorizations escape(Authorizations auths) {
        ArrayList<byte[]> retAuths = new ArrayList<byte[]>(auths.getAuthorizations().size());

        for (byte[] auth : auths.getAuthorizations()) {
            retAuths.add(escape(auth, false));
        }

        return new Authorizations(retAuths);
    }
511355
public Set<Permission> authorize(AuthenticatedUser user, IResource resource)
    {
        if (user.isSuper())
            return Permission.ALL;

        UntypedResultSet result;
        try
        {
            ResultMessage.Rows rows = authorizeStatement.execute(QueryState.forInternalCalls(),
                                                                 QueryOptions.forInternalCalls(ConsistencyLevel.LOCAL_ONE,
                                                                                               Lists.newArrayList(ByteBufferUtil.bytes(user.getName()),
                                                                                                                  ByteBufferUtil.bytes(resource.getName()))));
            result = UntypedResultSet.create(rows.result);
        }
        catch (RequestValidationException e)
        {
            throw new AssertionError(e); // not supposed to happen
        }
        catch (RequestExecutionException e)
        {
            logger.warn("CassandraAuthorizer failed to authorize {} for {}", user, resource);
            return Permission.NONE;
        }

        if (result.isEmpty() || !result.one().has(PERMISSIONS))
            return Permission.NONE;

        Set<Permission> permissions = EnumSet.noneOf(Permission.class);
        for (String perm : result.one().getSet(PERMISSIONS, UTF8Type.instance))
            permissions.add(Permission.valueOf(perm));
        return permissions;
    }
223369
def get_authorizations_by_search(self, authorization_query, authorization_search):
        """"""
        # Implemented from azosid template for -
        # osid.resource.ResourceSearchSession.get_resources_by_search_template
        if not self._can('search'):
            raise PermissionDenied()
        return self._provider_session.get_authorizations_by_search(authorization_query, authorization_search)
1166914
function getParams(user, auth, url, options, headers) {
    return _.extend({
        url: url,
        headers: _.extend({
            'User-Agent': user.userAgent,
            'Authorization': getAuthorization(user, auth)
        }, headers)
    }, options);
}