本文整理了Java中java.security.Permissions
类的一些代码示例,展示了Permissions
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Permissions
类的具体详情如下:
包路径:java.security.Permissions
类名称:Permissions
[英]Legacy security code; do not use.
[中]遗留安全代码;不要使用。
代码示例来源:origin: org.codehaus.groovy/groovy
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;
}
代码示例来源:origin: dlew/joda-time-android
public PermissionCollection getPermissions(CodeSource codesource) {
Permissions p = new Permissions();
p.add(new AllPermission()); // enable everything
return p;
}
public void refresh() {
代码示例来源:origin: org.apache.ant/ant
/**
* The central point in checking permissions.
* Overridden from java.lang.SecurityManager
*
* @param perm The permission requested.
*/
@Override
public void checkPermission(final java.security.Permission perm) {
if (active) {
if (delegateToOldSM && !perm.getName().equals("exitVM")) {
boolean permOK = false;
if (granted.implies(perm)) {
permOK = true;
}
checkRevoked(perm);
/*
if the permission was not explicitly granted or revoked
the original security manager will do its work
*/
if (!permOK && origSm != null) {
origSm.checkPermission(perm);
}
} else {
if (!granted.implies(perm)) {
throw new SecurityException("Permission " + perm + " was not granted.");
}
checkRevoked(perm);
}
}
}
代码示例来源:origin: wildfly/wildfly
/**
* Get a read-only collection of the given permissions.
*
* @param permissions the permissions to assign
* @return the read-only collection
*/
public static PermissionCollection readOnlyCollectionOf(Permission... permissions) {
final int length = permissions.length;
if (length == 0) {
return EMPTY_PERMISSION_COLLECTION;
} else {
Permissions collection = new Permissions();
addAll(collection, Arrays.asList(permissions));
collection.setReadOnly();
return collection;
}
}
}
代码示例来源:origin: wildfly/wildfly
@Override
public void addToRole(String roleName, Permission permission) throws PolicyContextException {
checkNotNullParam("roleName", roleName);
checkNotNullParam("permission", permission);
synchronized (this) { // prevents state change while adding
checkIfInOpenState();
this.rolePermissions.computeIfAbsent(roleName, s -> new Permissions()).add(permission);
}
}
代码示例来源:origin: org.jboss.modules/jboss-modules
private static PermissionCollection copyPermissions(PermissionCollection permissionCollection) {
final Permissions permissions = new Permissions();
final Enumeration<Permission> elements = permissionCollection.elements();
while (elements.hasMoreElements()) {
permissions.add(elements.nextElement());
}
permissions.setReadOnly();
return permissions;
}
代码示例来源:origin: ben-manes/caffeine
@Override
public String toString() {
List<Permission> ps = new ArrayList<Permission>();
for (Enumeration<Permission> e = perms.elements(); e.hasMoreElements();) {
ps.add(e.nextElement());
}
return "AdjustablePolicy with permissions " + ps;
}
}
代码示例来源:origin: weld/core
private ProtectionDomain create(ProtectionDomain domain) {
if (domain.implies(ACCESS_DECLARED_MEMBERS_PERMISSION)) {
return domain;
}
PermissionCollection permissions = domain.getPermissions();
PermissionCollection proxyPermissions = new Permissions();
if (permissions != null) {
Enumeration<Permission> permissionElements = permissions.elements();
while (permissionElements.hasMoreElements()) {
proxyPermissions.add(permissionElements.nextElement());
}
}
proxyPermissions.add(ACCESS_DECLARED_MEMBERS_PERMISSION);
return new ProtectionDomain(domain.getCodeSource(), proxyPermissions);
}
代码示例来源:origin: org.glassfish.security/security
private static boolean grantedIsExcluded(Permission granted, Permissions excluded) {
boolean isExcluded = false;
if (excluded != null) {
if (!excluded.implies(granted)) {
Enumeration e = excluded.elements();
while (!isExcluded && e.hasMoreElements()) {
Permission excludedPerm = (Permission) e.nextElement();
if (granted.implies(excludedPerm)) {
isExcluded = true;
}
}
} else {
isExcluded = true;
}
}
if (logger.isLoggable(Level.FINEST)){
if (isExcluded) {
logger.finest("JACC Policy Provider: permission is excluded: "+granted);
}
}
return isExcluded;
}
代码示例来源:origin: org.ow2.orchestra/orchestra-utils
/**
* @param permissions
* @return
*/
public static int getPermissionsSize(final Permissions permissions) {
int size = 0;
final Enumeration<Permission> p = permissions.elements();
while (p.hasMoreElements()) {
size++;
}
return size;
}
代码示例来源:origin: org.eclipse.jetty/jetty-policy
private PermissionCollection copyOf(final PermissionCollection in)
{
PermissionCollection out = new Permissions();
synchronized (in)
{
for (Enumeration<Permission> el = in.elements() ; el.hasMoreElements() ;)
{
out.add((Permission)el.nextElement());
}
}
return out;
}
代码示例来源:origin: org.apache.geronimo.ext.openejb/openejb-core
/**
* Removes permissions from <code>toBeChecked</code> that are implied by
* <code>permission</code>.
*
* @param toBeChecked the permissions that are to be checked and possibly culled
* @param permission the permission that is to be used for culling
* @return the culled set of permissions that are not implied by <code>permission</code>
*/
private Permissions cullPermissions(Permissions toBeChecked, Permission permission) {
Permissions result = new Permissions();
for (Enumeration e = toBeChecked.elements(); e.hasMoreElements();) {
Permission test = (Permission) e.nextElement();
if (!permission.implies(test)) {
result.add(test);
}
}
return result;
}
}
代码示例来源:origin: wildfly/wildfly-core
private static Permissions createPermissions(List<Permission> permissionsList, List<InjectedValue<Permissions>> permissionSetInjectors) throws StartException {
Permissions allPermissions = createPermissions(permissionsList);
for (InjectedValue<Permissions> permissionSetInjector : permissionSetInjectors) {
Permissions permissionSet = permissionSetInjector.getValue();
Enumeration<java.security.Permission> permissions = permissionSet.elements();
while (permissions.hasMoreElements()) {
allPermissions.add(permissions.nextElement());
}
}
return allPermissions;
}
代码示例来源:origin: org.apache.portals.jetspeed-2/jetspeed-security
/**
* @see java.security.Policy#getPermissions(java.security.ProtectionDomain)
*/
public PermissionCollection getPermissions(ProtectionDomain domain)
{
PermissionCollection otherPerms = new Permissions();
if (null != domain)
{
otherPerms = getPermissions(domain.getCodeSource());
}
return otherPerms;
}
代码示例来源:origin: org.netbeans.api/org-openide-execution
protected PermissionCollection createPermissions(CodeSource cs, InputOutput io) {
PermissionCollection allPerms = new Permissions();
allPerms.add(new AllPermission());
allPerms.setReadOnly();
return allPerms;
}
代码示例来源:origin: spring-projects/spring-framework
beanFactory.setSecurityContextProvider(null);
Permissions perms = new Permissions();
perms.add(new AuthPermission("getSubject"));
ProtectionDomain pd = new ProtectionDomain(null, perms);
代码示例来源:origin: apache/stanbol
@Override
public PermissionCollection getPermissions(ProtectionDomain domain) {
PermissionCollection result = new Permissions();
result.add(new AllPermission());
return result;
}
});
代码示例来源:origin: org.glassfish.main.security/security-ee
static Permissions addToRoleMap(HashMap<String, Permissions> map,
String roleName, Permission p) {
Permissions collection = map.get(roleName);
if (collection == null) {
collection = new Permissions();
map.put(roleName,collection);
}
collection.add(p);
if (logger.isLoggable(Level.FINE)){
logger.log(Level.FINE,"JACC: constraint capture: adding methods to role: "+ roleName+" methods: " + p.getActions());
}
return collection;
}
代码示例来源:origin: stackoverflow.com
private static final AccessControlContext allowedPermissionsAcc;
static { // initialization of the allowed permissions
PermissionCollection allowedPermissions = new Permissions();
allowedPermissions.add(new RuntimePermission("accessDeclaredMembers"));
// ... <many more permissions here> ...
allowedPermissionsAcc = new AccessControlContext(new ProtectionDomain[] {
new ProtectionDomain(null, allowedPermissions)});
}
代码示例来源:origin: robovm/robovm
/**
* Returns the {@code PermissionCollection} for the specified {@code
* CodeSource}.
*
* @param codesource
* the code source.
* @return the {@code PermissionCollection} for the specified {@code
* CodeSource}.
*/
protected PermissionCollection getPermissions(CodeSource codesource) {
// Do nothing by default, ProtectionDomain will take care about
// permissions in dynamic
return new Permissions();
}
内容来源于网络,如有侵权,请联系作者删除!