Java 8 Permissions - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Permissions class.

This code example shows how to use the following methods:add
    private static final Permissions DEFAULT_PERMISSIONS;
 
    private volatile boolean enabled;
 
    static { 
        final Permissions permissions = new Permissions();
        permissions.add(new PropertyPermission("*", "read"));
        permissions.add(new RuntimePermission("queuePrintJob"));
        permissions.add(new RuntimePermission("loadLibrary"));
        permissions.add(new FilePermission("*", "read"));
        permissions.add(new FilePermission("*", "write"));
        permissions.add(new SocketPermission("*", "connect"));
        DEFAULT_PERMISSIONS = permissions;
    } 
 
    public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
        final ModuleSpecification attachment = phaseContext.getDeploymentUnit().getAttachment(Attachments.MODULE_SPECIFICATION);
        if (attachment == null) {
            return; 
        } 
7
CodeRank
This code example shows how to use the following methods:sleep, add
 
    public static void main(String[] args) throws Exception {
 
        TestLibrary.suggestSecurityManager(null); 
 
        Permissions perms = new Permissions();
        perms.add(new SocketPermission("*:1024-", "listen"));
        AccessControlContext acc =
            new AccessControlContext(new ProtectionDomain[] {
                new ProtectionDomain(
                    new CodeSource(null, (Certificate[]) null), perms) });
 
        Remote impl = new DGCImplInsulation();;
 
        try { 
            Remote stub = (Remote) java.security.AccessController.doPrivileged(
                new ExportAction(impl));
            System.err.println("exported remote object; local stub: " + stub);
 
            MarshalledObject mobj = new MarshalledObject(stub);

7
CodeRank
This code example shows how to use the following methods:sleep, add
 
    public static void main(String[] args) throws Exception {
 
        TestLibrary.suggestSecurityManager(null); 
 
        Permissions perms = new Permissions();
        perms.add(new SocketPermission("*:1024-", "listen"));
        AccessControlContext acc =
            new AccessControlContext(new ProtectionDomain[] {
                new ProtectionDomain(
                    new CodeSource(null, (Certificate[]) null), perms) });
 
        Remote impl = new DGCImplInsulation();;
 
        try { 
            Remote stub = (Remote) java.security.AccessController.doPrivileged(
                new ExportAction(impl));
            System.err.println("exported remote object; local stub: " + stub);
 
            MarshalledObject mobj = new MarshalledObject(stub);

6
CodeRank
This code example shows how to use the following methods:sleep, add
 
    public static void main(String[] args) throws Exception {
 
        TestLibrary.suggestSecurityManager(null); 
 
        Permissions perms = new Permissions();
        perms.add(new SocketPermission("*:1024-", "listen"));
        AccessControlContext acc =
            new AccessControlContext(new ProtectionDomain[] {
                new ProtectionDomain(
                    new CodeSource(null, (Certificate[]) null), perms) });
 
        Remote impl = new DGCImplInsulation();;
 
        try { 
            Remote stub = (Remote) java.security.AccessController.doPrivileged(
                new ExportAction(impl));
            System.err.println("exported remote object; local stub: " + stub);
 
            MarshalledObject mobj = new MarshalledObject(stub);

6
CodeRank
This code example shows how to use the following methods:
	@Override 
	protected PermissionCollection getPermissions(CodeSource codeSource) {
		if (_SECURITY_ENABLED && (_id != null) && _id.startsWith("web-app:") &&
			!_id.endsWith("/ROOT")) {
 
			return new Permissions();
		} 
 
		return super.getPermissions(codeSource);
	} 
 
	private static final boolean _SECURITY_ENABLED =
		(System.getSecurityManager() != null);
 
	private final String _id;
 
} 
5
CodeRank
This code example shows how to use the following methods:
		} 
	} 
 
	private static final Log _log = LogFactoryUtil.getLog(AWTChecker.class);
 
	private final Permissions _permissions = new Permissions();
 
} 
5
CodeRank
This code example shows how to use the following methods:add
 
	protected void initHostsAndPorts(String networkPart, String action) {
		SocketPermission socketPermission = new SocketPermission(
			networkPart, action);
 
		_permissions.add(socketPermission);
	} 
 
	protected void initListenPorts() { 
		String[] listenParts = getPropertyArray(
			"security-manager-sockets-listen"); 
 
		for (String listenPart : listenParts) {
			initListenPorts(listenPart);
		} 
	} 
 
	protected void initListenPorts(String listenPart) {
		initHostsAndPorts("*:" + listenPart, SOCKET_PERMISSION_LISTEN);
	} 
5
CodeRank
This code example shows how to use the following methods:
	} 
 
	private static final Log _log = LogFactoryUtil.getLog(
		PropertyChecker.class); 
 
	private final Permissions _permissions = new Permissions();
 
} 
5
CodeRank
This code example shows how to use the following methods:add
{ 
  static Permission allPermission = new AllPermission();
 
  public PermissionCollection getPermissions(CodeSource codesource)
  { 
    Permissions perms = new Permissions();
    perms.add(allPermission);
    return perms;
  } 
 
  public void refresh() 
  { 
    // Nothing. 
  } 
} 
5
CodeRank
This code example shows how to use the following methods:
		throws MalformedURLException {
 
		URL rootURL = new URL("file", null, rootDir);
 
		ProtectionDomain protectionDomain = new ProtectionDomain(
			new CodeSource(rootURL, new Certificate[0]), new Permissions());
 
		if (policy.implies(protectionDomain, new AllPermission())) {
			throw new IllegalStateException(
				"The plugin's Java policy tried to declared all " + 
					"permissions"); 
		} 
	} 
 
	protected Checker getChecker(Class<? extends Permission> clazz) {
		return _checkers.get(clazz.getName());
	} 
 
	protected Provider getProvider() {
		String providerName = "SUN";
5
CodeRank

Related Java 8 Permissions Questions & Answers:

See Code Examples for Java 8 Permissions Methods: