Package java.security

Examples of java.security.SecurityPermission


    public void test_setPolicyLjava_security_Policy() {
        SecurityManager old = System.getSecurityManager();
        Policy oldPolicy = Policy.getPolicy();
        try {
            SecurityChecker checker = new SecurityChecker(
                new SecurityPermission("setPolicy"), true);
            System.setSecurityManager(checker);
            Policy custom = new TestProvider();
            Policy.setPolicy(custom);
            assertTrue(checker.checkAsserted);
            assertSame(custom, Policy.getPolicy());
View Full Code Here


        SecurityManager old = System.getSecurityManager();
        Policy oldPolicy = Policy.getPolicy();
        try {
            Policy.setPolicy(new TestProvider());
            SecurityChecker checker = new SecurityChecker(
                new SecurityPermission("getPolicy"), true);
            System.setSecurityManager(checker);
            Policy.getPolicy();
            assertTrue(checker.checkAsserted);

            checker.reset();
View Full Code Here

   
    /**
     * Tests that getPermissions() does proper permission evaluation.
     */
    public void testGetPermissions() {
        SecurityPermission sp = new SecurityPermission("abc");
        SecurityPermission sp2 = new SecurityPermission("fbdf");
        PermissionCollection spc = sp.newPermissionCollection();
        spc.add(sp2);
        ProtectionDomain pd = new ProtectionDomain(null, null);
        ProtectionDomain pd2 = new ProtectionDomain(null, spc);
        TestProvider policy = new TestProvider();
View Full Code Here

                (java.security.cert.Certificate[]) null);

        PermissionCollection pCollection = p.getPermissions(codeSource);
        Enumeration<Permission> elements = pCollection.elements();

        SecurityPermission perm = new SecurityPermission(
                "codeBaseForPolicyTest");

        while (elements.hasMoreElements()) {
            if (elements.nextElement().equals(perm)) {
                return; // passed
View Full Code Here

  /**
   * @tests java.security.Permission#Permission(java.lang.String)
   */
  public void test_ConstructorLjava_lang_String() {
    // test method java.security.permission.Permission(string)
    SecurityPermission permi = new SecurityPermission(
        "Testing the permission abstract class");
    String name = permi.getName();
    assertEquals("Permission Constructor failed",
        "Testing the permission abstract class", name);
  }
View Full Code Here

  /**
   * @tests java.security.Permission#checkGuard(java.lang.Object)
   */
  public void test_checkGuardLjava_lang_Object() {
    // test method java.security.permission.checkGuard(object)
    SecurityPermission permi = new SecurityPermission(
        "Testing the permission abstract class");
    String name = permi.getName();
    try {
      permi.checkGuard(name);
    } catch (SecurityException e) {
      fail("security not granted when it is suppose to be : " + e);
    }
  }
View Full Code Here

  /**
   * @tests java.security.Permission#getName()
   */
  public void test_getName() {
    // test method java.security.permission.getName()
    SecurityPermission permi = new SecurityPermission("testing getName()");
    String name = permi.getName();
    assertEquals("getName failed to obtain the correct name",
        "testing getName()", name);

    SecurityPermission permi2 = new SecurityPermission("93048Helloworld");
    assertEquals("getName failed to obtain correct name",
        "93048Helloworld", permi2.getName());
  }
View Full Code Here

   * @tests java.security.Permission#toString()
   */
  public void test_toString() {
    // test method java.security.permission.toString
    // test for permission with no action
    SecurityPermission permi = new SecurityPermission("testing toString");
    String toString = permi.toString();
    assertNotNull("toString should have returned a string of elements",
        toString);
  }
View Full Code Here

   * @tests java.security.SecurityPermission#SecurityPermission(java.lang.String)
   */
  public void test_ConstructorLjava_lang_String() {
    // Test for method java.security.SecurityPermission(java.lang.String)
    assertEquals("create securityPermission constructor(string) failed",
        "SecurityPermission(string)", new SecurityPermission("SecurityPermission(string)").getName()
            );

  }
View Full Code Here

   *        java.lang.String)
   */
  public void test_ConstructorLjava_lang_StringLjava_lang_String() {
    // Test for method java.security.SecurityPermission(java.lang.String,
    // java.lang.String)
    SecurityPermission sp = new SecurityPermission("security.file", "write");
    assertEquals("creat securityPermission constructor(string,string) failed",
        "security.file", sp.getName());

  }
View Full Code Here

TOP

Related Classes of java.security.SecurityPermission

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.