all PermissionTemplate release & visibility data attributes (if not blank or false)
542661
def attributes_for(permission_template:)
        {}.tap do |attrs|
          attrs['data-sharing'] = sharing?(permission_template: permission_template)
          # Either add "no-delay" (if immediate release) or a specific release date, but not both.
          if permission_template.release_no_delay?
            attrs['data-release-no-delay'] = true
          elsif permission_template.release_date.present?
            attrs['data-release-date'] = permission_template.release_date
          end
          attrs['data-release-before-date'] = true if permission_template.release_before_date?
          attrs['data-visibility'] = permission_template.visibility if permission_template.visibility.present?
        end
      end
683537
protected void checkTemplate() {

        if (CmsStringUtil.isEmptyOrWhitespaceOnly(m_simpleFieldFolderName.getValue())) {
            return;
        }
        if (!m_clonedCms.existsResource(getSiteRoot())) {
            return;
        }
        try {
            String templateValue = m_clonedCms.readPropertyObject(
                getSiteRoot(),
                CmsPropertyDefinition.PROPERTY_TEMPLATE,
                false).getValue();
            m_simpleFieldTemplate.addItem(templateValue);
            m_simpleFieldTemplate.setValue(templateValue);
        } catch (CmsException e) {
            //
        }
    }
653906
function Permission(permissionName, validationFunction) {
      validateConstructor(permissionName, validationFunction);

      this.permissionName = permissionName;
      this.validationFunction = annotateValidationFunction(validationFunction);
    }
1099358
function checkDisplay () {
      var myPermissions = self.allProperties[resizeListenerId] // JSON.parse(el.dataset.responsives)
      var curWidth = window.innerWidth
      var initial = el.dataset.initialDisplay ? el.dataset.initialDisplay : ''
      var parameters = self._rPermissions[binding.arg]
      for (let i in parameters) {
        if (curWidth >= parameters[i].min && curWidth <= parameters[i].max) {
          if (myPermissions.lastBp !== i) {
            if (self.allProperties[resizeListenerId].useClass) {
              el.classList.add(myPermissions.bpSet + '-' + i)
              el.classList.remove(myPermissions.bpSet + '-' + myPermissions.lastBp)
            } else {
              el.style.display = myPermissions[i] ? initial : 'none'
            }

            self.allProperties[resizeListenerId].lastBp = i
          }
          break
        }
      }
    }
1326456
function (protectionLevel) {

			// ReSharper disable InconsistentNaming
			var PERMISSION_READ = 1;
			var PERMISSION_READ_ENCRYPTED = 2;
			var PERMISSION_READ_ENCRYPTED_MITM = 4;
			var PERMISSION_WRITE = 16;
			var PERMISSION_WRITE_ENCRYPTED = 32;
			var PERMISSION_WRITE_ENCRYPTED_MITM = 64;
			var PERMISSION_WRITE_SIGNED = 128;
			var PERMISSION_WRITE_SIGNED_MITM = 256;
			// ReSharper restore InconsistentNaming

			var permissions = 0;

			switch (protectionLevel) {
				case winble.gatt.GattProtectionLevel.plain:
					permissions = PERMISSION_READ | PERMISSION_WRITE;
					break;
				case winble.gatt.GattProtectionLevel.authenticationRequired:
					permissions = PERMISSION_READ | PERMISSION_WRITE_SIGNED;
					break;
				case winble.gatt.GattProtectionLevel.encryptionRequired:
					permissions = PERMISSION_READ_ENCRYPTED | PERMISSION_WRITE_ENCRYPTED;
					break;
				case winble.gatt.GattProtectionLevel.encryptionAndAuthenticationRequired:
					permissions = PERMISSION_READ_ENCRYPTED | PERMISSION_WRITE_ENCRYPTED | PERMISSION_WRITE_SIGNED;
					break;
			}

			return (permissions);
		}
365466
public void updateDebugTemplate(String template) throws SecurityException {
	checkWriteAccess();
	boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_DEBUGGING);
	if (!hasAccess) throw new SecurityException("no access to change debugging settings");

	Element debugging = _getRootElement("debugging");
	// if(template.trim().length()>0)
	debugging.setAttribute("template", template);
    }
447988
private static Map<String, Integer> permissions() {

        if (m_permissions == null) {
            LinkedHashMap<String, Integer> permissions = new LinkedHashMap<String, Integer>();
            permissions.put("GUI_PERMISSION_TYPE_READ_0", new Integer(CmsPermissionSet.PERMISSION_READ));
            permissions.put("GUI_PERMISSION_TYPE_WRITE_0", new Integer(CmsPermissionSet.PERMISSION_WRITE));
            permissions.put("GUI_PERMISSION_TYPE_VIEW_0", new Integer(CmsPermissionSet.PERMISSION_VIEW));
            permissions.put("GUI_PERMISSION_TYPE_CONTROL_0", new Integer(CmsPermissionSet.PERMISSION_CONTROL));
            permissions.put(
                "GUI_PERMISSION_TYPE_DIRECT_PUBLISH_0",
                new Integer(CmsPermissionSet.PERMISSION_DIRECT_PUBLISH));
            m_permissions = Collections.unmodifiableMap(permissions);
        }
        return m_permissions;
    }
157071
@Override
    public boolean requestPermissionToWrite() {
        boolean rc = false;
        synchronized (this) {
            if ((currentState & WRITE_NOT_ALLOWED_MASK) == 0) {
                currentState = (currentState | WRITE_PENDING) & WRITE_PENDING_CLEAR_OUT;
                rc = true;
            }
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "requestPermissionToWrite returning " + rc);
        }
        return rc;
    }
1221223
def component_permissions_reader(method_name)
      joinable_type.constantize.component_permissions_hash.each do |component_name, component_permissions|
        if method_name.to_s == "#{component_name}_permissions"
          return component_permissions.collect {|permission| "#{permission}_#{component_name}"}.select {|permission| has_permission?(permission)}.join(" ")
        end
      end
    
      raise "Unknown component_permissions_reader #{method_name.inspect}"
    end
611592
def has_object_permission(self, request, view, obj):
        
        if not self.object_permissions:
            return True

        serializer_class = view.get_serializer_class()
        model_class = serializer_class.Meta.model
        action_method_name = None
        if hasattr(view, 'action'):
            action = self._get_action(view.action)
            action_method_name = "has_object_{action}_permission".format(action=action)
            # If the specific action permission exists then use it, otherwise use general.
            if hasattr(obj, action_method_name):
                return getattr(obj, action_method_name)(request)

        if request.method in permissions.SAFE_METHODS:
            assert hasattr(obj, 'has_object_read_permission'), \
                self._get_error_message(model_class, 'has_object_read_permission', action_method_name)
            return obj.has_object_read_permission(request)
        else:
            assert hasattr(obj, 'has_object_write_permission'), \
                self._get_error_message(model_class, 'has_object_write_permission', action_method_name)
            return obj.has_object_write_permission(request)
985940
public static boolean hasPermission(@NonNull final Context context,
                                        @NonNull final String permission) {
        //TODO Update to new (M preview) permission model https://developer.android.com/preview/features/runtime-permissions.html#coding
        if (TextUtils.isEmpty(permission)) {
            throw new IllegalArgumentException("Permission can't be null or empty.");
        }

        try {
            final PackageInfo info = context.getPackageManager()
                    .getPackageInfo(context.getPackageName(), PackageManager.GET_PERMISSIONS);
            final String[] requestedPermissions = info.requestedPermissions;
            if (requestedPermissions != null) {
                for (String requestedPermission : requestedPermissions) {
                    if (TextUtils.equals(permission, requestedPermission)) {
                        return true;
                    }
                }
            }
        } catch (PackageManager.NameNotFoundException ignore) {
            // ignore
        }

        return false;
    }
516657
def _get_all_permissions(opts):
    ""
    perms = []
    for action in settings.DEFAULT_PERMISSIONS:
        perms.append((_get_permission_codename(action, opts), 'Can %s %s' % (action, opts.verbose_name_raw)))
    return perms + list(opts.permissions)
1079892
def get_permission_checks(self, request, view):
        
        if view.action is None:
            return []
        # if permissions are defined for view directly - use them.
        if hasattr(view, view.action + '_permissions'):
            return getattr(view, view.action + '_permissions')
        # otherwise return view-level permissions + extra view permissions
        extra_permissions = getattr(view, view.action + 'extra_permissions', [])
        if request.method in SAFE_METHODS:
            return getattr(view, 'safe_methods_permissions', []) + extra_permissions
        else:
            return getattr(view, 'unsafe_methods_permissions', []) + extra_permissions
55255
def upload_template_and_reload(name):
    
    template = get_templates()[name]
    local_path = template["local_path"]
    if not os.path.exists(local_path):
        project_root = os.path.dirname(os.path.abspath(__file__))
        local_path = os.path.join(project_root, local_path)
    remote_path = template["remote_path"]
    reload_command = template.get("reload_command")
    owner = template.get("owner")
    mode = template.get("mode")
    remote_data = ""
    if exists(remote_path):
        with hide("stdout"):
            remote_data = sudo("cat %s" % remote_path, show=False)
    with open(local_path, "r") as f:
        local_data = f.read()
        # Escape all non-string-formatting-placeholder occurrences of '%':
        local_data = re.sub(r"%(?!\(\w+\)s)", "%%", local_data)
        if "%(db_pass)s" in local_data:
            env.db_pass = db_pass()
        local_data %= env
    clean = lambda s: s.replace("\n", "").replace("\r", "").strip()
    if clean(remote_data) == clean(local_data):
        return
    upload_template(local_path, remote_path, env, use_sudo=True, backup=False)
    if owner:
        sudo("chown %s %s" % (owner, remote_path))
    if mode:
        sudo("chmod %s %s" % (mode, remote_path))
    if reload_command:
        sudo(reload_command)
278204
def permissions(self):
        
        # TODO: optimize this, it's kind of a bad solution for listing a mostly
        # static set of files.
        # We could either add a permissions dict as an attribute or cache this
        # in some way. Creating a dict would be another place we have to define
        # the permission, so I'm not a huge fan, but it would definitely be the
        # easier option.
        permissions_dict = {"self": {}, "parent": {}}

        for field in self.properties._meta.get_fields():
            split_field = field.name.split('_', 1)
            if len(split_field) <= 0 or split_field[0] not in ['self', 'parent']:
                continue
            permissions_dict[split_field[0]][split_field[1]] = getattr(self.properties, field.name)

        return permissions_dict
926638
private void setFileNotWorldReadablePermissions(File file) {
       file.setReadable(false, false);
       file.setWritable(false, false);
       file.setExecutable(false, false);
       file.setReadable(true, true);
       file.setWritable(true, true);
    }
346351
static void setPermissionsToOwnerOnly(File file) throws IOException {
    // Disable access by other users if O/S allows it and set file permissions to readable and
    // writable by user. Use reflection since JDK 1.5 will not have these methods
    try {
      Method setReadable = File.class.getMethod("setReadable", boolean.class, boolean.class);
      Method setWritable = File.class.getMethod("setWritable", boolean.class, boolean.class);
      Method setExecutable = File.class.getMethod("setExecutable", boolean.class, boolean.class);
      if (!(Boolean) setReadable.invoke(file, false, false)
          || !(Boolean) setWritable.invoke(file, false, false)
          || !(Boolean) setExecutable.invoke(file, false, false)) {
        LOGGER.warning("unable to change permissions for everybody: " + file);
      }
      if (!(Boolean) setReadable.invoke(file, true, true)
          || !(Boolean) setWritable.invoke(file, true, true)
          || !(Boolean) setExecutable.invoke(file, true, true)) {
        LOGGER.warning("unable to change permissions for owner: " + file);
      }
    } catch (InvocationTargetException exception) {
      Throwable cause = exception.getCause();
      Throwables.propagateIfPossible(cause, IOException.class);
      // shouldn't reach this point, but just in case...
      throw new RuntimeException(cause);
    } catch (NoSuchMethodException exception) {
      LOGGER.warning(
          "Unable to set permissions for "
              + file
              + ", likely because you are running a version of Java prior to 1.6");
    } catch (SecurityException exception) {
      // ignored
    } catch (IllegalAccessException exception) {
      // ignored
    } catch (IllegalArgumentException exception) {
      // ignored
    }
  }