login();
Object obj = getInitialContext().lookup("security-proxy/ProxiedStatelessBean");
obj = PortableRemoteObject.narrow(obj, IOSessionHome.class);
IOSessionHome home = (IOSessionHome) obj;
log.debug("Found IOSessionHome");
IOSession bean = home.create();
log.debug("Created IOSession");
try
{
// This should not be allowed
bean.read("/restricted/pgp.keys");
fail("Was able to call read(/restricted/pgp.keys)");
}
catch(RemoteException e)
{
log.debug("IOSession.read failed as expected");
}
bean.read("/public/pgp.keys");
try
{
// This should not be allowed
bean.retryableRead("/restricted/pgp.keys");
fail("Was able to call read(/restricted/pgp.keys)");
}
catch(ReadAccessException e)
{
log.debug("IOSession.read failed as expected with ReadAccessException");
bean.read("/public/pgp.keys");
}
try
{
// This should not be allowed
bean.write("/restricted/pgp.keys");
fail("Was able to call write(/restricted/pgp.keys)");
}
catch(RemoteException e)
{
log.debug("IOSession.write failed as expected");
}
bean.write("/public/pgp.keys");
bean.remove();
}