java.lang.RuntimePermission Java Examples
The following examples show how to use
java.lang.RuntimePermission.
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: SecurityManager.java From Java8CN with Apache License 2.0 | 5 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to define classes in the package * specified by the argument. * <p> * This method is used by the <code>loadClass</code> method of some * class loaders. * <p> * This method first gets a list of restricted packages by * obtaining a comma-separated list from a call to * <code>java.security.Security.getProperty("package.definition")</code>, * and checks to see if <code>pkg</code> starts with or equals * any of the restricted packages. If it does, then * <code>checkPermission</code> gets called with the * <code>RuntimePermission("defineClassInPackage."+pkg)</code> * permission. * <p> * If this method is overridden, then * <code>super.checkPackageDefinition</code> should be called * as the first line in the overridden method. * * @param pkg the package name. * @exception SecurityException if the calling thread does not have * permission to define classes in the specified package. * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean) * @see java.security.Security#getProperty getProperty * @see #checkPermission(java.security.Permission) checkPermission */ public void checkPackageDefinition(String pkg) { if (pkg == null) { throw new NullPointerException("package name can't be null"); } String[] pkgs; synchronized (packageDefinitionLock) { /* * Do we need to update our property array? */ if (!packageDefinitionValid) { String tmpPropertyStr = AccessController.doPrivileged( new PrivilegedAction<String>() { public String run() { return java.security.Security.getProperty( "package.definition"); } } ); packageDefinition = getPackages(tmpPropertyStr); packageDefinitionValid = true; } // Using a snapshot of packageDefinition -- don't care if static // field changes afterwards; array contents won't change. pkgs = packageDefinition; } /* * Traverse the list of packages, check for any matches. */ for (int i = 0; i < pkgs.length; i++) { if (pkg.startsWith(pkgs[i]) || pkgs[i].equals(pkg + ".")) { checkPermission( new RuntimePermission("defineClassInPackage."+pkg)); break; // No need to continue; only need to check this once } } }
Example #2
Source File: SecurityManager.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to define classes in the package * specified by the argument. * <p> * This method is used by the <code>loadClass</code> method of some * class loaders. * <p> * This method first gets a list of restricted packages by * obtaining a comma-separated list from a call to * <code>java.security.Security.getProperty("package.definition")</code>, * and checks to see if <code>pkg</code> starts with or equals * any of the restricted packages. If it does, then * <code>checkPermission</code> gets called with the * <code>RuntimePermission("defineClassInPackage."+pkg)</code> * permission. * <p> * If this method is overridden, then * <code>super.checkPackageDefinition</code> should be called * as the first line in the overridden method. * * @param pkg the package name. * @exception SecurityException if the calling thread does not have * permission to define classes in the specified package. * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean) * @see java.security.Security#getProperty getProperty * @see #checkPermission(java.security.Permission) checkPermission */ public void checkPackageDefinition(String pkg) { if (pkg == null) { throw new NullPointerException("package name can't be null"); } String[] pkgs; synchronized (packageDefinitionLock) { /* * Do we need to update our property array? */ if (!packageDefinitionValid) { String tmpPropertyStr = AccessController.doPrivileged( new PrivilegedAction<String>() { public String run() { return java.security.Security.getProperty( "package.definition"); } } ); packageDefinition = getPackages(tmpPropertyStr); packageDefinitionValid = true; } // Using a snapshot of packageDefinition -- don't care if static // field changes afterwards; array contents won't change. pkgs = packageDefinition; } /* * Traverse the list of packages, check for any matches. */ for (int i = 0; i < pkgs.length; i++) { if (pkg.startsWith(pkgs[i]) || pkgs[i].equals(pkg + ".")) { checkPermission( new RuntimePermission("defineClassInPackage."+pkg)); break; // No need to continue; only need to check this once } } }
Example #3
Source File: SecurityManager.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to define classes in the package * specified by the argument. * <p> * This method is used by the <code>loadClass</code> method of some * class loaders. * <p> * This method first gets a list of restricted packages by * obtaining a comma-separated list from a call to * <code>java.security.Security.getProperty("package.definition")</code>, * and checks to see if <code>pkg</code> starts with or equals * any of the restricted packages. If it does, then * <code>checkPermission</code> gets called with the * <code>RuntimePermission("defineClassInPackage."+pkg)</code> * permission. * <p> * If this method is overridden, then * <code>super.checkPackageDefinition</code> should be called * as the first line in the overridden method. * * @param pkg the package name. * @exception SecurityException if the calling thread does not have * permission to define classes in the specified package. * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean) * @see java.security.Security#getProperty getProperty * @see #checkPermission(java.security.Permission) checkPermission */ public void checkPackageDefinition(String pkg) { if (pkg == null) { throw new NullPointerException("package name can't be null"); } String[] pkgs; synchronized (packageDefinitionLock) { /* * Do we need to update our property array? */ if (!packageDefinitionValid) { String tmpPropertyStr = AccessController.doPrivileged( new PrivilegedAction<String>() { public String run() { return java.security.Security.getProperty( "package.definition"); } } ); packageDefinition = getPackages(tmpPropertyStr); packageDefinitionValid = true; } // Using a snapshot of packageDefinition -- don't care if static // field changes afterwards; array contents won't change. pkgs = packageDefinition; } /* * Traverse the list of packages, check for any matches. */ for (int i = 0; i < pkgs.length; i++) { if (pkg.startsWith(pkgs[i]) || pkgs[i].equals(pkg + ".")) { checkPermission( new RuntimePermission("defineClassInPackage."+pkg)); break; // No need to continue; only need to check this once } } }
Example #4
Source File: SecurityManager.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to define classes in the package * specified by the argument. * <p> * This method is used by the <code>loadClass</code> method of some * class loaders. * <p> * This method first gets a list of restricted packages by * obtaining a comma-separated list from a call to * <code>java.security.Security.getProperty("package.definition")</code>, * and checks to see if <code>pkg</code> starts with or equals * any of the restricted packages. If it does, then * <code>checkPermission</code> gets called with the * <code>RuntimePermission("defineClassInPackage."+pkg)</code> * permission. * <p> * If this method is overridden, then * <code>super.checkPackageDefinition</code> should be called * as the first line in the overridden method. * * @param pkg the package name. * @exception SecurityException if the calling thread does not have * permission to define classes in the specified package. * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean) * @see java.security.Security#getProperty getProperty * @see #checkPermission(java.security.Permission) checkPermission */ public void checkPackageDefinition(String pkg) { if (pkg == null) { throw new NullPointerException("package name can't be null"); } String[] pkgs; synchronized (packageDefinitionLock) { /* * Do we need to update our property array? */ if (!packageDefinitionValid) { String tmpPropertyStr = AccessController.doPrivileged( new PrivilegedAction<String>() { public String run() { return java.security.Security.getProperty( "package.definition"); } } ); packageDefinition = getPackages(tmpPropertyStr); packageDefinitionValid = true; } // Using a snapshot of packageDefinition -- don't care if static // field changes afterwards; array contents won't change. pkgs = packageDefinition; } /* * Traverse the list of packages, check for any matches. */ for (int i = 0; i < pkgs.length; i++) { if (pkg.startsWith(pkgs[i]) || pkgs[i].equals(pkg + ".")) { checkPermission( new RuntimePermission("defineClassInPackage."+pkg)); break; // No need to continue; only need to check this once } } }
Example #5
Source File: SecurityManager.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to define classes in the package * specified by the argument. * <p> * This method is used by the <code>loadClass</code> method of some * class loaders. * <p> * This method first gets a list of restricted packages by * obtaining a comma-separated list from a call to * <code>java.security.Security.getProperty("package.definition")</code>, * and checks to see if <code>pkg</code> starts with or equals * any of the restricted packages. If it does, then * <code>checkPermission</code> gets called with the * <code>RuntimePermission("defineClassInPackage."+pkg)</code> * permission. * <p> * If this method is overridden, then * <code>super.checkPackageDefinition</code> should be called * as the first line in the overridden method. * * @param pkg the package name. * @exception SecurityException if the calling thread does not have * permission to define classes in the specified package. * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean) * @see java.security.Security#getProperty getProperty * @see #checkPermission(java.security.Permission) checkPermission */ public void checkPackageDefinition(String pkg) { if (pkg == null) { throw new NullPointerException("package name can't be null"); } String[] pkgs; synchronized (packageDefinitionLock) { /* * Do we need to update our property array? */ if (!packageDefinitionValid) { String tmpPropertyStr = AccessController.doPrivileged( new PrivilegedAction<String>() { public String run() { return java.security.Security.getProperty( "package.definition"); } } ); packageDefinition = getPackages(tmpPropertyStr); packageDefinitionValid = true; } // Using a snapshot of packageDefinition -- don't care if static // field changes afterwards; array contents won't change. pkgs = packageDefinition; } /* * Traverse the list of packages, check for any matches. */ for (int i = 0; i < pkgs.length; i++) { if (pkg.startsWith(pkgs[i]) || pkgs[i].equals(pkg + ".")) { checkPermission( new RuntimePermission("defineClassInPackage."+pkg)); break; // No need to continue; only need to check this once } } }
Example #6
Source File: SecurityManager.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to define classes in the package * specified by the argument. * <p> * This method is used by the <code>loadClass</code> method of some * class loaders. * <p> * This method first gets a list of restricted packages by * obtaining a comma-separated list from a call to * <code>java.security.Security.getProperty("package.definition")</code>, * and checks to see if <code>pkg</code> starts with or equals * any of the restricted packages. If it does, then * <code>checkPermission</code> gets called with the * <code>RuntimePermission("defineClassInPackage."+pkg)</code> * permission. * <p> * If this method is overridden, then * <code>super.checkPackageDefinition</code> should be called * as the first line in the overridden method. * * @param pkg the package name. * @exception SecurityException if the calling thread does not have * permission to define classes in the specified package. * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean) * @see java.security.Security#getProperty getProperty * @see #checkPermission(java.security.Permission) checkPermission */ public void checkPackageDefinition(String pkg) { if (pkg == null) { throw new NullPointerException("package name can't be null"); } String[] pkgs; synchronized (packageDefinitionLock) { /* * Do we need to update our property array? */ if (!packageDefinitionValid) { String tmpPropertyStr = AccessController.doPrivileged( new PrivilegedAction<String>() { public String run() { return java.security.Security.getProperty( "package.definition"); } } ); packageDefinition = getPackages(tmpPropertyStr); packageDefinitionValid = true; } // Using a snapshot of packageDefinition -- don't care if static // field changes afterwards; array contents won't change. pkgs = packageDefinition; } /* * Traverse the list of packages, check for any matches. */ for (int i = 0; i < pkgs.length; i++) { if (pkg.startsWith(pkgs[i]) || pkgs[i].equals(pkg + ".")) { checkPermission( new RuntimePermission("defineClassInPackage."+pkg)); break; // No need to continue; only need to check this once } } }
Example #7
Source File: SecurityManager.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to define classes in the package * specified by the argument. * <p> * This method is used by the <code>loadClass</code> method of some * class loaders. * <p> * This method first gets a list of restricted packages by * obtaining a comma-separated list from a call to * <code>java.security.Security.getProperty("package.definition")</code>, * and checks to see if <code>pkg</code> starts with or equals * any of the restricted packages. If it does, then * <code>checkPermission</code> gets called with the * <code>RuntimePermission("defineClassInPackage."+pkg)</code> * permission. * <p> * If this method is overridden, then * <code>super.checkPackageDefinition</code> should be called * as the first line in the overridden method. * * @param pkg the package name. * @exception SecurityException if the calling thread does not have * permission to define classes in the specified package. * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean) * @see java.security.Security#getProperty getProperty * @see #checkPermission(java.security.Permission) checkPermission */ public void checkPackageDefinition(String pkg) { if (pkg == null) { throw new NullPointerException("package name can't be null"); } String[] pkgs; synchronized (packageDefinitionLock) { /* * Do we need to update our property array? */ if (!packageDefinitionValid) { String tmpPropertyStr = AccessController.doPrivileged( new PrivilegedAction<String>() { public String run() { return java.security.Security.getProperty( "package.definition"); } } ); packageDefinition = getPackages(tmpPropertyStr); packageDefinitionValid = true; } // Using a snapshot of packageDefinition -- don't care if static // field changes afterwards; array contents won't change. pkgs = packageDefinition; } /* * Traverse the list of packages, check for any matches. */ for (int i = 0; i < pkgs.length; i++) { if (pkg.startsWith(pkgs[i]) || pkgs[i].equals(pkg + ".")) { checkPermission( new RuntimePermission("defineClassInPackage."+pkg)); break; // No need to continue; only need to check this once } } }
Example #8
Source File: SecurityManager.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to define classes in the package * specified by the argument. * <p> * This method is used by the <code>loadClass</code> method of some * class loaders. * <p> * This method first gets a list of restricted packages by * obtaining a comma-separated list from a call to * <code>java.security.Security.getProperty("package.definition")</code>, * and checks to see if <code>pkg</code> starts with or equals * any of the restricted packages. If it does, then * <code>checkPermission</code> gets called with the * <code>RuntimePermission("defineClassInPackage."+pkg)</code> * permission. * <p> * If this method is overridden, then * <code>super.checkPackageDefinition</code> should be called * as the first line in the overridden method. * * @param pkg the package name. * @exception SecurityException if the calling thread does not have * permission to define classes in the specified package. * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean) * @see java.security.Security#getProperty getProperty * @see #checkPermission(java.security.Permission) checkPermission */ public void checkPackageDefinition(String pkg) { if (pkg == null) { throw new NullPointerException("package name can't be null"); } String[] pkgs; synchronized (packageDefinitionLock) { /* * Do we need to update our property array? */ if (!packageDefinitionValid) { String tmpPropertyStr = AccessController.doPrivileged( new PrivilegedAction<String>() { public String run() { return java.security.Security.getProperty( "package.definition"); } } ); packageDefinition = getPackages(tmpPropertyStr); packageDefinitionValid = true; } // Using a snapshot of packageDefinition -- don't care if static // field changes afterwards; array contents won't change. pkgs = packageDefinition; } /* * Traverse the list of packages, check for any matches. */ for (int i = 0; i < pkgs.length; i++) { if (pkg.startsWith(pkgs[i]) || pkgs[i].equals(pkg + ".")) { checkPermission( new RuntimePermission("defineClassInPackage."+pkg)); break; // No need to continue; only need to check this once } } }
Example #9
Source File: SecurityManager.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to define classes in the package * specified by the argument. * <p> * This method is used by the <code>loadClass</code> method of some * class loaders. * <p> * This method first gets a list of restricted packages by * obtaining a comma-separated list from a call to * <code>java.security.Security.getProperty("package.definition")</code>, * and checks to see if <code>pkg</code> starts with or equals * any of the restricted packages. If it does, then * <code>checkPermission</code> gets called with the * <code>RuntimePermission("defineClassInPackage."+pkg)</code> * permission. * <p> * If this method is overridden, then * <code>super.checkPackageDefinition</code> should be called * as the first line in the overridden method. * * @param pkg the package name. * @exception SecurityException if the calling thread does not have * permission to define classes in the specified package. * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean) * @see java.security.Security#getProperty getProperty * @see #checkPermission(java.security.Permission) checkPermission */ public void checkPackageDefinition(String pkg) { if (pkg == null) { throw new NullPointerException("package name can't be null"); } String[] pkgs; synchronized (packageDefinitionLock) { /* * Do we need to update our property array? */ if (!packageDefinitionValid) { String tmpPropertyStr = AccessController.doPrivileged( new PrivilegedAction<String>() { public String run() { return java.security.Security.getProperty( "package.definition"); } } ); packageDefinition = getPackages(tmpPropertyStr); packageDefinitionValid = true; } // Using a snapshot of packageDefinition -- don't care if static // field changes afterwards; array contents won't change. pkgs = packageDefinition; } /* * Traverse the list of packages, check for any matches. */ for (int i = 0; i < pkgs.length; i++) { if (pkg.startsWith(pkgs[i]) || pkgs[i].equals(pkg + ".")) { checkPermission( new RuntimePermission("defineClassInPackage."+pkg)); break; // No need to continue; only need to check this once } } }
Example #10
Source File: SecurityManager.java From Java8CN with Apache License 2.0 | 4 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to access the package specified by * the argument. * <p> * This method is used by the <code>loadClass</code> method of class * loaders. * <p> * This method first gets a list of * restricted packages by obtaining a comma-separated list from * a call to * <code>java.security.Security.getProperty("package.access")</code>, * and checks to see if <code>pkg</code> starts with or equals * any of the restricted packages. If it does, then * <code>checkPermission</code> gets called with the * <code>RuntimePermission("accessClassInPackage."+pkg)</code> * permission. * <p> * If this method is overridden, then * <code>super.checkPackageAccess</code> should be called * as the first line in the overridden method. * * @param pkg the package name. * @exception SecurityException if the calling thread does not have * permission to access the specified package. * @exception NullPointerException if the package name argument is * <code>null</code>. * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean) * loadClass * @see java.security.Security#getProperty getProperty * @see #checkPermission(java.security.Permission) checkPermission */ public void checkPackageAccess(String pkg) { if (pkg == null) { throw new NullPointerException("package name can't be null"); } String[] pkgs; synchronized (packageAccessLock) { /* * Do we need to update our property array? */ if (!packageAccessValid) { String tmpPropertyStr = AccessController.doPrivileged( new PrivilegedAction<String>() { public String run() { return java.security.Security.getProperty( "package.access"); } } ); packageAccess = getPackages(tmpPropertyStr); packageAccessValid = true; } // Using a snapshot of packageAccess -- don't care if static field // changes afterwards; array contents won't change. pkgs = packageAccess; } /* * Traverse the list of packages, check for any matches. */ for (int i = 0; i < pkgs.length; i++) { if (pkg.startsWith(pkgs[i]) || pkgs[i].equals(pkg + ".")) { checkPermission( new RuntimePermission("accessClassInPackage."+pkg)); break; // No need to continue; only need to check this once } } }
Example #11
Source File: SecurityManager.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to access the package specified by * the argument. * <p> * This method is used by the <code>loadClass</code> method of class * loaders. * <p> * This method first gets a list of * restricted packages by obtaining a comma-separated list from * a call to * <code>java.security.Security.getProperty("package.access")</code>, * and checks to see if <code>pkg</code> starts with or equals * any of the restricted packages. If it does, then * <code>checkPermission</code> gets called with the * <code>RuntimePermission("accessClassInPackage."+pkg)</code> * permission. * <p> * If this method is overridden, then * <code>super.checkPackageAccess</code> should be called * as the first line in the overridden method. * * @param pkg the package name. * @exception SecurityException if the calling thread does not have * permission to access the specified package. * @exception NullPointerException if the package name argument is * <code>null</code>. * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean) * loadClass * @see java.security.Security#getProperty getProperty * @see #checkPermission(java.security.Permission) checkPermission */ public void checkPackageAccess(String pkg) { if (pkg == null) { throw new NullPointerException("package name can't be null"); } String[] pkgs; synchronized (packageAccessLock) { /* * Do we need to update our property array? */ if (!packageAccessValid) { String tmpPropertyStr = AccessController.doPrivileged( new PrivilegedAction<String>() { public String run() { return java.security.Security.getProperty( "package.access"); } } ); packageAccess = getPackages(tmpPropertyStr); packageAccessValid = true; } // Using a snapshot of packageAccess -- don't care if static field // changes afterwards; array contents won't change. pkgs = packageAccess; } /* * Traverse the list of packages, check for any matches. */ for (int i = 0; i < pkgs.length; i++) { if (pkg.startsWith(pkgs[i]) || pkgs[i].equals(pkg + ".")) { checkPermission( new RuntimePermission("accessClassInPackage."+pkg)); break; // No need to continue; only need to check this once } } }
Example #12
Source File: SecurityManager.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to access the package specified by * the argument. * <p> * This method is used by the <code>loadClass</code> method of class * loaders. * <p> * This method first gets a list of * restricted packages by obtaining a comma-separated list from * a call to * <code>java.security.Security.getProperty("package.access")</code>, * and checks to see if <code>pkg</code> starts with or equals * any of the restricted packages. If it does, then * <code>checkPermission</code> gets called with the * <code>RuntimePermission("accessClassInPackage."+pkg)</code> * permission. * <p> * If this method is overridden, then * <code>super.checkPackageAccess</code> should be called * as the first line in the overridden method. * * @param pkg the package name. * @exception SecurityException if the calling thread does not have * permission to access the specified package. * @exception NullPointerException if the package name argument is * <code>null</code>. * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean) * loadClass * @see java.security.Security#getProperty getProperty * @see #checkPermission(java.security.Permission) checkPermission */ public void checkPackageAccess(String pkg) { if (pkg == null) { throw new NullPointerException("package name can't be null"); } String[] pkgs; synchronized (packageAccessLock) { /* * Do we need to update our property array? */ if (!packageAccessValid) { String tmpPropertyStr = AccessController.doPrivileged( new PrivilegedAction<String>() { public String run() { return java.security.Security.getProperty( "package.access"); } } ); packageAccess = getPackages(tmpPropertyStr); packageAccessValid = true; } // Using a snapshot of packageAccess -- don't care if static field // changes afterwards; array contents won't change. pkgs = packageAccess; } /* * Traverse the list of packages, check for any matches. */ for (int i = 0; i < pkgs.length; i++) { if (pkg.startsWith(pkgs[i]) || pkgs[i].equals(pkg + ".")) { checkPermission( new RuntimePermission("accessClassInPackage."+pkg)); break; // No need to continue; only need to check this once } } }
Example #13
Source File: SecurityManager.java From JDKSourceCode1.8 with MIT License | 4 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to access the package specified by * the argument. * <p> * This method is used by the <code>loadClass</code> method of class * loaders. * <p> * This method first gets a list of * restricted packages by obtaining a comma-separated list from * a call to * <code>java.security.Security.getProperty("package.access")</code>, * and checks to see if <code>pkg</code> starts with or equals * any of the restricted packages. If it does, then * <code>checkPermission</code> gets called with the * <code>RuntimePermission("accessClassInPackage."+pkg)</code> * permission. * <p> * If this method is overridden, then * <code>super.checkPackageAccess</code> should be called * as the first line in the overridden method. * * @param pkg the package name. * @exception SecurityException if the calling thread does not have * permission to access the specified package. * @exception NullPointerException if the package name argument is * <code>null</code>. * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean) * loadClass * @see java.security.Security#getProperty getProperty * @see #checkPermission(java.security.Permission) checkPermission */ public void checkPackageAccess(String pkg) { if (pkg == null) { throw new NullPointerException("package name can't be null"); } String[] pkgs; synchronized (packageAccessLock) { /* * Do we need to update our property array? */ if (!packageAccessValid) { String tmpPropertyStr = AccessController.doPrivileged( new PrivilegedAction<String>() { public String run() { return java.security.Security.getProperty( "package.access"); } } ); packageAccess = getPackages(tmpPropertyStr); packageAccessValid = true; } // Using a snapshot of packageAccess -- don't care if static field // changes afterwards; array contents won't change. pkgs = packageAccess; } /* * Traverse the list of packages, check for any matches. */ for (int i = 0; i < pkgs.length; i++) { if (pkg.startsWith(pkgs[i]) || pkgs[i].equals(pkg + ".")) { checkPermission( new RuntimePermission("accessClassInPackage."+pkg)); break; // No need to continue; only need to check this once } } }
Example #14
Source File: SecurityManager.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to access the package specified by * the argument. * <p> * This method is used by the <code>loadClass</code> method of class * loaders. * <p> * This method first gets a list of * restricted packages by obtaining a comma-separated list from * a call to * <code>java.security.Security.getProperty("package.access")</code>, * and checks to see if <code>pkg</code> starts with or equals * any of the restricted packages. If it does, then * <code>checkPermission</code> gets called with the * <code>RuntimePermission("accessClassInPackage."+pkg)</code> * permission. * <p> * If this method is overridden, then * <code>super.checkPackageAccess</code> should be called * as the first line in the overridden method. * * @param pkg the package name. * @exception SecurityException if the calling thread does not have * permission to access the specified package. * @exception NullPointerException if the package name argument is * <code>null</code>. * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean) * loadClass * @see java.security.Security#getProperty getProperty * @see #checkPermission(java.security.Permission) checkPermission */ public void checkPackageAccess(String pkg) { if (pkg == null) { throw new NullPointerException("package name can't be null"); } String[] pkgs; synchronized (packageAccessLock) { /* * Do we need to update our property array? */ if (!packageAccessValid) { String tmpPropertyStr = AccessController.doPrivileged( new PrivilegedAction<String>() { public String run() { return java.security.Security.getProperty( "package.access"); } } ); packageAccess = getPackages(tmpPropertyStr); packageAccessValid = true; } // Using a snapshot of packageAccess -- don't care if static field // changes afterwards; array contents won't change. pkgs = packageAccess; } /* * Traverse the list of packages, check for any matches. */ for (int i = 0; i < pkgs.length; i++) { if (pkg.startsWith(pkgs[i]) || pkgs[i].equals(pkg + ".")) { checkPermission( new RuntimePermission("accessClassInPackage."+pkg)); break; // No need to continue; only need to check this once } } }
Example #15
Source File: SecurityManager.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to access the package specified by * the argument. * <p> * This method is used by the <code>loadClass</code> method of class * loaders. * <p> * This method first gets a list of * restricted packages by obtaining a comma-separated list from * a call to * <code>java.security.Security.getProperty("package.access")</code>, * and checks to see if <code>pkg</code> starts with or equals * any of the restricted packages. If it does, then * <code>checkPermission</code> gets called with the * <code>RuntimePermission("accessClassInPackage."+pkg)</code> * permission. * <p> * If this method is overridden, then * <code>super.checkPackageAccess</code> should be called * as the first line in the overridden method. * * @param pkg the package name. * @exception SecurityException if the calling thread does not have * permission to access the specified package. * @exception NullPointerException if the package name argument is * <code>null</code>. * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean) * loadClass * @see java.security.Security#getProperty getProperty * @see #checkPermission(java.security.Permission) checkPermission */ public void checkPackageAccess(String pkg) { if (pkg == null) { throw new NullPointerException("package name can't be null"); } String[] pkgs; synchronized (packageAccessLock) { /* * Do we need to update our property array? */ if (!packageAccessValid) { String tmpPropertyStr = AccessController.doPrivileged( new PrivilegedAction<String>() { public String run() { return java.security.Security.getProperty( "package.access"); } } ); packageAccess = getPackages(tmpPropertyStr); packageAccessValid = true; } // Using a snapshot of packageAccess -- don't care if static field // changes afterwards; array contents won't change. pkgs = packageAccess; } /* * Traverse the list of packages, check for any matches. */ for (int i = 0; i < pkgs.length; i++) { if (pkg.startsWith(pkgs[i]) || pkgs[i].equals(pkg + ".")) { checkPermission( new RuntimePermission("accessClassInPackage."+pkg)); break; // No need to continue; only need to check this once } } }
Example #16
Source File: SecurityManager.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to access the package specified by * the argument. * <p> * This method is used by the <code>loadClass</code> method of class * loaders. * <p> * This method first gets a list of * restricted packages by obtaining a comma-separated list from * a call to * <code>java.security.Security.getProperty("package.access")</code>, * and checks to see if <code>pkg</code> starts with or equals * any of the restricted packages. If it does, then * <code>checkPermission</code> gets called with the * <code>RuntimePermission("accessClassInPackage."+pkg)</code> * permission. * <p> * If this method is overridden, then * <code>super.checkPackageAccess</code> should be called * as the first line in the overridden method. * * @param pkg the package name. * @exception SecurityException if the calling thread does not have * permission to access the specified package. * @exception NullPointerException if the package name argument is * <code>null</code>. * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean) * loadClass * @see java.security.Security#getProperty getProperty * @see #checkPermission(java.security.Permission) checkPermission */ public void checkPackageAccess(String pkg) { if (pkg == null) { throw new NullPointerException("package name can't be null"); } String[] pkgs; synchronized (packageAccessLock) { /* * Do we need to update our property array? */ if (!packageAccessValid) { String tmpPropertyStr = AccessController.doPrivileged( new PrivilegedAction<String>() { public String run() { return java.security.Security.getProperty( "package.access"); } } ); packageAccess = getPackages(tmpPropertyStr); packageAccessValid = true; } // Using a snapshot of packageAccess -- don't care if static field // changes afterwards; array contents won't change. pkgs = packageAccess; } /* * Traverse the list of packages, check for any matches. */ for (int i = 0; i < pkgs.length; i++) { if (pkg.startsWith(pkgs[i]) || pkgs[i].equals(pkg + ".")) { checkPermission( new RuntimePermission("accessClassInPackage."+pkg)); break; // No need to continue; only need to check this once } } }
Example #17
Source File: SecurityManager.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to access the package specified by * the argument. * <p> * This method is used by the <code>loadClass</code> method of class * loaders. * <p> * This method first gets a list of * restricted packages by obtaining a comma-separated list from * a call to * <code>java.security.Security.getProperty("package.access")</code>, * and checks to see if <code>pkg</code> starts with or equals * any of the restricted packages. If it does, then * <code>checkPermission</code> gets called with the * <code>RuntimePermission("accessClassInPackage."+pkg)</code> * permission. * <p> * If this method is overridden, then * <code>super.checkPackageAccess</code> should be called * as the first line in the overridden method. * * @param pkg the package name. * @exception SecurityException if the calling thread does not have * permission to access the specified package. * @exception NullPointerException if the package name argument is * <code>null</code>. * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean) * loadClass * @see java.security.Security#getProperty getProperty * @see #checkPermission(java.security.Permission) checkPermission */ public void checkPackageAccess(String pkg) { if (pkg == null) { throw new NullPointerException("package name can't be null"); } String[] pkgs; synchronized (packageAccessLock) { /* * Do we need to update our property array? */ if (!packageAccessValid) { String tmpPropertyStr = AccessController.doPrivileged( new PrivilegedAction<String>() { public String run() { return java.security.Security.getProperty( "package.access"); } } ); packageAccess = getPackages(tmpPropertyStr); packageAccessValid = true; } // Using a snapshot of packageAccess -- don't care if static field // changes afterwards; array contents won't change. pkgs = packageAccess; } /* * Traverse the list of packages, check for any matches. */ for (int i = 0; i < pkgs.length; i++) { if (pkg.startsWith(pkgs[i]) || pkgs[i].equals(pkg + ".")) { checkPermission( new RuntimePermission("accessClassInPackage."+pkg)); break; // No need to continue; only need to check this once } } }
Example #18
Source File: SecurityManager.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to access the package specified by * the argument. * <p> * This method is used by the <code>loadClass</code> method of class * loaders. * <p> * This method first gets a list of * restricted packages by obtaining a comma-separated list from * a call to * <code>java.security.Security.getProperty("package.access")</code>, * and checks to see if <code>pkg</code> starts with or equals * any of the restricted packages. If it does, then * <code>checkPermission</code> gets called with the * <code>RuntimePermission("accessClassInPackage."+pkg)</code> * permission. * <p> * If this method is overridden, then * <code>super.checkPackageAccess</code> should be called * as the first line in the overridden method. * * @param pkg the package name. * @exception SecurityException if the calling thread does not have * permission to access the specified package. * @exception NullPointerException if the package name argument is * <code>null</code>. * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean) * loadClass * @see java.security.Security#getProperty getProperty * @see #checkPermission(java.security.Permission) checkPermission */ public void checkPackageAccess(String pkg) { if (pkg == null) { throw new NullPointerException("package name can't be null"); } String[] pkgs; synchronized (packageAccessLock) { /* * Do we need to update our property array? */ if (!packageAccessValid) { String tmpPropertyStr = AccessController.doPrivileged( new PrivilegedAction<String>() { public String run() { return java.security.Security.getProperty( "package.access"); } } ); packageAccess = getPackages(tmpPropertyStr); packageAccessValid = true; } // Using a snapshot of packageAccess -- don't care if static field // changes afterwards; array contents won't change. pkgs = packageAccess; } /* * Traverse the list of packages, check for any matches. */ for (int i = 0; i < pkgs.length; i++) { if (pkg.startsWith(pkgs[i]) || pkgs[i].equals(pkg + ".")) { checkPermission( new RuntimePermission("accessClassInPackage."+pkg)); break; // No need to continue; only need to check this once } } }
Example #19
Source File: SecurityManager.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to access the package specified by * the argument. * <p> * This method is used by the <code>loadClass</code> method of class * loaders. * <p> * This method first gets a list of * restricted packages by obtaining a comma-separated list from * a call to * <code>java.security.Security.getProperty("package.access")</code>, * and checks to see if <code>pkg</code> starts with or equals * any of the restricted packages. If it does, then * <code>checkPermission</code> gets called with the * <code>RuntimePermission("accessClassInPackage."+pkg)</code> * permission. * <p> * If this method is overridden, then * <code>super.checkPackageAccess</code> should be called * as the first line in the overridden method. * * @param pkg the package name. * @exception SecurityException if the calling thread does not have * permission to access the specified package. * @exception NullPointerException if the package name argument is * <code>null</code>. * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean) * loadClass * @see java.security.Security#getProperty getProperty * @see #checkPermission(java.security.Permission) checkPermission */ public void checkPackageAccess(String pkg) { if (pkg == null) { throw new NullPointerException("package name can't be null"); } String[] pkgs; synchronized (packageAccessLock) { /* * Do we need to update our property array? */ if (!packageAccessValid) { String tmpPropertyStr = AccessController.doPrivileged( new PrivilegedAction<String>() { public String run() { return java.security.Security.getProperty( "package.access"); } } ); packageAccess = getPackages(tmpPropertyStr); packageAccessValid = true; } // Using a snapshot of packageAccess -- don't care if static field // changes afterwards; array contents won't change. pkgs = packageAccess; } /* * Traverse the list of packages, check for any matches. */ for (int i = 0; i < pkgs.length; i++) { if (pkg.startsWith(pkgs[i]) || pkgs[i].equals(pkg + ".")) { checkPermission( new RuntimePermission("accessClassInPackage."+pkg)); break; // No need to continue; only need to check this once } } }
Example #20
Source File: SecurityManager.java From openjdk-jdk8u with GNU General Public License v2.0 | 3 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to write to the specified file * descriptor. * <p> * This method calls <code>checkPermission</code> with the * <code>RuntimePermission("writeFileDescriptor")</code> * permission. * <p> * If you override this method, then you should make a call to * <code>super.checkWrite</code> * at the point the overridden method would normally throw an * exception. * * @param fd the system-dependent file descriptor. * @exception SecurityException if the calling thread does not have * permission to access the specified file descriptor. * @exception NullPointerException if the file descriptor argument is * <code>null</code>. * @see java.io.FileDescriptor * @see #checkPermission(java.security.Permission) checkPermission */ public void checkWrite(FileDescriptor fd) { if (fd == null) { throw new NullPointerException("file descriptor can't be null"); } checkPermission(new RuntimePermission("writeFileDescriptor")); }
Example #21
Source File: SecurityManager.java From JDKSourceCode1.8 with MIT License | 3 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to write to the specified file * descriptor. * <p> * This method calls <code>checkPermission</code> with the * <code>RuntimePermission("writeFileDescriptor")</code> * permission. * <p> * If you override this method, then you should make a call to * <code>super.checkWrite</code> * at the point the overridden method would normally throw an * exception. * * @param fd the system-dependent file descriptor. * @exception SecurityException if the calling thread does not have * permission to access the specified file descriptor. * @exception NullPointerException if the file descriptor argument is * <code>null</code>. * @see java.io.FileDescriptor * @see #checkPermission(java.security.Permission) checkPermission */ public void checkWrite(FileDescriptor fd) { if (fd == null) { throw new NullPointerException("file descriptor can't be null"); } checkPermission(new RuntimePermission("writeFileDescriptor")); }
Example #22
Source File: SecurityManager.java From jdk8u_jdk with GNU General Public License v2.0 | 3 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to dynamic link the library code * specified by the string argument file. The argument is either a * simple library name or a complete filename. * <p> * This method is invoked for the current security manager by * methods <code>load</code> and <code>loadLibrary</code> of class * <code>Runtime</code>. * <p> * This method calls <code>checkPermission</code> with the * <code>RuntimePermission("loadLibrary."+lib)</code> permission. * <p> * If you override this method, then you should make a call to * <code>super.checkLink</code> * at the point the overridden method would normally throw an * exception. * * @param lib the name of the library. * @exception SecurityException if the calling thread does not have * permission to dynamically link the library. * @exception NullPointerException if the <code>lib</code> argument is * <code>null</code>. * @see java.lang.Runtime#load(java.lang.String) * @see java.lang.Runtime#loadLibrary(java.lang.String) * @see #checkPermission(java.security.Permission) checkPermission */ public void checkLink(String lib) { if (lib == null) { throw new NullPointerException("library can't be null"); } checkPermission(new RuntimePermission("loadLibrary."+lib)); }
Example #23
Source File: SecurityManager.java From Java8CN with Apache License 2.0 | 3 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to write to the specified file * descriptor. * <p> * This method calls <code>checkPermission</code> with the * <code>RuntimePermission("writeFileDescriptor")</code> * permission. * <p> * If you override this method, then you should make a call to * <code>super.checkWrite</code> * at the point the overridden method would normally throw an * exception. * * @param fd the system-dependent file descriptor. * @exception SecurityException if the calling thread does not have * permission to access the specified file descriptor. * @exception NullPointerException if the file descriptor argument is * <code>null</code>. * @see java.io.FileDescriptor * @see #checkPermission(java.security.Permission) checkPermission */ public void checkWrite(FileDescriptor fd) { if (fd == null) { throw new NullPointerException("file descriptor can't be null"); } checkPermission(new RuntimePermission("writeFileDescriptor")); }
Example #24
Source File: SecurityManager.java From Java8CN with Apache License 2.0 | 3 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to read from the specified file * descriptor. * <p> * This method calls <code>checkPermission</code> with the * <code>RuntimePermission("readFileDescriptor")</code> * permission. * <p> * If you override this method, then you should make a call to * <code>super.checkRead</code> * at the point the overridden method would normally throw an * exception. * * @param fd the system-dependent file descriptor. * @exception SecurityException if the calling thread does not have * permission to access the specified file descriptor. * @exception NullPointerException if the file descriptor argument is * <code>null</code>. * @see java.io.FileDescriptor * @see #checkPermission(java.security.Permission) checkPermission */ public void checkRead(FileDescriptor fd) { if (fd == null) { throw new NullPointerException("file descriptor can't be null"); } checkPermission(new RuntimePermission("readFileDescriptor")); }
Example #25
Source File: SecurityManager.java From jdk1.8-source-analysis with Apache License 2.0 | 3 votes |
/** * Constructs a new <code>SecurityManager</code>. * * <p> If there is a security manager already installed, this method first * calls the security manager's <code>checkPermission</code> method * with the <code>RuntimePermission("createSecurityManager")</code> * permission to ensure the calling thread has permission to create a new * security manager. * This may result in throwing a <code>SecurityException</code>. * * @exception java.lang.SecurityException if a security manager already * exists and its <code>checkPermission</code> method * doesn't allow creation of a new security manager. * @see java.lang.System#getSecurityManager() * @see #checkPermission(java.security.Permission) checkPermission * @see java.lang.RuntimePermission */ public SecurityManager() { synchronized(SecurityManager.class) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { // ask the currently installed security manager if we // can create a new one. sm.checkPermission(new RuntimePermission ("createSecurityManager")); } initialized = true; } }
Example #26
Source File: SecurityManager.java From hottub with GNU General Public License v2.0 | 3 votes |
/** * Constructs a new <code>SecurityManager</code>. * * <p> If there is a security manager already installed, this method first * calls the security manager's <code>checkPermission</code> method * with the <code>RuntimePermission("createSecurityManager")</code> * permission to ensure the calling thread has permission to create a new * security manager. * This may result in throwing a <code>SecurityException</code>. * * @exception java.lang.SecurityException if a security manager already * exists and its <code>checkPermission</code> method * doesn't allow creation of a new security manager. * @see java.lang.System#getSecurityManager() * @see #checkPermission(java.security.Permission) checkPermission * @see java.lang.RuntimePermission */ public SecurityManager() { synchronized(SecurityManager.class) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { // ask the currently installed security manager if we // can create a new one. sm.checkPermission(new RuntimePermission ("createSecurityManager")); } initialized = true; } }
Example #27
Source File: SecurityManager.java From Java8CN with Apache License 2.0 | 3 votes |
/** * Constructs a new <code>SecurityManager</code>. * * <p> If there is a security manager already installed, this method first * calls the security manager's <code>checkPermission</code> method * with the <code>RuntimePermission("createSecurityManager")</code> * permission to ensure the calling thread has permission to create a new * security manager. * This may result in throwing a <code>SecurityException</code>. * * @exception java.lang.SecurityException if a security manager already * exists and its <code>checkPermission</code> method * doesn't allow creation of a new security manager. * @see java.lang.System#getSecurityManager() * @see #checkPermission(java.security.Permission) checkPermission * @see java.lang.RuntimePermission */ public SecurityManager() { synchronized(SecurityManager.class) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { // ask the currently installed security manager if we // can create a new one. sm.checkPermission(new RuntimePermission ("createSecurityManager")); } initialized = true; } }
Example #28
Source File: SecurityManager.java From openjdk-jdk8u with GNU General Public License v2.0 | 3 votes |
/** * Constructs a new <code>SecurityManager</code>. * * <p> If there is a security manager already installed, this method first * calls the security manager's <code>checkPermission</code> method * with the <code>RuntimePermission("createSecurityManager")</code> * permission to ensure the calling thread has permission to create a new * security manager. * This may result in throwing a <code>SecurityException</code>. * * @exception java.lang.SecurityException if a security manager already * exists and its <code>checkPermission</code> method * doesn't allow creation of a new security manager. * @see java.lang.System#getSecurityManager() * @see #checkPermission(java.security.Permission) checkPermission * @see java.lang.RuntimePermission */ public SecurityManager() { synchronized(SecurityManager.class) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { // ask the currently installed security manager if we // can create a new one. sm.checkPermission(new RuntimePermission ("createSecurityManager")); } initialized = true; } }
Example #29
Source File: SecurityManager.java From jdk8u_jdk with GNU General Public License v2.0 | 3 votes |
/** * Constructs a new <code>SecurityManager</code>. * * <p> If there is a security manager already installed, this method first * calls the security manager's <code>checkPermission</code> method * with the <code>RuntimePermission("createSecurityManager")</code> * permission to ensure the calling thread has permission to create a new * security manager. * This may result in throwing a <code>SecurityException</code>. * * @exception java.lang.SecurityException if a security manager already * exists and its <code>checkPermission</code> method * doesn't allow creation of a new security manager. * @see java.lang.System#getSecurityManager() * @see #checkPermission(java.security.Permission) checkPermission * @see java.lang.RuntimePermission */ public SecurityManager() { synchronized(SecurityManager.class) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { // ask the currently installed security manager if we // can create a new one. sm.checkPermission(new RuntimePermission ("createSecurityManager")); } initialized = true; } }
Example #30
Source File: SecurityManager.java From hottub with GNU General Public License v2.0 | 3 votes |
/** * Throws a <code>SecurityException</code> if the * calling thread is not allowed to dynamic link the library code * specified by the string argument file. The argument is either a * simple library name or a complete filename. * <p> * This method is invoked for the current security manager by * methods <code>load</code> and <code>loadLibrary</code> of class * <code>Runtime</code>. * <p> * This method calls <code>checkPermission</code> with the * <code>RuntimePermission("loadLibrary."+lib)</code> permission. * <p> * If you override this method, then you should make a call to * <code>super.checkLink</code> * at the point the overridden method would normally throw an * exception. * * @param lib the name of the library. * @exception SecurityException if the calling thread does not have * permission to dynamically link the library. * @exception NullPointerException if the <code>lib</code> argument is * <code>null</code>. * @see java.lang.Runtime#load(java.lang.String) * @see java.lang.Runtime#loadLibrary(java.lang.String) * @see #checkPermission(java.security.Permission) checkPermission */ public void checkLink(String lib) { if (lib == null) { throw new NullPointerException("library can't be null"); } checkPermission(new RuntimePermission("loadLibrary."+lib)); }