implement stub versions of java.security classes

This commit is contained in:
Joel Dice 2009-08-03 08:56:19 -06:00
parent c5deeb2cda
commit 54ceb80116
7 changed files with 115 additions and 2 deletions

View File

@ -23,6 +23,8 @@ import java.io.InputStream;
import java.io.IOException;
import java.net.URL;
import java.security.ProtectionDomain;
import java.security.Permissions;
import java.security.AllPermission;
public final class Class <T> implements Type, GenericDeclaration {
private static final int PrimitiveFlag = 1 << 4;
@ -494,7 +496,9 @@ public final class Class <T> implements Type, GenericDeclaration {
}
public ProtectionDomain getProtectionDomain() {
throw new UnsupportedOperationException();
Permissions p = new Permissions();
p.add(new AllPermission());
return new ProtectionDomain(null, p);
}
// for GNU Classpath compatibility:

View File

@ -0,0 +1,13 @@
/* Copyright (c) 2009, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear
in all copies.
There is NO WARRANTY for this software. See license.txt for
details. */
package java.security;
public class AllPermission extends Permission { }

View File

@ -0,0 +1,13 @@
/* Copyright (c) 2009, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear
in all copies.
There is NO WARRANTY for this software. See license.txt for
details. */
package java.security;
public class CodeSource { }

View File

@ -0,0 +1,17 @@
/* Copyright (c) 2009, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear
in all copies.
There is NO WARRANTY for this software. See license.txt for
details. */
package java.security;
public abstract class Permission {
public PermissionCollection newPermissionCollection() {
return null;
}
}

View File

@ -0,0 +1,15 @@
/* Copyright (c) 2009, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear
in all copies.
There is NO WARRANTY for this software. See license.txt for
details. */
package java.security;
public abstract class PermissionCollection {
public abstract void add(Permission p);
}

View File

@ -0,0 +1,41 @@
/* Copyright (c) 2009, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear
in all copies.
There is NO WARRANTY for this software. See license.txt for
details. */
package java.security;
import java.util.Map;
import java.util.HashMap;
import java.util.Set;
import java.util.HashSet;
public class Permissions extends PermissionCollection {
private final Map<Class,PermissionCollection> collections = new HashMap();
public void add(Permission p) {
Class c = p.getClass();
PermissionCollection pc = collections.get(c);
if (pc == null) {
pc = p.newPermissionCollection();
if (pc == null) {
pc = new MyPermissionCollection();
}
collections.put(c, pc);
}
pc.add(p);
}
private static class MyPermissionCollection extends PermissionCollection {
private final Set<Permission> permissions = new HashSet();
public void add(Permission p) {
permissions.add(p);
}
}
}

View File

@ -10,4 +10,14 @@
package java.security;
public class ProtectionDomain { }
public class ProtectionDomain {
private final CodeSource codeSource;
private final PermissionCollection permissions;
public ProtectionDomain(CodeSource codeSource,
PermissionCollection permissions)
{
this.codeSource = codeSource;
this.permissions = permissions;
}
}