Package java.security

Examples of java.security.ProtectionDomain


    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


            // Load the bytecode
            byte[] byteCode = ClassLoaderUtils.loadByteCode(name, is);

            // Let the policy do things before we define the class
            BaseClassLoaderPolicy basePolicy = policy;
            ProtectionDomain protectionDomain = basePolicy.getProtectionDomain(name, resourcePath);
            try
            {
               byte[] transformed = policy.transform(name, byteCode, protectionDomain);
               if (transformed != null)
                  byteCode = transformed;
            }
            catch (Throwable t)
            {
               throw new RuntimeException("Unexpected error transforming class " + name, t);
            }

            // Create the package if necessary
            URL codeSourceURL = null;
            if (protectionDomain != null)
            {
               CodeSource codeSource = protectionDomain.getCodeSource();
               if (codeSource != null)
                  codeSourceURL = codeSource.getLocation();
            }
            definePackage(name, codeSourceURL);
View Full Code Here

    *
    * @return the deployer's location
    */
   protected String getDeployerLocation()
   {
      ProtectionDomain pd = getClass().getProtectionDomain();
      CodeSource cs = pd.getCodeSource();
      URL location = cs.getLocation();
      return location.toExternalForm();
   }
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

  private void doPermissionCheckInContext(PermissionCheckEntityInformation entityInformation, PermissibleAction action) {
    final Policy policy = Policy.getPolicy();
    final Principal[] principals = getCallerPrincipals();

    final CodeSource codeSource = entityInformation.getEntity().getClass().getProtectionDomain().getCodeSource();
    final ProtectionDomain pd = new ProtectionDomain( codeSource, null, null, principals );

    // the action is known as 'method name' in JACC
    final EJBMethodPermission jaccPermission = new EJBMethodPermission(
        entityInformation.getEntityName(),
        action.getImpliedActions()[0],
View Full Code Here

        Set principalsSet = caller.getPrincipals();
        principals = new Principal[ principalsSet.size() ];
        principalsSet.toArray( principals );
      }

      ProtectionDomain pd = new ProtectionDomain( ejbCS, null, null, principals );
      if ( policy.implies( pd, methodPerm ) == false ) {
        String msg = "Denied: " + methodPerm + ", caller=" + caller;
        SecurityException e = new SecurityException( msg );
        throw e;
      }
View Full Code Here

        Set principalsSet = caller.getPrincipals();
        principals = new Principal[ principalsSet.size() ];
        principalsSet.toArray( principals );
      }

      ProtectionDomain pd = new ProtectionDomain( ejbCS, null, null, principals );
      if ( policy.implies( pd, methodPerm ) == false ) {
        String msg = "Denied: " + methodPerm + ", caller=" + caller;
        SecurityException e = new SecurityException( msg );
        throw e;
      }
View Full Code Here

      {
         Class iface = ifaces[i];
         results.append("\n++" + iface + "(" + Integer.toHexString(iface.hashCode()) + ")");
         ClassLoader loader = ifaces[i].getClassLoader();
         results.append("\n++++ClassLoader: " + loader);
         ProtectionDomain pd = ifaces[i].getProtectionDomain();
         CodeSource cs = pd.getCodeSource();
         if (cs != null)
         {
            results.append("\n++++CodeSource: " + cs);
         }
         else
View Full Code Here

    public void testGetPermissions() {
        SecurityPermission sp = new SecurityPermission("abc");
        SecurityPermission sp2 = new SecurityPermission("fbdf");
        PermissionCollection spc = sp.newPermissionCollection();
        spc.add(sp2);
        ProtectionDomain pd = new ProtectionDomain(null, null);
        ProtectionDomain pd2 = new ProtectionDomain(null, spc);
        TestProvider policy = new TestProvider();
        policy.pc = sp.newPermissionCollection();
                
        //case1: empty policy, no static permissions in PD
        PermissionCollection pc4pd = policy.getPermissions(pd);
View Full Code Here

        }
        return bundleJars;
    }

    protected String getJarUrl(Class clazz) {
        ProtectionDomain protectionDomain = clazz.getProtectionDomain();
        CodeSource codeSource = protectionDomain.getCodeSource();
        URL loc = codeSource.getLocation();
        return loc.toString();
    }
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.