Package java.security

Examples of java.security.PrivilegedAction


            });
    }
   
    boolean getFileExists(final File f) {
    return ((Boolean)
            AccessController.doPrivileged(new PrivilegedAction() {
                public Object run() {
                    return new Boolean(f.exists());
                }
            })).booleanValue();
    }
View Full Code Here


            })).booleanValue();
    }
   
    long getLastModified(final File f) {
    return ((Long)
            AccessController.doPrivileged(new PrivilegedAction() {
                public Object run() {
                    return new Long(f.lastModified());
                }
            })).longValue();
    }
View Full Code Here

    public URL findResource(final String name) {
  /*
   * The same restriction to finding classes applies to resources
   */
  URL url =
      (URL) AccessController.doPrivileged(new PrivilegedAction() {
                public Object run() {
                    return ucp.findResource(name, true);
                }
            }, acc);

View Full Code Here

    if (url != null) {
        return true;
    }
    do {
        URL u = (URL)
      AccessController.doPrivileged(new PrivilegedAction() {
          public Object run() {
        if (!e.hasMoreElements())
                                     return null;
                              return e.nextElement();
          }
View Full Code Here

  if (p != null) {
      final SecurityManager sm = System.getSecurityManager();
      if (sm != null) {
    final Permission fp = p;
    AccessController.doPrivileged(new PrivilegedAction() {
        public Object run() throws SecurityException {
      sm.checkPermission(fp);
      return null;
        }
    }, acc);
View Full Code Here

               final ClassLoader parent) {
  // Save the caller's context
  AccessControlContext acc = AccessController.getContext();
  // Need a privileged block to create the class loader
  URLClassLoader ucl =
      (URLClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
    public Object run() {
        return new FactoryURLClassLoader(urls, parent);
    }
      });
  // Now set the context on the loader using the one we saved,
View Full Code Here

    public static URLClassLoader newInstance(final URL[] urls) {
  // Save the caller's context
  AccessControlContext acc = AccessController.getContext();
  // Need a privileged block to create the class loader
  URLClassLoader ucl = (URLClassLoader)
      AccessController.doPrivileged(new PrivilegedAction() {
    public Object run() {
        return new FactoryURLClassLoader(urls);
    }
      });
View Full Code Here

      // trying to initialize the policy (which usually involves
      // accessing some security and/or system properties, which in turn
      // calls the installed security manager's checkPermission method
      // which will loop infinitely if there is a non-system class
      // (in this case: the new security manager class) on the stack).
      AccessController.doPrivileged(new PrivilegedAction() {
    public Object run() {
        s.getClass().getProtectionDomain().implies
      (SecurityConstants.ALL_PERMISSION);
        return null;
    }
View Full Code Here

    return result;
      }
  }

  // We have to raise privilege for getDeclaredMethods
  result = (Method[]) AccessController.doPrivileged(new PrivilegedAction() {
    public Object run() {
        return fclz.getDeclaredMethods();
    }
      });
View Full Code Here

        iterCache[type] = new SoftReference(cache);
        return result;
    }

    private static ResourceBundle getBundle(final String baseName, final Locale locale) {
         return (ResourceBundle) AccessController.doPrivileged(new PrivilegedAction() {
            public Object run() {
                return ResourceBundle.getBundle(baseName, locale);
            }
        });
    }
View Full Code Here

TOP

Related Classes of java.security.PrivilegedAction

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.