So I've given it some thought and the only explanation I can come up
with is:
1. To create an instance of the bootstrap proxy you need the codebase
annotation.
2. Codebase annotation is needed because you want the bootstrap proxy's
class to be
defined in the proper codebase ClassLoader
3. Since you do not want to allow any code downloads before placing
constraints on the
bootstrap proxy - it has to be a dynamic proxy. That way its class can
be defined by the codebase loader
and yet no code is downloaded
So the overall sequence is as follows:
1. Get the codebase annotation and create the codebase loader
2. Create an instance of a dynamic proxy of a class defined by the
codebase loader
3. IMPORTANT - before creating the proxy instance DO NOT grant any
download permissions
- that way we are sure the proxy does not triggers any code download and
execution due
to it implementing some foreign interfaces
4. Once the proxy is instantiated - grant its ClassLoader download
permissions
5. Place the constraints on the proxy
6. Invoke a remote method on the proxy
I understand the whole thing is to make sure the bootstrap proxy
is defined by the codebase ClassLoader - and the ClassLoader is needed
to be able to
dynamically grant download permissions.
What I DO NOT understand is - why the download permissions are needed at
all?
Since the bootstrap proxy's code MUST be local code - why not simply
have its class
defined by the context ClassLoader?
Since downloading code is done only after authentication anyway - I
don't see the reason to
use DownloadPermissions at all.
The only thing that comes to mind is that it is to make sure the service
is not able to download code from a codebase different than its own.
Which is OK but redundant. The reasoning is:
Since the code of the service proxy is already trusted (we have
established trust before downloading it) -
we can simply place the constraints on the service proxy that instructs
it to only download
code meeting certain criteria.
Am I correct in my thinking?
Thanks,
Michal
Michał Kłeczek wrote:
Let me dig some deeper. Comments inline.
Peter wrote:
Yes the dynamic proxy's are 100% local code. Remember dynamic
proxy's don't have codebase s. :)
Of course they do - look at PreferredClassProvider - the dynamic proxy
class is defined by the codebase loader!
Being a dynamic proxy does not mean there is no codebase.
AtomicMarshalInputStream performs a special input validation on
java.lang.reflect.Proxy thus ensuring the InvocationHandler is also
trusted. If the InvocationHandler doesn't pass the test the proxy's
never created.
Why does it only verify dynamic proxies? Doesn't it verify normal
objects?
The dynamic proxy's put you in direct contact with the service
provider using only local code with input validation constrained over
secure connections (as configured with constraints in force).
I think I've given you enough info now to investigate further.
Ok - so your "token" is the same thing as my SmartProxyWrapper. Let's
call it a "bootstrap proxy", ok?
1. What interface this bootstrap proxy implements?
2. Why do you think it has to be a dynamic proxy (ie. an instance of a
subclass of java.lang.Proxy)?
3. What and when are DownloadPermissions required? How do they add to
the overall security?
I understand the security of service proxies is enforced by the
constraints placed on the bootstrap proxy.
So where is the place for DownloadPermissions?
4. Finally - how is the lookup service proxy verified? Does it also
provide the bootstrap proxy?
If so - what special role does it play in the architecture?
The bootstrap proxy does not have to be provided by the lookup
service, does it?
If it is verified differently - why and how?
Thanks,
Michal