Java 8 CodeSource - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 CodeSource class.

This code example shows how to use the following methods: getLocation
                        URL url = null;
                        ProtectionDomain pd = provider.getClass().getProtectionDomain();
                        if (pd != null) {
                            CodeSource cs = pd.getCodeSource();
                            if (cs != null) {
                                url = cs.getLocation();
                            } 
                        } 
                        return url;
                    } 
                }); 
                log.debug("Provider code base: " + url);
            } 
 
            Cipher.getInstance("DummyAlg/DummyMode/DummyPadding", "DP");
 
            response.getWriter().write("ok");
            response.getWriter().close();
 
        } catch (Exception e) {
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getCertificates, getCodeSigners, getLocation
        } 
        return cs.implies(normalizeCodeSource(codeSource));
    } 
 
    private CodeSource normalizeCodeSource(CodeSource codeSource) {
        URL codeSourceURL = PolicyUtils.normalizeURL(codeSource.getLocation());
        CodeSource result = codeSource;
 
        if (codeSourceURL != codeSource.getLocation()) {
            // URL was normalized - recreate codeSource with new URL 
            CodeSigner[] signers = codeSource.getCodeSigners();
            if (signers == null) {
                result = new CodeSource(codeSourceURL, codeSource
                        .getCertificates());
            } else { 
                result = new CodeSource(codeSourceURL, signers);
            } 
        } 
        return result;
    } 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
 
    public static void main(String[] args) throws Exception {
        String userDir = System.getProperty("user.dir");
        String jarURL = "jar:file:" + userDir + File.separator + "foo.jar!/";
        URL codeSourceURL = new URL(jarURL);
        CodeSource cs = new CodeSource(codeSourceURL, new Certificate[0]);
        PermissionCollection perms = Policy.getPolicy().getPermissions(cs);
        if (!perms.implies(new AllPermission()))
            throw new Exception("FAILED: " + codeSourceURL
                                + " not granted AllPermission"); 
    } 
} 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: implies
 
    private static void testImplies(URL thisURL, URL thatURL, boolean result)
        throws SecurityException 
    { 
        CodeSource thisCs =
            new CodeSource(thisURL, (java.security.cert.Certificate[]) null);
        CodeSource thatCs =
            new CodeSource(thatURL, (java.security.cert.Certificate[]) null);
 
        if (thisCs.implies(thatCs) != result) {
            throw new SecurityException("test failed");
        } 
    } 
} 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: sleep
        Permissions perms = new Permissions();
        perms.add(new SocketPermission("*:1024-", "listen"));
        AccessControlContext acc =
            new AccessControlContext(new ProtectionDomain[] {
                new ProtectionDomain(
                    new CodeSource(null, (Certificate[]) null), perms) });
 
        Remote impl = new DGCImplInsulation();;
 
        try { 
            Remote stub = (Remote) java.security.AccessController.doPrivileged(
                new ExportAction(impl));
            System.err.println("exported remote object; local stub: " + stub);
 
            MarshalledObject mobj = new MarshalledObject(stub);
            stub = (Remote) mobj.get();
            System.err.println("marshalled/unmarshalled stub: " + stub);
 
            ReferenceQueue refQueue = new ReferenceQueue();
            Reference weakRef = new WeakReference(impl, refQueue);

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
See Code Examples for Java 8 CodeSource Methods: