Methods Summary |
---|
private static void | checkPermission(java.security.Permission p)
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(p);
}
|
private void | checkState()
if (readOnly) {
throw new IllegalStateException(Messages.getString("auth.0A")); //$NON-NLS-1$
}
|
public static java.lang.Object | doAs(javax.security.auth.Subject subject, java.security.PrivilegedAction action)Runs the code defined by {@code action} using the permissions granted to
the {@code Subject} itself and to the code as well.
checkPermission(_AS);
return doAs_PrivilegedAction(subject, action, AccessController.getContext());
|
public static java.lang.Object | doAs(javax.security.auth.Subject subject, java.security.PrivilegedExceptionAction action)Runs the code defined by {@code action} using the permissions granted to
the subject and to the code itself.
checkPermission(_AS);
return doAs_PrivilegedExceptionAction(subject, action, AccessController.getContext());
|
public static java.lang.Object | doAsPrivileged(javax.security.auth.Subject subject, java.security.PrivilegedAction action, java.security.AccessControlContext context)Run the code defined by {@code action} using the permissions granted to
the {@code Subject} and to the code itself, additionally providing a more
specific context.
checkPermission(_AS_PRIVILEGED);
if (context == null) {
return doAs_PrivilegedAction(subject, action, new AccessControlContext(
new ProtectionDomain[0]));
}
return doAs_PrivilegedAction(subject, action, context);
|
public static java.lang.Object | doAsPrivileged(javax.security.auth.Subject subject, java.security.PrivilegedExceptionAction action, java.security.AccessControlContext context)Runs the code defined by {@code action} using the permissions granted to
the subject and to the code itself, additionally providing a more
specific context.
checkPermission(_AS_PRIVILEGED);
if (context == null) {
return doAs_PrivilegedExceptionAction(subject, action,
new AccessControlContext(new ProtectionDomain[0]));
}
return doAs_PrivilegedExceptionAction(subject, action, context);
|
private static java.lang.Object | doAs_PrivilegedAction(javax.security.auth.Subject subject, java.security.PrivilegedAction action, java.security.AccessControlContext context)
AccessControlContext newContext;
final SubjectDomainCombiner combiner;
if (subject == null) {
// performance optimization
// if subject is null there is nothing to combine
combiner = null;
} else {
combiner = new SubjectDomainCombiner(subject);
}
PrivilegedAction dccAction = new PrivilegedAction() {
public Object run() {
return new AccessControlContext(context, combiner);
}
};
newContext = (AccessControlContext) AccessController.doPrivileged(dccAction);
return AccessController.doPrivileged(action, newContext);
|
private static java.lang.Object | doAs_PrivilegedExceptionAction(javax.security.auth.Subject subject, java.security.PrivilegedExceptionAction action, java.security.AccessControlContext context)
AccessControlContext newContext;
final SubjectDomainCombiner combiner;
if (subject == null) {
// performance optimization
// if subject is null there is nothing to combine
combiner = null;
} else {
combiner = new SubjectDomainCombiner(subject);
}
PrivilegedAction<AccessControlContext> dccAction = new PrivilegedAction<AccessControlContext>() {
public AccessControlContext run() {
return new AccessControlContext(context, combiner);
}
};
newContext = AccessController.doPrivileged(dccAction);
return AccessController.doPrivileged(action, newContext);
|
public boolean | equals(java.lang.Object obj)Checks two Subjects for equality. More specifically if the principals,
public and private credentials are equal, equality for two {@code
Subjects} is implied.
if (this == obj) {
return true;
}
if (obj == null || this.getClass() != obj.getClass()) {
return false;
}
Subject that = (Subject) obj;
if (principals.equals(that.principals)
&& publicCredentials.equals(that.publicCredentials)
&& privateCredentials.equals(that.privateCredentials)) {
return true;
}
return false;
|
public java.util.Set | getPrincipals()Returns this {@code Subject}'s {@link Principal}.
return principals;
|
public java.util.Set | getPrincipals(java.lang.Class c)Returns this {@code Subject}'s {@link Principal} which is a subclass of
the {@code Class} provided.
return ((SecureSet<Principal>) principals).get(c);
|
public java.util.Set | getPrivateCredentials()Returns the private credentials associated with this {@code Subject}.
return privateCredentials;
|
public java.util.Set | getPrivateCredentials(java.lang.Class c)Returns this {@code Subject}'s private credentials which are a subclass
of the {@code Class} provided.
return privateCredentials.get(c);
|
public java.util.Set | getPublicCredentials()Returns the public credentials associated with this {@code Subject}.
return publicCredentials;
|
public java.util.Set | getPublicCredentials(java.lang.Class c)Returns this {@code Subject}'s public credentials which are a subclass of
the {@code Class} provided.
return publicCredentials.get(c);
|
public static javax.security.auth.Subject | getSubject(java.security.AccessControlContext context)Returns the {@code Subject} that was last associated with the {@code
context} provided as argument.
checkPermission(_SUBJECT);
if (context == null) {
throw new NullPointerException(Messages.getString("auth.09")); //$NON-NLS-1$
}
PrivilegedAction<DomainCombiner> action = new PrivilegedAction<DomainCombiner>() {
public DomainCombiner run() {
return context.getDomainCombiner();
}
};
DomainCombiner combiner = AccessController.doPrivileged(action);
if ((combiner == null) || !(combiner instanceof SubjectDomainCombiner)) {
return null;
}
return ((SubjectDomainCombiner) combiner).getSubject();
|
public int | hashCode()Returns a hash code of this {@code Subject}.
return principals.hashCode() + privateCredentials.hashCode()
+ publicCredentials.hashCode();
|
public boolean | isReadOnly()Returns whether this {@code Subject} is read-only or not.
return readOnly;
|
private void | readObject(java.io.ObjectInputStream in)
in.defaultReadObject();
publicCredentials = new SecureSet<Object>(_PUBLIC_CREDENTIALS);
privateCredentials = new SecureSet<Object>(_PRIVATE_CREDENTIALS);
|
public void | setReadOnly()Prevents from modifications being done to the credentials and {@link
Principal} sets. After setting it to read-only this {@code Subject} can
not be made writable again. The destroy method on the credentials still
works though.
checkPermission(_READ_ONLY);
readOnly = true;
|
public java.lang.String | toString()Returns a {@code String} representation of this {@code Subject}.
StringBuffer buf = new StringBuffer("Subject:\n"); //$NON-NLS-1$
Iterator<?> it = principals.iterator();
while (it.hasNext()) {
buf.append("\tPrincipal: "); //$NON-NLS-1$
buf.append(it.next());
buf.append('\n");
}
it = publicCredentials.iterator();
while (it.hasNext()) {
buf.append("\tPublic Credential: "); //$NON-NLS-1$
buf.append(it.next());
buf.append('\n");
}
int offset = buf.length() - 1;
it = privateCredentials.iterator();
try {
while (it.hasNext()) {
buf.append("\tPrivate Credential: "); //$NON-NLS-1$
buf.append(it.next());
buf.append('\n");
}
} catch (SecurityException e) {
buf.delete(offset, buf.length());
buf.append("\tPrivate Credentials: no accessible information\n"); //$NON-NLS-1$
}
return buf.toString();
|
private void | writeObject(java.io.ObjectOutputStream out)
out.defaultWriteObject();
|