当前位置: 首页>>代码示例>>Java>>正文


Java AllPermission类代码示例

本文整理汇总了Java中java.security.AllPermission的典型用法代码示例。如果您正苦于以下问题:Java AllPermission类的具体用法?Java AllPermission怎么用?Java AllPermission使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AllPermission类属于java.security包,在下文中一共展示了AllPermission类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkConfiguration

import java.security.AllPermission; //导入依赖的package包/类
/**
 * Prints warning message if installed Policy is the default Policy
 * implementation and globally granted permissions do not include
 * AllPermission or any ExecPermissions/ExecOptionPermissions.
 */
static void checkConfiguration() {
    Policy policy =
        AccessController.doPrivileged(new PrivilegedAction<Policy>() {
            public Policy run() {
                return Policy.getPolicy();
            }
        });
    if (!(policy instanceof PolicyFile)) {
        return;
    }
    PermissionCollection perms = getExecPermissions();
    for (Enumeration<Permission> e = perms.elements();
         e.hasMoreElements();)
    {
        Permission p = e.nextElement();
        if (p instanceof AllPermission ||
            p instanceof ExecPermission ||
            p instanceof ExecOptionPermission)
        {
            return;
        }
    }
    System.err.println(getTextResource("rmid.exec.perms.inadequate"));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:Activation.java

示例2: checkPerm

import java.security.AllPermission; //导入依赖的package包/类
private static void checkPerm(PolicyFile p, ProtectionDomain pd)
            throws Exception {
    boolean foundIt = false;
    Enumeration perms = p.getPermissions(pd).elements();
    while (perms.hasMoreElements()) {
        Permission perm = (Permission)perms.nextElement();
        if (!(perm instanceof AllPermission)) {
            throw new SecurityException("expected AllPermission");
        } else {
            foundIt = true;
        }
    }
    if (!foundIt) {
        throw new SecurityException("expected AllPermission");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:TokenStore.java

示例3: testExtFuncNotAllowed

import java.security.AllPermission; //导入依赖的package包/类
/**
 * Security is enabled, extension function not allowed
 */
public void testExtFuncNotAllowed() {
    Policy p = new SimplePolicy(new AllPermission());
    Policy.setPolicy(p);
    System.setSecurityManager(new SecurityManager());
    TransformerFactory factory = TransformerFactory.newInstance();

    try {
        transform(factory);
    } catch (TransformerConfigurationException e) {
        fail(e.getMessage());
    } catch (TransformerException ex) {
        //expected since extension function is disallowed
        System.out.println("testExtFuncNotAllowed: OK");
    } finally {
        System.setSecurityManager(null);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:XSLTExFuncTest.java

示例4: testExtFuncNotAllowed

import java.security.AllPermission; //导入依赖的package包/类
/**
 * Security is enabled, extension function not allowed
 */
public void testExtFuncNotAllowed() {
    Policy p = new SimplePolicy(new AllPermission());
    Policy.setPolicy(p);
    System.setSecurityManager(new SecurityManager());

    try {
        evaluate(false);
    } catch (XPathFactoryConfigurationException e) {
        fail(e.getMessage());
    } catch (XPathExpressionException ex) {
        //expected since extension function is disallowed
        System.out.println("testExtFuncNotAllowed: OK");
    } finally {
        System.setSecurityManager(null);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:XPathExFuncTest.java

示例5: testValidation_SAX_withSM

import java.security.AllPermission; //导入依赖的package包/类
@Test
public void testValidation_SAX_withSM() {
    System.out.println("Validation using SAX Source with security manager:");
    System.setProperty(SAX_FACTORY_ID, "MySAXFactoryImpl");
    Permissions granted = new java.security.Permissions();
    granted.add(new AllPermission());
    System.setSecurityManager(new MySM(granted));

    try {
        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        // should not allow
        factory.setFeature(ORACLE_FEATURE_SERVICE_MECHANISM, true);
        if ((boolean) factory.getFeature(ORACLE_FEATURE_SERVICE_MECHANISM)) {
            Assert.fail("should not override in secure mode");
        }
    } catch (Exception e) {
        Assert.fail(e.getMessage());

    } finally {
        System.clearProperty(SAX_FACTORY_ID);
        System.setSecurityManager(null);
    }

    System.setSecurityManager(null);

}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:27,代码来源:Bug7143711Test.java

示例6: testTransform_DOM_withSM

import java.security.AllPermission; //导入依赖的package包/类
@Test(enabled=false) //skipped due to bug JDK-8080097
public void testTransform_DOM_withSM() {
    System.out.println("Transform using DOM Source;  Security Manager is set:");

    Permissions granted = new java.security.Permissions();
    granted.add(new AllPermission());
    System.setSecurityManager(new MySM(granted));
    System.setProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl");

    try {
        TransformerFactory factory = TransformerFactory.newInstance("com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl",
                TransformerFactory.class.getClassLoader());
        factory.setFeature(ORACLE_FEATURE_SERVICE_MECHANISM, true);
        if ((boolean) factory.getFeature(ORACLE_FEATURE_SERVICE_MECHANISM)) {
            Assert.fail("should not override in secure mode");
        }

    } catch (Exception e) {
        Assert.fail(e.getMessage());
    } finally {
        System.clearProperty(DOM_FACTORY_ID);
        System.setSecurityManager(null);
    }

    System.clearProperty(DOM_FACTORY_ID);
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:27,代码来源:Bug7143711Test.java

示例7: testXPath_DOM_withSM

import java.security.AllPermission; //导入依赖的package包/类
@Test
public void testXPath_DOM_withSM() {
    System.out.println("Evaluate DOM Source;  Security Manager is set:");
    Permissions granted = new java.security.Permissions();
    granted.add(new AllPermission());
    System.setSecurityManager(new MySM(granted));
    System.setProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl");

    try {
        XPathFactory xPathFactory = XPathFactory.newInstance("http://java.sun.com/jaxp/xpath/dom",
                "com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl", null);
        xPathFactory.setFeature(ORACLE_FEATURE_SERVICE_MECHANISM, true);
        if ((boolean) xPathFactory.getFeature(ORACLE_FEATURE_SERVICE_MECHANISM)) {
            Assert.fail("should not override in secure mode");
        }

    } catch (Exception e) {
        Assert.fail(e.getMessage());
    } finally {
        System.clearProperty(DOM_FACTORY_ID);
        System.setSecurityManager(null);
    }

    System.clearProperty(DOM_FACTORY_ID);
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:26,代码来源:Bug7143711Test.java

示例8: getKeyStore

import java.security.AllPermission; //导入依赖的package包/类
/**
 * Returns a KeyStore corresponding to the appropriate level level (user or
 * system) and type.
 *
 * @param level whether the KeyStore desired is a user-level or system-level
 * KeyStore
 * @param type the type of KeyStore desired
 * @param create true if keystore can be created
 * @return a KeyStore containing certificates from the appropriate
 */
public static final KeyStore getKeyStore(Level level, Type type, boolean create) {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        sm.checkPermission(new AllPermission());
    }

    String location = getKeyStoreLocation(level, type).getFullPath();
    KeyStore ks = null;
    try {
        ks = createKeyStoreFromFile(new File(location), create);
        //hashcode is used instead of instance so when no references are left
        //to keystore, then this will not be blocker for garbage collection
        keystoresPaths.put(ks.hashCode(),location);
    } catch (Exception e) {
        OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
    }
    return ks;
}
 
开发者ID:GITNE,项目名称:icedtea-web,代码行数:29,代码来源:KeyStores.java

示例9: getPermissions

import java.security.AllPermission; //导入依赖的package包/类
/**
 * @return a PermissionCollection containing the basic
 * permissions granted depending on the security type.
 *
 * @param cs the CodeSource to get permissions for
 */
public PermissionCollection getPermissions(CodeSource cs) {
    PermissionCollection permissions = getSandBoxPermissions();

    // discard sandbox, give all
    if (ALL_PERMISSIONS.equals(type)) {
        permissions = new Permissions();
        if (customTrustedPolicy == null) {
            permissions.add(new AllPermission());
            return permissions;
        } else {
            return customTrustedPolicy.getPermissions(cs);
        }
    }

    // add j2ee to sandbox if needed
    if (J2EE_PERMISSIONS.equals(type))
        for (Permission j2eePermission : j2eePermissions) {
            permissions.add(j2eePermission);
    }

    return permissions;
}
 
开发者ID:GITNE,项目名称:icedtea-web,代码行数:29,代码来源:SecurityDesc.java

示例10: decrementLoaderUseCount

import java.security.AllPermission; //导入依赖的package包/类
/**
 * Decrements loader use count by 1
 * 
 * If count reaches 0, loader is removed from list of available loaders
 * 
 * @throws SecurityException if caller is not trusted
 */
public void decrementLoaderUseCount() {

    // For use by trusted code only
    if (System.getSecurityManager() != null)
        System.getSecurityManager().checkPermission(new AllPermission());

    String uniqueKey = file.getUniqueKey();

    // NB: There will only ever be one class-loader per unique-key
    synchronized ( getUniqueKeyLock(uniqueKey) ) {
        useCount--;

        if (useCount <= 0) {
            uniqueKeyToLoader.remove(uniqueKey);
        }
    }
}
 
开发者ID:GITNE,项目名称:icedtea-web,代码行数:25,代码来源:JNLPClassLoader.java

示例11: test02Data

import java.security.AllPermission; //导入依赖的package包/类
@Test
public void test02Data() {
	
	final String INVALID_BUNDLE_PATH = "invalidBundleData02.jar";
	final String FORMATED_INVALID_BUNDLE_PATH = "file:" + INVALID_BUNDLE_PATH; 
	
	Bundle bundle = FrameworkUtil.getBundle(Data02Test.class);
	BundleContext ctx = bundle.getBundleContext();
	
	try {
		System.getSecurityManager().checkPermission(new AllPermission());
		assertTrue(INVALID_BUNDLE_PATH + " was not found", new File(INVALID_BUNDLE_PATH).exists());
		ctx.installBundle(FORMATED_INVALID_BUNDLE_PATH).start();
	} catch (BundleException e) {
		fail("[FAIL] Bundle with non ASCII character in its manifest file has created an BundleException : " + e.getMessage());
		//Nevertheless with this method, invalidBundle is still present on the platform in installed state
	}
}
 
开发者ID:osgi,项目名称:osgi.security-tests,代码行数:19,代码来源:Data02Test.java

示例12: getPermissions

import java.security.AllPermission; //导入依赖的package包/类
public PermissionCollection getPermissions(CodeSource codesource)
{
    // contract of getPermissions() methods is to return a _mutable_ PermissionCollection

    Permissions perms = new Permissions();

    if (codesource == null || codesource.getLocation() == null)
        return perms;

    switch (codesource.getLocation().getProtocol())
    {
        case "file":
            // All JARs and class files reside on the file system - we can safely
            // assume that these classes are "good".
            perms.add(new AllPermission());
            return perms;
    }

    return perms;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:21,代码来源:ThreadAwareSecurityManager.java

示例13: test_ConstructorLjava_lang_StringLjava_lang_String

import java.security.AllPermission; //导入依赖的package包/类
/**
 * @tests java.security.AllPermission#AllPermission(java.lang.String,
 *        java.lang.String)
 */
@TestTargetNew(
    level = TestLevel.PARTIAL,
    notes = "Null/empty parameters checking missed",
    method = "AllPermission",
    args = {java.lang.String.class, java.lang.String.class}
)
public void test_ConstructorLjava_lang_StringLjava_lang_String() {
    // Test for method java.security.AllPermission(java.lang.String,
    // java.lang.String)
    AllPermission ap = new AllPermission("Don't remember this stupid name",
            "or this action");
    assertEquals("Bogus name for AllPermission \"" + ap.getName() + "\".",
            "<all permissions>", ap.getName());
    assertEquals(
            "AllPermission constructed with actions didn't ignore them.",
            "<all actions>", ap.getActions());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:22,代码来源:AllPermission2Test.java

示例14: test_hashCode

import java.security.AllPermission; //导入依赖的package包/类
/**
 * @tests java.security.AllPermission#hashCode()
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "hashCode",
    args = {}
)
public void test_hashCode() {
    final int ALLPERMISSION_HASH = 1;
    // Test for method int java.security.AllPermission.hashCode()
    AllPermission TestAllPermission = new AllPermission();
    assertTrue("AllPermission hashCode is wrong. Should have been "
            + ALLPERMISSION_HASH + " but was "
            + TestAllPermission.hashCode(),
            TestAllPermission.hashCode() == ALLPERMISSION_HASH);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:19,代码来源:AllPermission2Test.java

示例15: test_impliesLjava_security_Permission

import java.security.AllPermission; //导入依赖的package包/类
/**
 * @tests java.security.AllPermission#implies(java.security.Permission)
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "implies",
    args = {java.security.Permission.class}
)
public void test_impliesLjava_security_Permission() {
    // Test for method boolean
    // java.security.AllPermission.implies(java.security.Permission)
    assertTrue("AllPermission does not imply a AllPermission.",
            new AllPermission().implies(new AllPermission()));
    assertTrue("AllPermission does not imply a SecurityPermission.",
            new AllPermission().implies(new SecurityPermission("ugh!")));
    assertTrue("SecurityPermission implies AllPermission.",
            !(new SecurityPermission("ugh!").implies(new AllPermission())));
    assertTrue("AllPermission does not imply when parametr NULL", new AllPermission().implies(null));
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:21,代码来源:AllPermission2Test.java


注:本文中的java.security.AllPermission类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。