本文整理汇总了Java中org.apache.cxf.interceptor.security.AccessDeniedException类的典型用法代码示例。如果您正苦于以下问题:Java AccessDeniedException类的具体用法?Java AccessDeniedException怎么用?Java AccessDeniedException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AccessDeniedException类属于org.apache.cxf.interceptor.security包,在下文中一共展示了AccessDeniedException类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTargetMethod
import org.apache.cxf.interceptor.security.AccessDeniedException; //导入依赖的package包/类
protected Method getTargetMethod(Message m) {
// Used the SOAP
BindingOperationInfo bop = m.getExchange().get(BindingOperationInfo.class);
if (bop != null) {
MethodDispatcher md = (MethodDispatcher)
m.getExchange().get(Service.class).get(MethodDispatcher.class.getName());
return md.getMethod(bop);
}
// Used for JAX-RS
// This doesn't work for JAX-RS sub-resources as the lookup is only done on the original method, not the
// sub-resource
Method method = (Method) m.get("org.apache.cxf.resource.method");
if (method != null) {
return method;
}
throw new AccessDeniedException("Method is not available : Unauthorized");
}
示例2: handleMessage
import org.apache.cxf.interceptor.security.AccessDeniedException; //导入依赖的package包/类
public void handleMessage(Message message) throws Fault
{
SecurityContext sc = message.get(SecurityContext.class);
if (sc == null)
{
return;
}
Method method = getTargetMethod(message);
if (authorize(sc, method))
{
return;
}
throw new AccessDeniedException("Unauthorized");
}
示例3: getTargetMethod
import org.apache.cxf.interceptor.security.AccessDeniedException; //导入依赖的package包/类
protected Method getTargetMethod(Message m)
{
BindingOperationInfo bop = m.getExchange().get(BindingOperationInfo.class);
if (bop != null)
{
MethodDispatcher md = (MethodDispatcher) m.getExchange().get(Service.class).get(MethodDispatcher.class.getName());
return md.getMethod(bop);
}
Method method = (Method) m.get("org.apache.cxf.resource.method");
if (method != null)
{
return method;
}
throw new AccessDeniedException("Method is not available : Unauthorized");
}
示例4: getTargetMethod
import org.apache.cxf.interceptor.security.AccessDeniedException; //导入依赖的package包/类
/**
* Here we are getting the target invocation method. The method get set as a
* properties in the
* message by the
* {@link org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor}
*
* @param message incoming message
* @return
*/
protected Method getTargetMethod(Message message) {
BindingOperationInfo bop = message.getExchange().get(BindingOperationInfo.class);
if (bop != null) {
MethodDispatcher md =
(MethodDispatcher) message.getExchange().get(Service.class)
.get(MethodDispatcher.class.getName());
return md.getMethod(bop);
}
Method method = (Method) message.get("org.apache.cxf.resource.method");
if (method != null) {
return method;
}
log.error("The requested resource is not found. Please check the resource path etc..");
throw new AccessDeniedException("Method is not available : Unauthorized");
}
示例5: handleMessage
import org.apache.cxf.interceptor.security.AccessDeniedException; //导入依赖的package包/类
public void handleMessage( Message message ) throws Fault
{
Fault fault = (Fault) message.getContent( Exception.class );
Throwable ex = fault.getCause();
if ( !(ex instanceof SecurityException) )
{
throw new RuntimeException( "Security Exception is expected:" + ex );
}
HttpServletResponse response = (HttpServletResponse) message.getExchange().getInMessage()
.get( AbstractHTTPDestination.HTTP_RESPONSE );
int status = ex instanceof AccessDeniedException ? 403 : 401;
response.setStatus( status );
try
{
response.getOutputStream().write( ex.getMessage().getBytes() );
response.getOutputStream().flush();
}
catch ( IOException iex )
{
// ignore
}
message.getInterceptorChain().abort();
}
示例6: handleMessage
import org.apache.cxf.interceptor.security.AccessDeniedException; //导入依赖的package包/类
@Override
public void handleMessage(Message message) throws Fault {
try {
super.handleMessage(message);
} catch (AccessDeniedException fault) {
Fault unauthorized = new Fault("Unauthorized", getGlobal());
unauthorized.setStatusCode(403);
throw unauthorized;
}
}
示例7: getTargetMethod
import org.apache.cxf.interceptor.security.AccessDeniedException; //导入依赖的package包/类
/**
* Here we are getting the target invocation method. The method get set as a property in the
* message by the {@link org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor}
*
* @param message incoming message
* @return
*/
protected Method getTargetMethod(Message message) {
BindingOperationInfo bop = message.getExchange().get(BindingOperationInfo.class);
if (bop != null) {
MethodDispatcher md = (MethodDispatcher)
message.getExchange().get(Service.class).get(MethodDispatcher.class.getName());
return md.getMethod(bop);
}
Method method = (Method) message.get("org.apache.cxf.resource.method");
if (method != null) {
return method;
}
log.error("The requested resource is not found. Please check the resource path, etc");
throw new AccessDeniedException("Method is not available: Unauthorized");
}