Java 8 SecurityPermission - 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 SecurityPermission class.

This code example shows how to use the following methods:getName, getActions
        ) 
    }) 
    public void testCtor() 
    { 
        String name = "basic123*$%#";
        SecurityPermission test = new SecurityPermission(name);
        assertEquals(name, test.getName());
        assertEquals("", test.getActions());
        test = new SecurityPermission(name, "#$!#12435");
        assertEquals(name, test.getName());
        assertEquals("", test.getActions());
        try{ 
            new SecurityPermission(null);
            fail("NPE is not thrown");
        } 
        catch (NullPointerException ok){}
 
        try{ 
            new SecurityPermission(null, "ds235");
            fail("NPE is not thrown");
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
 
    /** 
     * Tests that policy is really resetted on refresh().  
     */ 
    public void testRefresh() { 
        Permission sp = new SecurityPermission("sdf");
        PolicyEntry[] pe = new PolicyEntry[] { new PolicyEntry(null, null,
            Arrays.asList(new Permission[] { sp })) };
        TestParser tp = new TestParser(pe);
        DefaultPolicy policy = new DefaultPolicy(tp);
        CodeSource cs = new CodeSource(null, (Certificate[])null);
        assertTrue(policy.getPermissions(cs).implies(sp));
 
        tp.content = new PolicyEntry[0];
        policy.refresh();
        assertFalse(policy.getPermissions(cs).implies(sp));
 
        tp.content = null;
        policy.refresh();
        assertFalse(policy.getPermissions(cs).implies(sp));

5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        PermissionCollection pc1 = dp.newPermissionCollection();
        PermissionCollection pc2 = dp.newPermissionCollection();
        assertNotSame(pc1, pc2);
        pc1.add(new DelegationPermission("\"BBB\" \"AAA\""));
        try { 
            pc1.add(new SecurityPermission("aaa"));
            fail("should not add non DelegationPermission");
        } catch (IllegalArgumentException e){
        } 
		try { 
		    pc1.add(null);
		    fail("permission is null");
		} catch (IllegalArgumentException e) {
		} 
        pc1.setReadOnly();
		try { 
			pc1.add(new DelegationPermission("\"CCC\" \"AAA\""));
			fail("read-only flag is ignored");
		} catch (SecurityException e) {
		} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
            perm.equals(new RuntimePermission("createClassLoader")) ||
            perm.equals(new FilePermission(deletedFile,"delete")) ||
            perm.equals(new FilePermission(readedFile,"read")) ||
            perm.equals(new PropertyPermission("*", "read,write")) ||
            perm.equals(new PropertyPermission("key", "read")) ||
            perm.equals(new SecurityPermission("getPolicy")) ||
//          perm.equals(new AWTPermission("accessClipboard")) || 
            perm.equals(new FilePermission(writedFile,"write"))) {
            throw 
            new SecurityException("Unable to create Security Manager");
        } 
    } 
 
    @Override 
    public ClassLoader currentClassLoader() {
        return super.currentClassLoader(); 
    } 
 
    @Override 
    public Class<?> currentLoadedClass() {
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
            perm.equals(new RuntimePermission("createClassLoader")) ||
            perm.equals(new FilePermission(deletedFile,"delete")) ||
            perm.equals(new FilePermission(readedFile,"read")) ||
            perm.equals(new PropertyPermission("*", "read,write")) ||
            perm.equals(new PropertyPermission("key", "read")) ||
            perm.equals(new SecurityPermission("getPolicy")) ||
//          perm.equals(new AWTPermission("accessClipboard")) || 
            perm.equals(new FilePermission(writedFile,"write"))) {
            throw 
            new SecurityException("Unable to create Security Manager");
        } 
    } 
 
    @Override 
    public ClassLoader currentClassLoader() {
        return super.currentClassLoader(); 
    } 
 
    @Override 
    public Class<?> currentLoadedClass() {
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
import org.apache.accumulo.core.master.state.tables.TableState; 
import org.apache.accumulo.core.zookeeper.ZooCache; 
import org.apache.accumulo.core.zookeeper.ZooUtil; 
 
public class Tables { 
  private static SecurityPermission TABLES_PERMISSION = new SecurityPermission("tablesPermission"); 
   
  private static ZooCache getZooCache(Instance instance) { 
    SecurityManager sm = System.getSecurityManager(); 
    if (sm != null) { 
      sm.checkPermission(TABLES_PERMISSION); 
    } 
    return ZooCache.getInstance(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut()); 
  } 
   
  private static SortedMap<String,String> getMap(Instance instance, boolean nameAsKey) { 
    ZooCache zc = getZooCache(instance); 
     
    List<String> tableIds = zc.getChildren(ZooUtil.getRoot(instance) + Constants.ZTABLES); 
     
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
     */ 
    protected Object[] getData() {
        Permissions ps = new Permissions();
 
        ps.add(new AllPermission());
        ps.add(new SecurityPermission("abc"));
 
        return new Object[] { new Permissions(), ps };
    } 
} 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
import org.apache.accumulo.core.master.state.tables.TableState; 
import org.apache.accumulo.core.zookeeper.ZooCache; 
import org.apache.accumulo.core.zookeeper.ZooUtil; 
 
public class Tables { 
  private static SecurityPermission TABLES_PERMISSION = new SecurityPermission("tablesPermission");
   
  private static ZooCache getZooCache(Instance instance) {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
      sm.checkPermission(TABLES_PERMISSION);
    } 
    return ZooCache.getInstance(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut());
  } 
   
  private static SortedMap<String,String> getMap(Instance instance, boolean nameAsKey) {
    ZooCache zc = getZooCache(instance);
     
    List<String> tableIds = zc.getChildren(ZooUtil.getRoot(instance) + Constants.ZTABLES);
     
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
public class Tables { 
  private static final Logger log = Logger.getLogger(Tables.class); 
 
  public static final String VALID_NAME_REGEX = "^(\\w+\\.)?(\\w+)$";
   
  private static final SecurityPermission TABLES_PERMISSION = new SecurityPermission("tablesPermission");
  private static final AtomicLong cacheResetCount = new AtomicLong(0);
 
  private static ZooCache getZooCache(Instance instance) {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
      sm.checkPermission(TABLES_PERMISSION);
    } 
    return new ZooCacheFactory().getZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut());
  } 
 
  private static SortedMap<String,String> getMap(Instance instance, boolean nameAsKey) {
    ZooCache zc = getZooCache(instance);
 
    List<String> tableIds = zc.getChildren(ZooUtil.getRoot(instance) + Constants.ZTABLES);
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
    /** 
     * @see com.intel.drl.test.SerializationTest#getData() 
     */ 
    protected Object[] getData() { 
        return new Object[] { new SecurityPermission("%&#C"), 
                new SecurityPermission("jlkhb.3465.*", "sf"), }; 
    } 
} 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Java 8 SecurityPermission Methods: