Package java.security

Examples of java.security.CodeSource


    {
        return (String)AccessController.doPrivileged( new PrivilegedAction()
        {
          public Object run()
          {
              CodeSource cs = null;
              try {
                  cs = cls.getProtectionDomain().getCodeSource();
              }
              catch (SecurityException se) {
                  return se.getMessage();
              }
 
              if ( cs == null )
                  return null;       
     
              URL result = cs.getLocation ();
     
              return result.toString();
          }
        });
    }
View Full Code Here


     *
     * @return iterable of all concrete classes in the same package as the seedclass, and also all classes in subpackages.
     */
    public static Iterable<Class<?>> getClasses( final Class<?> seedClass )
    {
        CodeSource codeSource = seedClass.getProtectionDomain().getCodeSource();
        if( codeSource == null )
        {
            return Iterables.empty();
        }

        URL location = codeSource.getLocation();

        if( !location.getProtocol().equals( "file" ) )
        {
            throw new IllegalArgumentException( "Can only enumerate classes from file system locations. URL is:" + location );
        }
View Full Code Here

  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;
    String result = url.getFile();
    if (result.endsWith(".jar")) { //$NON-NLS-1$
      result = result.substring(0, result.lastIndexOf('/'));
View Full Code Here

  }

  public static void initializeProperties() {
    // initialize some framework properties that must always be set
    if (getProperty(PROP_FRAMEWORK) == null || getProperty(PROP_INSTALL_AREA) == null) {
      CodeSource cs = FrameworkProperties.class.getProtectionDomain().getCodeSource();
      if (cs == null)
        throw new IllegalArgumentException(NLS.bind(EclipseAdaptorMsg.ECLIPSE_STARTUP_PROPS_NOT_SET, PROP_FRAMEWORK + ", " + PROP_INSTALL_AREA)); //$NON-NLS-1$
      URL url = cs.getLocation();
      // allow props to be preset
      if (getProperty(PROP_FRAMEWORK) == null)
        setProperty(PROP_FRAMEWORK, url.toExternalForm());
      if (getProperty(PROP_INSTALL_AREA) == null) {
        String filePart = url.getFile();
View Full Code Here

    {
         return (String)AccessController.doPrivileged( new PrivilegedAction()
        {
            public Object run()
            {
                CodeSource cs = null;
                try {
                    cs = cls.getProtectionDomain().getCodeSource ();
                }
                catch (SecurityException se) {
                    return Main.getTextMessage(
                        "SIF01.V", cls.getName(), se.getMessage());
                }
                if ( cs == null )
                    return null;       
    
                URL result = cs.getLocation ();
    
                return formatURL(result);
            }
        });
    }
View Full Code Here

           
            // Create the package if necessary
            URL codeSourceURL = null;
            if (protectionDomain != null)
            {
               CodeSource codeSource = protectionDomain.getCodeSource();
               if (codeSource != null)
                  codeSourceURL = codeSource.getLocation();
            }
            definePackage(name, codeSourceURL);
           
            // Finally we can define the class
            Class<?> result;
View Full Code Here

            results.append(urls[u]);
         }
         if( parent != null )
            parent = parent.getParent();
      }
      CodeSource clazzCS = clazz.getProtectionDomain().getCodeSource();
      if( clazzCS != null )
      {
         results.append("\n++++CodeSource: ");
         results.append(clazzCS);
      }
      else
         results.append("\n++++Null CodeSource");

      results.append("\nImplemented Interfaces:");
      Class[] ifaces = clazz.getInterfaces();
      for(int i = 0; i < ifaces.length; i ++)
      {
         Class iface = ifaces[i];
         results.append("\n++");
         results.append(iface);
         results.append("(");
         results.append(Integer.toHexString(iface.hashCode()));
         results.append(")");
         ClassLoader loader = ifaces[i].getClassLoader();
         results.append("\n++++ClassLoader: ");
         results.append(loader);
         ProtectionDomain pd = ifaces[i].getProtectionDomain();
         CodeSource cs = pd.getCodeSource();
         if( cs != null )
         {
            results.append("\n++++CodeSource: ");
            results.append(cs);
         }
View Full Code Here

            new PrivilegedAction() {
                public Object run() {
                    return cx.getApplicationClassLoader();
                }
            });
        final CodeSource codeSource = (CodeSource)securityDomain;
        Map classLoaderMap;
        synchronized(callers)
        {
            classLoaderMap = (Map)callers.get(codeSource);
            if(classLoaderMap == null)
View Full Code Here

            results.append(urls[u]);
         }
         if( parent != null )
            parent = parent.getParent();
      }
      CodeSource clazzCS = clazz.getProtectionDomain().getCodeSource();
      if( clazzCS != null )
      {
         results.append("\n++++CodeSource: ");
         results.append(clazzCS);
      }
      else
         results.append("\n++++Null CodeSource");

      results.append("\nImplemented Interfaces:");
      Class[] ifaces = clazz.getInterfaces();
      for(int i = 0; i < ifaces.length; i ++)
      {
         Class iface = ifaces[i];
         results.append("\n++");
         results.append(iface);
         results.append("(");
         results.append(Integer.toHexString(iface.hashCode()));
         results.append(")");
         ClassLoader loader = ifaces[i].getClassLoader();
         results.append("\n++++ClassLoader: ");
         results.append(loader);
         ProtectionDomain pd = ifaces[i].getProtectionDomain();
         CodeSource cs = pd.getCodeSource();
         if( cs != null )
         {
            results.append("\n++++CodeSource: ");
            results.append(cs);
         }
View Full Code Here

         {
            allPermissions.add(permission);
         }
      }
      ProtectionDomain[] protectionDomains =
         new ProtectionDomain[]{new ProtectionDomain(new CodeSource(getCodeSource(),
            (java.security.cert.Certificate[])null), allPermissions)};
      return AccessController.doPrivileged(action, new AccessControlContext(protectionDomains));
   }
View Full Code Here

TOP

Related Classes of java.security.CodeSource

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.