Package java.security

Examples of java.security.ProtectionDomain


        {
            if (domain == null) {
                return null;
            }

            return new ProtectionDomain(domain.getCodeSource(),
                                        domain.getPermissions(),
                                        loader,
                                        domain.getPrincipals());
        }
View Full Code Here


    public static URL getClassLocation(final Class clazz) {
        URL result = null;
        final String clsAsResource = clazz.getName().replace('.', '/')
                + ".class";
   
        final ProtectionDomain pd = clazz.getProtectionDomain();
        if (pd != null) {
            final CodeSource cs = pd.getCodeSource();
            // 'cs' can be null depending on the classloader
            if (cs != null) {
                result = cs.getLocation();
            }
   
View Full Code Here

    private static void setThreadClassLoader() {
        Thread.currentThread().setContextClassLoader(WebAppClassLoader.class.getClassLoader());
    }

    private static WebAppContext buildContext() throws IOException {
        ProtectionDomain protectionDomain = Startup.class.getProtectionDomain();
        URL location = protectionDomain.getCodeSource().getLocation();

        WebAppContext context = new WebAppContext();
        WebAppClassLoader webAppClassLoader = new WebAppClassLoader(Startup.class.getClassLoader(),context);
        context.setClassLoader(webAppClassLoader);
        context.setContextPath(URIUtil.SLASH);
View Full Code Here

   private void checkTrustRegistration(final Class cls)
   {
      SecurityManager sm = System.getSecurityManager();
      if (sm != null)
      {
         ProtectionDomain domain = (ProtectionDomain)AccessController.doPrivileged(new PrivilegedAction()
         {
            public Object run()
            {
               return cls.getProtectionDomain();
            }
         });

         MBeanTrustPermission permission = new MBeanTrustPermission("register");
         if (!domain.implies(permission))
         {
            throw new AccessControlException("Access denied " + permission + ": MBean class " + cls.getName() + " is not trusted for registration");
         }
      }
   }
View Full Code Here

        {
            if (m_state == Bundle.UNINSTALLED)
            {
                return null;
            }
            final ProtectionDomain pd = this.getProtectionDomain();
            if (pd == null)
            {
                return null;
            }
            return (A) new AccessControlContext(new ProtectionDomain[] {pd});
View Full Code Here

        return revision;
    }

    synchronized ProtectionDomain getProtectionDomain()
    {
        ProtectionDomain pd = null;

        for (int i = m_revisions.size() - 1; (i >= 0) && (pd == null); i--)
        {
            pd = ((BundleRevisionImpl) m_revisions.get(i)).getProtectionDomain();
        }
View Full Code Here

            {
                certList.add(new FakeCert(certs[j]));
            }
        }
        final Bundle fake = new FakeBundle(certificates);
        ProtectionDomain domain = new ProtectionDomain(null, null)
        {
            public boolean implies(Permission permission)
            {
                List posts = new ArrayList();
                Boolean result = m_pai.hasPermission("", fake, permission,
View Full Code Here

    private static void setThreadClassLoader() {
        Thread.currentThread().setContextClassLoader(WebAppClassLoader.class.getClassLoader());
    }

    private static WebAppContext buildContext() throws IOException {
        ProtectionDomain protectionDomain = Startup.class.getProtectionDomain();
        URL location = protectionDomain.getCodeSource().getLocation();

        WebAppContext context = new WebAppContext();
        WebAppClassLoader webAppClassLoader = new WebAppClassLoader(Startup.class.getClassLoader(),context);
        context.setClassLoader(webAppClassLoader);
        context.setContextPath(URIUtil.SLASH);
View Full Code Here

        private void initializeDerivativeProperties() {
            fullVersionString = MessageFormat.format("{0}", implementationVersion);
        }

        private Manifest readManifest() {
            ProtectionDomain domain = VersionBean.class.getProtectionDomain();
            if (domain != null) {
                CodeSource codeSource = domain.getCodeSource();
                if (codeSource != null) {
                    URL url = codeSource.getLocation();
                    if (url != null) {
                        InputStream manifestStream = null;
                        try {
View Full Code Here

        return copyClass(c);
    }

    private Class<?> copyClass(final Class c) throws ClassNotFoundException {
        final String name = c.getName();
        final ProtectionDomain pd = c.getProtectionDomain();
        byte[] bytecode = readByteCode(name);

        for (ClassFileTransformer xf : transformers) {
            try {
                bytecode = xf.transform(this, name, null, pd, bytecode);
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.