/** * Define a class given its bytes * * @param container the container from which the class data has been read * may be a directory or a jar/zip file. * * @param classData the bytecode data for the class * @param classname the name of the class * * @return the Class instance created from the given data * * @throws IOException if the class data cannot be read. */ protected Class defineClassFromData(File container, byte[] classData, String classname) throws IOException { definePackage(container, classname); ProtectionDomain currentPd = Project.class.getProtectionDomain(); String classResource = getClassFilename(classname); CodeSource src = new CodeSource(FILE_UTILS.getFileURL(container), getCertificates(container, classResource)); ProtectionDomain classesPd = new ProtectionDomain(src, currentPd.getPermissions(), this, currentPd.getPrincipals()); return defineClass(classname, classData, 0, classData.length, classesPd); }
protected PermissionCollection getPermissions(CodeSource codeSource) { PermissionCollection perms; try { try { perms = super.getPermissions(codeSource); } catch (SecurityException e) { // We lied about our CodeSource and that makes URLClassLoader unhappy. perms = new Permissions(); } ProtectionDomain myDomain = AccessController.doPrivileged(new PrivilegedAction<ProtectionDomain>() { public ProtectionDomain run() { return getClass().getProtectionDomain(); } }); PermissionCollection myPerms = myDomain.getPermissions(); if (myPerms != null) { for (Enumeration<Permission> elements = myPerms.elements(); elements.hasMoreElements();) { perms.add(elements.nextElement()); } } } catch (Throwable e) { // We lied about our CodeSource and that makes URLClassLoader unhappy. perms = new Permissions(); } perms.setReadOnly(); return perms; }
/** * Define a class given its bytes * * @param container the container from which the class data has been read * may be a directory or a jar/zip file. * * @param classData the bytecode data for the class * @param classname the name of the class * * @return the Class instance created from the given data * * @throws IOException if the class data cannot be read. */ protected Class<?> defineClassFromData(final File container, final byte[] classData, final String classname) throws IOException { definePackage(container, classname); final ProtectionDomain currentPd = Project.class.getProtectionDomain(); final String classResource = getClassFilename(classname); final CodeSource src = new CodeSource(FILE_UTILS.getFileURL(container), getCertificates(container, classResource)); final ProtectionDomain classesPd = new ProtectionDomain(src, currentPd.getPermissions(), this, currentPd.getPrincipals()); return defineClass(classname, classData, 0, classData.length, classesPd); }
private static ProtectionDomain prepareDomain(ProtectionDomain domain, ClassLoader loader) { if (domain == null) { return null; } return new ProtectionDomain(domain.getCodeSource(), domain.getPermissions(), loader, domain.getPrincipals()); }
csKey = domain.getCodeSource(); PermissionCollection pc = domain.getPermissions(); if (pc != null) { List<Permission> permList = Collections.list(pc.elements());
ContextPermissions(ProtectionDomain staticDomain) { _context = AccessController.getContext(); if (staticDomain != null) { _statisPermissions = staticDomain.getPermissions(); } setReadOnly(); }
ContextPermissions(ProtectionDomain staticDomain) { _context = AccessController.getContext(); if (staticDomain != null) { _statisPermissions = staticDomain.getPermissions(); } setReadOnly(); }
/** * Purge all cached information for specified bundle. */ @Override void purge(BundleImpl b, ProtectionDomain pd) { if (ph.purgePermissionCollection(new Long(b.id), pd.getPermissions())) { adminPerms.remove(b); } }
ContextPermissions(ProtectionDomain staticDomain) { _context = AccessController.getContext(); if (staticDomain != null) { _statisPermissions = staticDomain.getPermissions(); } setReadOnly(); }
ContextPermissions(ProtectionDomain staticDomain) { _context = AccessController.getContext(); if (staticDomain != null) { _statisPermissions = staticDomain.getPermissions(); } setReadOnly(); }
DelegatingProtectionDomain(ProtectionDomain delegate, Principal[] principals) { super(delegate.getCodeSource(), delegate.getPermissions(), delegate.getClassLoader(), principals); this.delegate = delegate; }
private static ProtectionDomain prepareDomain(ProtectionDomain domain, ClassLoader loader) { if (domain == null) { return null; } return new ProtectionDomain(domain.getCodeSource(), domain.getPermissions(), loader, domain.getPrincipals()); }
private static ProtectionDomain prepareDomain(ProtectionDomain domain, ClassLoader loader) { if (domain == null) { return null; } return new ProtectionDomain(domain.getCodeSource(), domain.getPermissions(), loader, domain.getPrincipals()); }
private static ProtectionDomain prepareDomain(ProtectionDomain domain, ClassLoader loader) { if (domain == null) { return null; } return new ProtectionDomain(domain.getCodeSource(), domain.getPermissions(), loader, domain.getPrincipals()); }
private void addImpliedImportPackagePermissions(ManifestElement[] importElements) { ProtectionDomain wovenDomain = ((Generation) ((ModuleRevision) getBundleWiring().getRevision()).getRevisionInfo()).getDomain(); if (wovenDomain != null) { // security is enabled; add the permissions for (ManifestElement clause : importElements) for (String pkg : clause.getValueComponents()) ((BundlePermissions) wovenDomain.getPermissions()).addWovenPermission(new PackagePermission(pkg, PackagePermission.IMPORT)); } }
private void addImpliedImportPackagePermissions(ManifestElement[] importElements) { ProtectionDomain wovenDomain = ((Generation) ((ModuleRevision) getBundleWiring().getRevision()).getRevisionInfo()).getDomain(); if (wovenDomain != null) { // security is enabled; add the permissions for (ManifestElement clause : importElements) for (String pkg : clause.getValueComponents()) ((BundlePermissions) wovenDomain.getPermissions()).addWovenPermission(new PackagePermission(pkg, PackagePermission.IMPORT)); } }
private void addImpliedImportPackagePermissions(ManifestElement[] importElements) { ProtectionDomain wovenDomain = ((Generation) ((ModuleRevision) getBundleWiring().getRevision()).getRevisionInfo()).getDomain(); if (wovenDomain != null) { // security is enabled; add the permissions for (ManifestElement clause : importElements) for (String pkg : clause.getValueComponents()) ((BundlePermissions) wovenDomain.getPermissions()).addWovenPermission(new PackagePermission(pkg, PackagePermission.IMPORT)); } }
private void addImpliedImportPackagePermissions(ManifestElement[] importElements) { ProtectionDomain wovenDomain = ((Generation) ((ModuleRevision) getBundleWiring().getRevision()).getRevisionInfo()).getDomain(); if (wovenDomain != null) { // security is enabled; add the permissions for (ManifestElement clause : importElements) for (String pkg : clause.getValueComponents()) ((BundlePermissions) wovenDomain.getPermissions()).addWovenPermission(new PackagePermission(pkg, PackagePermission.IMPORT)); } }
private void addImpliedImportPackagePermissions(ManifestElement[] importElements) { ProtectionDomain wovenDomain = ((Generation) ((ModuleRevision) getBundleWiring().getRevision()).getRevisionInfo()).getDomain(); if (wovenDomain != null) { // security is enabled; add the permissions for (ManifestElement clause : importElements) for (String pkg : clause.getValueComponents()) ((BundlePermissions) wovenDomain.getPermissions()).addWovenPermission(new PackagePermission(pkg, PackagePermission.IMPORT)); } }
private void addImpliedImportPackagePermissions(ManifestElement[] importElements) { ProtectionDomain wovenDomain = ((Generation) ((ModuleRevision) getBundleWiring().getRevision()).getRevisionInfo()).getDomain(); if (wovenDomain != null) { // security is enabled; add the permissions for (ManifestElement clause : importElements) for (String pkg : clause.getValueComponents()) ((BundlePermissions) wovenDomain.getPermissions()).addWovenPermission(new PackagePermission(pkg, PackagePermission.IMPORT)); } }