Java 8 ProtectionDomain - 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 ProtectionDomain class.

This code example shows how to use the following methods:getCodeSource
                URL url = AccessController.doPrivileged(new PrivilegedAction<URL>() {
                    public URL run() {
                        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();
7
CodeRank
This code example shows how to use the following methods:
  private static ProtectionDomain defaultDomain = null; 
 
  public static ProtectionDomain loadedClassDomain() { 
    if (defaultDomain == null) { 
      CodeSource cs = new CodeSource(null, (Certificate[]) null); 
      defaultDomain = new ProtectionDomain(cs, null); 
    } 
    return defaultDomain; 
  } 
} 
6
CodeRank
This code example shows how to use the following methods:getCodeSource
 
		Server server = new Server(port);
		server.setStopAtShutdown(true);
 
		ProtectionDomain protectionDomain = Main.class.getProtectionDomain();
		URL location = protectionDomain.getCodeSource().getLocation();
		String warFile = location.toExternalForm();
 
		WebAppContext context = new WebAppContext(warFile, contextPath);
		context.setServer(server);
 
		// 设置work dir,war包将解压到该目录,jsp编译后的文件也将放入其中。 
		String currentDir = new File(location.getPath()).getParent();
		File workDir = new File(currentDir, "work");
		context.setTempDirectory(workDir);
 
		server.setHandler(context);
		return server;
	} 
 
6
CodeRank
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();

6
CodeRank
This code example shows how to use the following methods:
		 
		ProtectionDomain processedProtectionDomain = domain;
	    
		if (processedProtectionDomain == null && data.getSymbolicName().equals("org.apache.openejb.core")) {		
			PermissionCollection emptyPermissionCollection = (new AllPermission()).newPermissionCollection();
			processedProtectionDomain = new ProtectionDomain(null, emptyPermissionCollection);			
		} 
		return new DefaultClassLoader(parent, delegate, processedProtectionDomain, data, classpath);
	} 
 
	@Override 
	public boolean addClassPathEntry(ArrayList<ClasspathEntry> arg0,
			String arg1, ClasspathManager arg2, BaseData arg3,
			ProtectionDomain arg4) {
		// TODO Auto-generated method stub 
		return false; 
	} 
 
	@Override 
	public String findLibrary(BaseData arg0, String arg1) {
5
CodeRank
This code example shows how to use the following methods:
                                (new CodeSource(url3,
                                    (java.security.cert.Certificate[]) null),
                                null,                   // permissions 
                                null,                   // class loader 
                                null);                  // principals 
        ProtectionDomain d4 = new ProtectionDomain
                                (new CodeSource(url4,
                                    (java.security.cert.Certificate[]) null),
                                null,                   // permissions 
                                null,                   // class loader 
                                null);                  // principals 
 
        // test 1 
        // -- regular combine, make sure we get a proper combination back 
 
        ProtectionDomain currentDomains[] = { d1, d2, d3 };
        ProtectionDomain assignedDomains[] = { d4 };
        ProtectionDomain domains1[] = sdc.combine
                        (currentDomains, assignedDomains);
 
5
CodeRank
This code example shows how to use the following methods:getCodeSource
   static final Set<String> grants = new HashSet<String>();
   boolean logPolicyChecks = false; // switch to true if we need to log grants
 
   @Override 
   public boolean implies(ProtectionDomain domain, Permission permission) {
      String location = domain.getCodeSource().getLocation().getPath().replaceAll("\\\\", "/");
      // Allow any permissions from dependencies and the actual modules' classes 
      if (location.endsWith(".jar") || location.endsWith(MODULE_CLASSES)) {
         if (logPolicyChecks) {
            StringBuilder sb = new StringBuilder();
            sb.append(location.substring(location.lastIndexOf(File.separator)+1));
            sb.append("> permission ");
            sb.append(permission.getClass().getName());
            sb.append(" \"");
            sb.append(permission.getName());
            sb.append("\"");
            if (permission.getActions().length()>0) {
               sb.append(" \"");
               sb.append(permission.getActions());
               sb.append("\"");
5
CodeRank
This code example shows how to use the following methods:
	protected void checkForAllPermission(Policy policy, String rootDir)
		throws MalformedURLException {
 
		URL rootURL = new URL("file", null, rootDir);
 
		ProtectionDomain protectionDomain = new ProtectionDomain(
			new CodeSource(rootURL, new Certificate[0]), new Permissions());
 
		if (policy.implies(protectionDomain, new AllPermission())) {
			throw new IllegalStateException(
				"The plugin's Java policy tried to declared all " + 
					"permissions"); 
		} 
	} 
 
	protected Checker getChecker(Class<? extends Permission> clazz) {
		return _checkers.get(clazz.getName());
	} 
 
	protected Provider getProvider() {
5
CodeRank
This code example shows how to use the following methods:getCodeSource
	private static Class<?> _loadTestClass(Class<?> clazz)
		throws ClassNotFoundException {
 
		ProtectionDomain protectionDomain = clazz.getProtectionDomain();
 
		CodeSource codeSource = protectionDomain.getCodeSource();
 
		ClassLoader classLoader = new PACLClassLoader(
			new URL[] {codeSource.getLocation()}, clazz.getClassLoader());
 
		return Class.forName(clazz.getName(), true, classLoader);
	} 
 
	private static final String _PACKAGE_PATH =
		"com.liferay.portal.security.pacl.test."; 
 
	static { 
		URL resource = PACLTestRule.class.getResource("pacl-test.properties");
 
		if (resource != null) {
5
CodeRank
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();

5
CodeRank
See Code Examples for Java 8 ProtectionDomain Methods: