Package java.security

Examples of java.security.ProtectionDomain


  /**
   * get the path name of the Frege Standard Library
   */
  public String getFregeLib() {
    if (fregeLib == null) {
      final ProtectionDomain pd = this.getClass().getProtectionDomain();
      final CodeSource cs = pd.getCodeSource();
      URL xurl = cs.getLocation();
      fregeLib = xurl.getPath() + "/lib/fregec.jar";
      System.err.println(kPluginID + ": " + xurl);
    }
    return fregeLib;
View Full Code Here


          intp.println(ConsoleMsg.CONSOLE_NO_EXPORTED_PACKAGES_NO_PACKAGE_ADMIN_MESSAGE);
        }

        SecurityManager sm = System.getSecurityManager();
        if (sm != null) {
          ProtectionDomain domain = bundle.getProtectionDomain();

          intp.println(domain);
        }
      }
      nextArg = intp.nextArgument();
View Full Code Here

    fwkFile = new File(fwkFile.getParent());
    return fwkFile.getAbsolutePath();
  }

  private static String getSysPathFromCodeSource() {
    ProtectionDomain pd = EclipseStarter.class.getProtectionDomain();
    if (pd == null)
      return null;
    CodeSource cs = pd.getCodeSource();
    if (cs == null)
      return null;
    URL url = cs.getLocation();
    if (url == null)
      return null;
View Full Code Here

         VirtualFile root = findRoot(path);
         URL codeSourceURL = root.toURL();
         Certificate[] certs = null; // TODO JBMICROCONT-182 determine certificates
         CodeSource cs = new CodeSource(codeSourceURL, certs);
         PermissionCollection permissions = Policy.getPolicy().getPermissions(cs);
         return new ProtectionDomain(cs, permissions);
      }
      catch (Exception e)
      {
         throw new Error("Error determining protection domain for " + clazz, e);
      }
View Full Code Here

//         public URL run()
//         {
//            return getParent().getResource(classFileName);
//         }
//      });
      ProtectionDomain protectionDomain = null;
      InputStream in = null;
      if (url != null)
      {
         try
         {
            in = AccessController.doPrivileged(new PrivilegedExceptionAction<InputStream>()
            {
               public InputStream run() throws Exception
               {
                  return url.openStream();
               }
            });
         }
         catch (PrivilegedActionException e)
         {
            throw new ClassNotFoundException(name, e);
         }
         String urlstring = url.toExternalForm();
         URL urlCS = url;
         if (urlstring.startsWith("jar:"))
         {
            int i = urlstring.indexOf('!');
            String cs = urlstring.substring(4, i);
            urlCS = new URL(cs);
         }
         else
         {
            int i = urlstring.indexOf(classFileName);
            if (i != -1)
            {
               String cs = urlstring.substring(0, i);
               urlCS = new URL(cs);
            }
         }
         CodeSource codeSource = new CodeSource(urlCS, (Certificate[]) null);
         protectionDomain = new ProtectionDomain(codeSource, null, this, null);
      }
      else
      {
         /* Try the system tmpdir/aopdynclasses, the default location
         the AOPClassPool writes dynamic class files to.
View Full Code Here

      }
   }

   public void testCanonicalPath() throws Exception
   {
      ProtectionDomain pd = getClass().getProtectionDomain();
      URL url = pd.getCodeSource().getLocation();
      String urlString = url.toExternalForm();
      if (urlString.endsWith("/") == false)
         urlString += "/";
      String testDir = urlString + "vfs/../vfs/test/";
      URL testURL = Strings.toURL(testDir);
View Full Code Here

      if( this.loadedClass != null && order == loadOrder )
      {
         StringBuffer tmp = new StringBuffer("Duplicate class found: "+classname);
         tmp.append('\n');
         ProtectionDomain pd = this.loadedClass.getProtectionDomain();
         CodeSource cs = pd != null ? pd.getCodeSource() : null;
         tmp.append("Current CS: "+cs);
         tmp.append('\n');
         pd = theClass.getProtectionDomain();
         cs = pd != null ? pd.getCodeSource() : null;
         tmp.append("Duplicate CS: "+cs);
         log.warn(tmp.toString());
      }

      // Accept the lowest order source of the class
      if( theClass != null )
      {
         if( order < loadOrder )
         {
            this.loadedClass = theClass;
            this.loadOrder = order;
         }
         else
         {
            ProtectionDomain pd = this.loadedClass.getProtectionDomain();
            CodeSource cs = pd != null ? pd.getCodeSource() : null;
            ProtectionDomain pd2 = theClass.getProtectionDomain();
            CodeSource cs2 = pd != null ? pd2.getCodeSource() : null;
            log.debug("Ignoring source of: "+classname+" from CodeSource: "+cs2
               +", due to order("+order+">="+loadOrder+"), "
               +"accepted CodeSource: "+cs);
         }
      }
View Full Code Here

        }

        // Store ProtectionDomains for loaded classes into array.
        // Avoid to duplicates.
        ArrayList l = new ArrayList();
        ProtectionDomain pdNext = null;
        ProtectionDomain pdPrev = null;

        for (int i = 0; i < classes.length; i++) {
            if (classes[i] != null) {
                pdNext = classes[i].getProtectionDomain();
View Full Code Here

        /*
         * Iterate over ProtectionDomains and and check implies().
         */
        for (int i = 0; i < protectionDomains.length; i++) {
            ProtectionDomain pd = protectionDomains[i];

            /*
             * Call implies() on PolicyFileProvider passing
             * permissions that granted in the policy file. Verify that
             * implies() returns false if ProtectionDomain is equal to null,
             * and verify that implies() returns true for non-null
             * ProtectionDomains.
             */
            checkImplies(pd, pma[IGRANTED], true, true);

            /*
             * Call implies() on PolicyFileProvider passing
             * not granted permissions. Verify that implies()
             * returns false for null and non-null
             * ProtectionDomains.
             */
            checkImplies(pd, pma[INOTGRANTED], false, false);

            /*
             * For non-null ProtectionDomains that have
             * PreferredClassLoader as ClassLoader
             * call implies() on PolicyFileProvider passing
             * permissions that granted to
             * qa1-policy-provider.jar's codebase.
             * Verify that implies() returns true.
             */
            if (pd == null) {
                continue;
            }

            if (pd.getClassLoader() instanceof PreferredClassLoader) {
                checkImplies(pd, pma[ICODEBASEGRANTED], true, false);
            }

            if (pma[ICODEBASENOTGRANTED] == null) {
                continue;
            }

            /*
             * For non-null ProtectionDomains that have
             * PreferredClassLoader as ClassLoader
             * call implies() on PolicyFileProvider passing
             * permissions that are not granted to
             * qa1-policy-provider.jar's codebase.
             * Verify that implies() returns false.
             */
            if (pd.getClassLoader() instanceof PreferredClassLoader) {
                checkImplies(pd, pma[ICODEBASENOTGRANTED], false, false);
            }
        }
    }
View Full Code Here

        /*
         * Iterate over ProtectionDomains and and check implies().
         */
        for (int i = 0; i < protectionDomains.length; i++) {
            ProtectionDomain pd = protectionDomains[i];

            if (pd == null) {
                continue;
            }

            /*
             * Get CodeSource for ProtectionDomain.
             */
            CodeSource cs = protectionDomains[i].getCodeSource();

            /*
             * Call getPermissions() on PolicyFileProvider passing
             * ProtectionDomain.
             */
            PermissionCollection pcPD = policy.getPermissions(pd);

            /*
             * Call getPermissions() on PolicyFileProvider passing
             * CodeSource.
             */
            PermissionCollection pcCS = policy.getPermissions(cs);

            /*
             * Call implies() on returned PermissionCollections passing
             * permissions that granted in the policy file. Verify that
             * implies() returns true.
             */
            checkImplies(pcPD, pma[IGRANTED], true);
            checkImplies(pcCS, pma[IGRANTED], true);

            /*
             * Call implies() on returned PermissionCollections passing
             * not granted permissions. Verify that implies()
             * returns false.
             */
            checkImplies(pcPD, pma[INOTGRANTED], false);
            checkImplies(pcCS, pma[INOTGRANTED], false);

            /*
             * For ProtectionDomains that have
             * PreferredClassLoader as ClassLoader
             * call implies() on returned PermissionCollections passing
             * permissions that granted to
             * qa1-policy-provider.jar's codebase.
             * Verify that implies() returns true.
             */
            if (pd.getClassLoader() instanceof PreferredClassLoader) {
                checkImplies(pcPD, pma[ICODEBASEGRANTED], true);
                checkImplies(pcCS, pma[ICODEBASEGRANTED], true);
            }

            if (pma[ICODEBASENOTGRANTED] == null) {
                continue;
            }

            /*
             * For ProtectionDomains that have
             * PreferredClassLoader as ClassLoader
             * call implies() on returned PermissionCollections passing
             * permissions that are not granted to
             * qa1-policy-provider.jar's codebase.
             * Verify that implies() returns false.
             */
            if (pd.getClassLoader() instanceof PreferredClassLoader) {
                checkImplies(pcPD, pma[ICODEBASENOTGRANTED], false);
                checkImplies(pcCS, pma[ICODEBASENOTGRANTED], false);
            }
        }
    }
View Full Code Here

TOP

Related Classes of java.security.ProtectionDomain

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.