1 22 package org.jboss.test.jmx.interceptors; 23 24 import java.security.Principal ; 25 import org.jboss.mx.interceptor.AbstractInterceptor; 26 import org.jboss.mx.server.Invocation; 27 import org.jboss.logging.Logger; 28 import org.jboss.security.SecurityAssociation; 29 30 34 public final class PrincipalInterceptor 35 extends AbstractInterceptor 36 { 37 private static Logger log = Logger.getLogger(PrincipalInterceptor.class); 38 39 public Object invoke(Invocation invocation) throws Throwable 41 { 42 45 String type = invocation.getType(); 46 if( type != Invocation.OP_GETMBEANINFO ) 47 { 48 Principal caller = SecurityAssociation.getPrincipal(); 49 String opName = invocation.getName(); 50 log.info("invoke, opName="+opName+", caller="+caller); 51 if( caller == null || caller.getName().equals("jduke") == false ) 52 { 53 throw new SecurityException ("Caller="+caller+" is not jduke"); 54 } 55 } 56 return invocation.nextInterceptor().invoke(invocation); 57 } 58 } 59 | Popular Tags |