SecurityInitializerImplpublic class SecurityInitializerImpl extends Object The class implements security initializer logic common for core
subsystems and for optional JSRs. Using this implmentation JSRs
can easily introduce own security initializers for redispatching
security tokens within JSR subsystem. |
Fields Summary |
---|
SecurityToken | internalSecurityTokenInternal security token | private String[] | trustedClassesList of trusted class names | private int | trustedStartIndex of the first trusted name in the list |
Constructors Summary |
---|
public SecurityInitializerImpl(SecurityToken token, String[] trusted)Create instance of SecurityInitializerImpl with a given token and
list of trusted class names
internalSecurityToken = token;
trustedClasses = trusted;
|
Methods Summary |
---|
boolean | isTrusted(java.lang.Object object)Check whether object is the instance of a trusted class, that means
the object owner has the right to request for a security token.
The optimized implementation for this method can be provided in
VM specific way.
Note, the implementation allows only single request for
SecurityToken for each trusted class, the class
is removed from the trusted list after token hand out.
if (trustedClasses != null) {
String className = object.getClass().getName();
// IMPL_NOTE: Optimize search for trusted class name
for (int i=trustedStart; i<trustedClasses.length; i++) {
if (className.equals(trustedClasses[i])) {
// Free name of the used trusted class and
// move forward the first name index
if (trustedStart != i) {
trustedClasses[i] =
trustedClasses[trustedStart];
}
trustedClasses[trustedStart] = null;
trustedStart++;
return true;
}
}
}
return false;
| public SecurityToken | requestToken(ImplicitlyTrustedClass trusted)Request security token using trusted object instance.
Note that the imposibility to create trusted objects
for untrusted requesters is the only guarantee of
secure tokens dispatching.
if (!isTrusted(trusted)) {
throw new SecurityException(
"Failed request for SecurityToken by " +
trusted.getClass().getName());
}
// Grant internal security token to trusted requester
return internalSecurityToken;
|
|