Package java.security

Examples of java.security.CodeSource


      }
      debug.println();
  }

  try {
      CodeSource codesource = getCodeSource(ge, keyStore);
      // skip if signedBy alias was unknown...
      if (codesource == null) return;

      PolicyEntry entry = new PolicyEntry(codesource);
      Enumeration enum_ = ge.permissionElements();
View Full Code Here


    {
  if (!initialized) {
      init();
  }

  final CodeSource codesource[] = {null};

  codesource[0] = canonicalizeCodebase(cs, true);

  if (debug != null) {
      debug.println("evaluate("+codesource[0]+")\n");
View Full Code Here

  return userCerts;
    }

    private CodeSource canonicalizeCodebase(CodeSource cs,
              boolean extractSignerCerts) {
  CodeSource canonCs = cs;
  if (cs.getLocation() != null &&
      cs.getLocation().getProtocol().equalsIgnoreCase("file")) {
      try {
    String path = cs.getLocation().getFile().replace
              ('/',
              File.separatorChar);
    URL csUrl = null;
    if (path.endsWith("*")) {
        // remove trailing '*' because it causes canonicalization
        // to fail on win32
        path = path.substring(0, path.length()-1);
        boolean appendFileSep = false;
        if (path.endsWith(File.separator))
      appendFileSep = true;
        if (path.equals("")) {
      path = System.getProperty("user.dir");
        }
        File f = new File(path);
        path = f.getCanonicalPath();
        StringBuffer sb = new StringBuffer(path);
        // reappend '*' to canonicalized filename (note that
        // canonicalization may have removed trailing file
        // separator, so we have to check for that, too)
        if (!path.endsWith(File.separator) &&
      (appendFileSep || f.isDirectory()))
      sb.append(File.separatorChar);
        sb.append('*');
        path = sb.toString();
    } else {
        path = new File(path).getCanonicalPath();
    }
    csUrl = new File(path).toURL();

    if (cs instanceof SubjectCodeSource) {
        SubjectCodeSource scs = (SubjectCodeSource)cs;
        if (extractSignerCerts) {
      canonCs = new SubjectCodeSource
            (scs.getSubject(),
            scs.getPrincipals(),
            csUrl,
            getSignerCertificates(scs));
        } else {
      canonCs = new SubjectCodeSource
            (scs.getSubject(),
            scs.getPrincipals(),
            csUrl,
            scs.getCertificates());
        }
    } else {
        if (extractSignerCerts) {
      canonCs = new CodeSource(csUrl,
            getSignerCertificates(cs));
        } else {
      canonCs = new CodeSource(csUrl,
            cs.getCertificates());
        }
    }
      } catch (IOException ioe) {
    // leave codesource as it is, unless we have to extract its
    // signer certificates
    if (extractSignerCerts) {
        if (!(cs instanceof SubjectCodeSource)) {
      canonCs = new CodeSource(cs.getLocation(),
            getSignerCertificates(cs));
        } else {
      SubjectCodeSource scs = (SubjectCodeSource)cs;
      canonCs = new SubjectCodeSource(scs.getSubject(),
            scs.getPrincipals(),
            scs.getLocation(),
            getSignerCertificates(scs));
        }
    }
      }
  } else {
      if (extractSignerCerts) {
    if (!(cs instanceof SubjectCodeSource)) {
        canonCs = new CodeSource(cs.getLocation(),
          getSignerCertificates(cs));
    } else {
        SubjectCodeSource scs = (SubjectCodeSource)cs;
        canonCs = new SubjectCodeSource(scs.getSubject(),
          scs.getPrincipals(),
View Full Code Here

       
        Class cls = ((InternalRuleBase)rb).getRootClassLoader().loadClass( "org.drools.rule.PackageCompilationDataTest$TestEvalExpression" );
       
        System.out.println( cls );
       
        final CodeSource codeSource = invoker.getEvalExpression().getClass().getProtectionDomain().getCodeSource();
        assertNotNull(codeSource.getLocation());
    }
View Full Code Here

*/
public class JACCPermissions {

  public static void checkPermission(Class clazz, String contextID, EJBMethodPermission methodPerm)
      throws SecurityException {
    CodeSource ejbCS = clazz.getProtectionDomain().getCodeSource();

    try {
      setContextID( contextID );

      Policy policy = Policy.getPolicy();
View Full Code Here

*/
public class JACCPermissions {

  public static void checkPermission(Class clazz, String contextID, EJBMethodPermission methodPerm)
      throws SecurityException {
    CodeSource ejbCS = clazz.getProtectionDomain().getCodeSource();

    try {
      setContextID( contextID );

      Policy policy = Policy.getPolicy();
View Full Code Here

         {
            break;
         }
         parent = parent.getParent();
      }
      CodeSource clazzCS = clazz.getProtectionDomain().getCodeSource();
      if (clazzCS != null)
      {
         results.append("\n++++CodeSource: " + 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++" + 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

            .getDefaultSecurityDomain()), SecurityActions.loadClass(config.getSecurityContextClassName()), getSecurityManagement());
      context.addValve(scevalve);

      // Add a valve to estalish the JACC context before authorization valves
      Certificate[] certs = null;
      CodeSource cs = new CodeSource(warUrl, certs);
      JaccContextValve jaccValve = new JaccContextValve(metaData, cs);
      context.addValve(jaccValve);

      // Set listener
      context.setConfigClass("org.jboss.web.tomcat.service.deployers.JBossContextConfig");
View Full Code Here

            }

        }

        // Create the code source object
        CodeSource codeSource =
            new CodeSource(entry.codeBase, entry.certificates);

        if (securityManager != null) {

            // Checking sealing
            if (pkg != null) {
View Full Code Here

            }

            try {
                clazz = defineClass(name, entry.binaryContent, 0,
                        entry.binaryContent.length,
                        new CodeSource(entry.codeBase, entry.certificates));
            } catch (UnsupportedClassVersionError ucve) {
                throw new UnsupportedClassVersionError(
                        ucve.getLocalizedMessage() + " " +
                        sm.getString("webappClassLoader.wrongVersion",
                                name));
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.