Java Code Examples for java.security.Permission#getName()
The following examples show how to use
java.security.Permission#getName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MarshalInputStream.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Fix for 4179055: Need to assist resolving sun stubs; resolve * class locally if it is a "permitted" sun class */ private Class<?> checkSunClass(String className, AccessControlException e) throws AccessControlException { // ensure that we are giving out a stub for the correct reason Permission perm = e.getPermission(); String name = null; if (perm != null) { name = perm.getName(); } Class<?> resolvedClass = permittedSunClasses.get(className); // if class not permitted, throw the SecurityException if ((name == null) || (resolvedClass == null) || ((!name.equals("accessClassInPackage.sun.rmi.server")) && (!name.equals("accessClassInPackage.sun.rmi.registry")))) { throw e; } return resolvedClass; }
Example 2
Source File: MarshalInputStream.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * Fix for 4179055: Need to assist resolving sun stubs; resolve * class locally if it is a "permitted" sun class */ private Class<?> checkSunClass(String className, AccessControlException e) throws AccessControlException { // ensure that we are giving out a stub for the correct reason Permission perm = e.getPermission(); String name = null; if (perm != null) { name = perm.getName(); } Class<?> resolvedClass = permittedSunClasses.get(className); // if class not permitted, throw the SecurityException if ((name == null) || (resolvedClass == null) || ((!name.equals("accessClassInPackage.sun.rmi.server")) && (!name.equals("accessClassInPackage.sun.rmi.registry")))) { throw e; } return resolvedClass; }
Example 3
Source File: MarshalInputStream.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Fix for 4179055: Need to assist resolving sun stubs; resolve * class locally if it is a "permitted" sun class */ private Class<?> checkSunClass(String className, AccessControlException e) throws AccessControlException { // ensure that we are giving out a stub for the correct reason Permission perm = e.getPermission(); String name = null; if (perm != null) { name = perm.getName(); } Class<?> resolvedClass = permittedSunClasses.get(className); // if class not permitted, throw the SecurityException if ((name == null) || (resolvedClass == null) || ((!name.equals("accessClassInPackage.sun.rmi.server")) && (!name.equals("accessClassInPackage.sun.rmi.registry")))) { throw e; } return resolvedClass; }
Example 4
Source File: URLResource.java From IoTgo_Android_App with MIT License | 6 votes |
/** * Returns an File representing the given resource or NULL if this * is not possible. */ @Override public File getFile() throws IOException { // Try the permission hack if (checkConnection()) { Permission perm = _connection.getPermission(); if (perm instanceof java.io.FilePermission) return new File(perm.getName()); } // Try the URL file arg try {return new File(_url.getFile());} catch(Exception e) {LOG.ignore(e);} // Don't know the file return null; }
Example 5
Source File: MarshalInputStream.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Fix for 4179055: Need to assist resolving sun stubs; resolve * class locally if it is a "permitted" sun class */ private Class<?> checkSunClass(String className, AccessControlException e) throws AccessControlException { // ensure that we are giving out a stub for the correct reason Permission perm = e.getPermission(); String name = null; if (perm != null) { name = perm.getName(); } Class<?> resolvedClass = permittedSunClasses.get(className); // if class not permitted, throw the SecurityException if ((name == null) || (resolvedClass == null) || ((!name.equals("accessClassInPackage.sun.rmi.server")) && (!name.equals("accessClassInPackage.sun.rmi.registry")))) { throw e; } return resolvedClass; }
Example 6
Source File: CassandraRule.java From logging-log4j2 with Apache License 2.0 | 6 votes |
private void cancelOnWindows() { final SecurityManager currentSecurityManager = System.getSecurityManager(); try { final SecurityManager securityManager = new SecurityManager() { @Override public void checkPermission(final Permission permission) { final String permissionName = permission.getName(); if (permissionName != null && permissionName.startsWith("exitVM")) { throw new SecurityException("test"); } } }; System.setSecurityManager(securityManager); daemon.stop(); } catch (final SecurityException ex) { // ignore } finally { System.setSecurityManager(currentSecurityManager); } }
Example 7
Source File: MarshalInputStream.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Fix for 4179055: Need to assist resolving sun stubs; resolve * class locally if it is a "permitted" sun class */ private Class<?> checkSunClass(String className, AccessControlException e) throws AccessControlException { // ensure that we are giving out a stub for the correct reason Permission perm = e.getPermission(); String name = null; if (perm != null) { name = perm.getName(); } Class<?> resolvedClass = permittedSunClasses.get(className); // if class not permitted, throw the SecurityException if ((name == null) || (resolvedClass == null) || ((!name.equals("accessClassInPackage.sun.rmi.server")) && (!name.equals("accessClassInPackage.sun.rmi.registry")))) { throw e; } return resolvedClass; }
Example 8
Source File: MarshalInputStream.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Fix for 4179055: Need to assist resolving sun stubs; resolve * class locally if it is a "permitted" sun class */ private Class<?> checkSunClass(String className, AccessControlException e) throws AccessControlException { // ensure that we are giving out a stub for the correct reason Permission perm = e.getPermission(); String name = null; if (perm != null) { name = perm.getName(); } Class<?> resolvedClass = permittedSunClasses.get(className); // if class not permitted, throw the SecurityException if ((name == null) || (resolvedClass == null) || ((!name.equals("accessClassInPackage.sun.rmi.server")) && (!name.equals("accessClassInPackage.sun.rmi.registry")))) { throw e; } return resolvedClass; }
Example 9
Source File: MarshalInputStream.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Fix for 4179055: Need to assist resolving sun stubs; resolve * class locally if it is a "permitted" sun class */ private Class<?> checkSunClass(String className, AccessControlException e) throws AccessControlException { // ensure that we are giving out a stub for the correct reason Permission perm = e.getPermission(); String name = null; if (perm != null) { name = perm.getName(); } Class<?> resolvedClass = permittedSunClasses.get(className); // if class not permitted, throw the SecurityException if ((name == null) || (resolvedClass == null) || ((!name.equals("accessClassInPackage.sun.rmi.server")) && (!name.equals("accessClassInPackage.sun.rmi.registry")))) { throw e; } return resolvedClass; }
Example 10
Source File: MarshalInputStream.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Fix for 4179055: Need to assist resolving sun stubs; resolve * class locally if it is a "permitted" sun class */ private Class<?> checkSunClass(String className, AccessControlException e) throws AccessControlException { // ensure that we are giving out a stub for the correct reason Permission perm = e.getPermission(); String name = null; if (perm != null) { name = perm.getName(); } Class<?> resolvedClass = permittedSunClasses.get(className); // if class not permitted, throw the SecurityException if ((name == null) || (resolvedClass == null) || ((!name.equals("accessClassInPackage.sun.rmi.server")) && (!name.equals("accessClassInPackage.sun.rmi.registry")))) { throw e; } return resolvedClass; }
Example 11
Source File: MarshalInputStream.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Fix for 4179055: Need to assist resolving sun stubs; resolve * class locally if it is a "permitted" sun class */ private Class<?> checkSunClass(String className, AccessControlException e) throws AccessControlException { // ensure that we are giving out a stub for the correct reason Permission perm = e.getPermission(); String name = null; if (perm != null) { name = perm.getName(); } Class<?> resolvedClass = permittedSunClasses.get(className); // if class not permitted, throw the SecurityException if ((name == null) || (resolvedClass == null) || ((!name.equals("accessClassInPackage.sun.rmi.server")) && (!name.equals("accessClassInPackage.sun.rmi.registry")))) { throw e; } return resolvedClass; }
Example 12
Source File: MarshalInputStream.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Fix for 4179055: Need to assist resolving sun stubs; resolve * class locally if it is a "permitted" sun class */ private Class<?> checkSunClass(String className, AccessControlException e) throws AccessControlException { // ensure that we are giving out a stub for the correct reason Permission perm = e.getPermission(); String name = null; if (perm != null) { name = perm.getName(); } Class<?> resolvedClass = permittedSunClasses.get(className); // if class not permitted, throw the SecurityException if ((name == null) || (resolvedClass == null) || ((!name.equals("accessClassInPackage.sun.rmi.server")) && (!name.equals("accessClassInPackage.sun.rmi.registry")))) { throw e; } return resolvedClass; }
Example 13
Source File: MarshalInputStream.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Fix for 4179055: Need to assist resolving sun stubs; resolve * class locally if it is a "permitted" sun class */ private Class<?> checkSunClass(String className, AccessControlException e) throws AccessControlException { // ensure that we are giving out a stub for the correct reason Permission perm = e.getPermission(); String name = null; if (perm != null) { name = perm.getName(); } Class<?> resolvedClass = permittedSunClasses.get(className); // if class not permitted, throw the SecurityException if ((name == null) || (resolvedClass == null) || ((!name.equals("accessClassInPackage.sun.rmi.server")) && (!name.equals("accessClassInPackage.sun.rmi.registry")))) { throw e; } return resolvedClass; }
Example 14
Source File: MarshalInputStream.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Fix for 4179055: Need to assist resolving sun stubs; resolve * class locally if it is a "permitted" sun class */ private Class<?> checkSunClass(String className, AccessControlException e) throws AccessControlException { // ensure that we are giving out a stub for the correct reason Permission perm = e.getPermission(); String name = null; if (perm != null) { name = perm.getName(); } Class<?> resolvedClass = permittedSunClasses.get(className); // if class not permitted, throw the SecurityException if ((name == null) || (resolvedClass == null) || ((!name.equals("accessClassInPackage.sun.rmi.server")) && (!name.equals("accessClassInPackage.sun.rmi.registry")))) { throw e; } return resolvedClass; }
Example 15
Source File: SystemUtil.java From gradle-avro-plugin with Apache License 2.0 | 5 votes |
static void forbidSystemExitCall() { final SecurityManager securityManager = new SecurityManager() { public void checkPermission(Permission permission) { String permissionName = permission.getName(); if (permissionName.startsWith(PERMISSION_PREFIX)) { String suffix = permissionName.substring(PERMISSION_PREFIX.length()); int status = Integer.parseInt(suffix); throw new ExitTrappedException(status); } } }; System.setSecurityManager(securityManager); }
Example 16
Source File: PluginSecurity.java From Elasticsearch with Apache License 2.0 | 5 votes |
/** Format permission type, name, and actions into a string */ static String formatPermission(Permission permission) { StringBuilder sb = new StringBuilder(); String clazz = null; if (permission instanceof UnresolvedPermission) { clazz = ((UnresolvedPermission) permission).getUnresolvedType(); } else { clazz = permission.getClass().getName(); } sb.append(clazz); String name = null; if (permission instanceof UnresolvedPermission) { name = ((UnresolvedPermission) permission).getUnresolvedName(); } else { name = permission.getName(); } if (name != null && name.length() > 0) { sb.append(' '); sb.append(name); } String actions = null; if (permission instanceof UnresolvedPermission) { actions = ((UnresolvedPermission) permission).getUnresolvedActions(); } else { actions = permission.getActions(); } if (actions != null && actions.length() > 0) { sb.append(' '); sb.append(actions); } return sb.toString(); }
Example 17
Source File: RenderSecurityManager.java From javaide with GNU General Public License v3.0 | 5 votes |
@Override public void checkPermission(Permission permission) { String name = permission.getName(); if ("setSecurityManager".equals(name)) { if (isRelevant()) { if (!mAllowSetSecurityManager) { throw RenderSecurityException.create("Security", null); } } else if (mLogger != null) { mLogger.warning("RenderSecurityManager being replaced by another thread"); } } else if (isRelevant()) { String actions = permission.getActions(); //noinspection PointlessBooleanExpression,ConstantConditions if (RESTRICT_READS && "read".equals(actions)) { if (!isReadingAllowed(name)) { throw RenderSecurityException.create("Read", name); } } else if (!actions.isEmpty() && !actions.equals("read")) { // write, execute, delete, readlink if (!(permission instanceof FilePermission) || !isWritingAllowed(name)) { if (permission instanceof PropertyPermission && isPropertyWriteAllowed(name)) { return; } throw RenderSecurityException.create("Write", name); } } } }
Example 18
Source File: DefaultPolicyBuilder.java From onos with Apache License 2.0 | 4 votes |
public static org.onosproject.security.Permission getOnosPermission(Permission permission) { if (permission instanceof AppPermission) { return new org.onosproject.security.Permission(AppPermission.class.getName(), permission.getName(), ""); } else if (permission instanceof FilePermission) { return new org.onosproject.security.Permission( FilePermission.class.getName(), permission.getName(), permission.getActions()); } else if (permission instanceof SerializablePermission) { return new org.onosproject.security.Permission( SerializablePermission.class.getName(), permission.getName(), permission.getActions()); } else if (permission instanceof NetPermission) { return new org.onosproject.security.Permission( NetPermission.class.getName(), permission.getName(), permission.getActions()); } else if (permission instanceof RuntimePermission) { return new org.onosproject.security.Permission( RuntimePermission.class.getName(), permission.getName(), permission.getActions()); } else if (permission instanceof SocketPermission) { return new org.onosproject.security.Permission( SocketPermission.class.getName(), permission.getName(), permission.getActions()); } else if (permission instanceof SQLPermission) { return new org.onosproject.security.Permission( SQLPermission.class.getName(), permission.getName(), permission.getActions()); } else if (permission instanceof PropertyPermission) { return new org.onosproject.security.Permission( PropertyPermission.class.getName(), permission.getName(), permission.getActions()); } else if (permission instanceof LoggingPermission) { return new org.onosproject.security.Permission( LoggingPermission.class.getName(), permission.getName(), permission.getActions()); } else if (permission instanceof SSLPermission) { return new org.onosproject.security.Permission( SSLPermission.class.getName(), permission.getName(), permission.getActions()); } else if (permission instanceof AuthPermission) { return new org.onosproject.security.Permission( AuthPermission.class.getName(), permission.getName(), permission.getActions()); } else if (permission instanceof PrivateCredentialPermission) { return new org.onosproject.security.Permission( PrivateCredentialPermission.class.getName(), permission.getName(), permission.getActions()); } else if (permission instanceof DelegationPermission) { return new org.onosproject.security.Permission( DelegationPermission.class.getName(), permission.getName(), permission.getActions()); } else if (permission instanceof javax.security.auth.kerberos.ServicePermission) { return new org.onosproject.security.Permission( javax.security.auth.kerberos.ServicePermission.class.getName(), permission.getName(), permission.getActions()); } else if (permission instanceof AudioPermission) { return new org.onosproject.security.Permission( AudioPermission.class.getName(), permission.getName(), permission.getActions()); } else if (permission instanceof AdaptPermission) { return new org.onosproject.security.Permission( AdaptPermission.class.getName(), permission.getName(), permission.getActions()); } else if (permission instanceof BundlePermission) { return new org.onosproject.security.Permission( BundlePermission.class.getName(), permission.getName(), permission.getActions()); } else if (permission instanceof CapabilityPermission) { return new org.onosproject.security.Permission( CapabilityPermission.class.getName(), permission.getName(), permission.getActions()); } else if (permission instanceof PackagePermission) { return new org.onosproject.security.Permission( PackagePermission.class.getName(), permission.getName(), permission.getActions()); } else if (permission instanceof ServicePermission) { return new org.onosproject.security.Permission( ServicePermission.class.getName(), permission.getName(), permission.getActions()); } else if (permission instanceof AdminPermission) { return new org.onosproject.security.Permission( AdminPermission.class.getName(), permission.getName(), permission.getActions()); //} else if (permission instanceof ConfigurationPermission) { // return new org.onosproject.security.Permission( // ConfigurationPermission.class.getName(), permission.getName(), permission.getActions()); } return null; }
Example 19
Source File: SESecurityManagerImpl.java From TorrentEngine with GNU General Public License v3.0 | 3 votes |
public void checkPermission( Permission perm, Object context) { if ( perm instanceof RuntimePermission ){ String name = perm.getName(); if ( name.equals( "stopThread")){ synchronized( stoppable_threads ){ if ( stoppable_threads.contains( Thread.currentThread())){ return; } } throw( new SecurityException( "Thread.stop operation prohibited")); }else if ( name.equals( "setSecurityManager" )){ throw( new SecurityException( "Permission Denied")); } } if ( old_sec_man != null ){ if ( context == null ){ old_sec_man.checkPermission( perm ); }else{ old_sec_man.checkPermission( perm, context ); } } }
Example 20
Source File: SESecurityManagerImpl.java From BiglyBT with GNU General Public License v2.0 | 2 votes |
@Override public void checkPermission( Permission perm, Object context) { if ( perm instanceof RuntimePermission ){ String name = perm.getName(); if ( name.equals( "stopThread")){ synchronized( stoppable_threads ){ if ( stoppable_threads.contains( Thread.currentThread())){ return; } } throw( new SecurityException( "Thread.stop operation prohibited")); }else if ( name.equals( "setSecurityManager" )){ throw( new SecurityException( "Permission Denied")); } }else if ( perm instanceof NetPermission ){ // we have to fail this permission in order to cause the NetworkInterface code // to revert to calling checkConnect if ( tls_ni.get() == null && !filtered_addresses.isEmpty()){ if ( perm.getName().equals( "getNetworkInformation" )){ throw( new SecurityException( "Permission Denied")); } } } if ( old_sec_man != null ){ if ( context == null ){ old_sec_man.checkPermission( perm ); }else{ old_sec_man.checkPermission( perm, context ); } } }