com.feilong.lib.xstream.security.NoPermission Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of feilong Show documentation
Show all versions of feilong Show documentation
feilong is a suite of core and expanded libraries that include utility classes, http, excel,cvs, io classes, and much much more.
/*
* Copyright (C) 2014 XStream Committers.
* All rights reserved.
*
* Created on 09. January 2014 by Joerg Schaible
*/
package com.feilong.lib.xstream.security;
/**
* Wrapper to negate another type permission.
*
* If the wrapped {@link TypePermission} allows the type, this instance will throw a {@link ForbiddenClassException}
* instead. An instance of this permission cannot be used to allow a type.
*
*
* @author Jörg Schaible
* @since 1.4.7
*/
public class NoPermission implements TypePermission{
private final TypePermission permission;
/**
* Construct a NoPermission.
*
* @param permission
* the permission to negate or null
to forbid any type
* @since 1.4.7
*/
public NoPermission(final TypePermission permission){
this.permission = permission;
}
@Override
public boolean allows(final Class type){
if (permission == null || permission.allows(type)){
throw new ForbiddenClassException(type);
}
return false;
}
}