Methods Summary |
---|
private final void | checkType(java.lang.String type)
if (type == null) {
throw new NullPointerException(Messages.getString("security.2F")); //$NON-NLS-1$
}
// type is the class name of the Permission class.
// Empty string is inappropriate for class name.
// But this check is commented out for compatibility with RI.
// see JIRA issue HARMONY-733
// if (type.length() == 0) {
// throw new IllegalArgumentException("type cannot be empty");
// }
|
public boolean | equals(java.lang.Object obj)Compares the specified object with this {@code UnresolvedPermission} for
equality and returns {@code true} if the specified object is equal,
{@code false} otherwise. To be equal, the specified object needs to be an
instance of {@code UnresolvedPermission}, the two {@code
UnresolvedPermission}s must refer to the same type and must have the same
name, the same actions and certificates.
if (obj == this) {
return true;
}
if (obj instanceof UnresolvedPermission) {
UnresolvedPermission that = (UnresolvedPermission)obj;
if (getName().equals(that.getName())
&& (targetName == null ? that.targetName == null
: targetName.equals(that.targetName))
&& (targetActions == null ? that.targetActions == null
: targetActions.equals(that.targetActions))
&& (PolicyUtils.matchSubset(targetCerts, that.targetCerts)
&& PolicyUtils.matchSubset(that.targetCerts, targetCerts))) {
return true;
}
}
return false;
|
public java.lang.String | getActions()Returns an empty string since there are no actions allowed for {@code
UnresolvedPermission}. The actions, specified in the constructor, are
used when the concrete permission is resolved and created.
return ""; //$NON-NLS-1$
|
public java.lang.String | getUnresolvedActions()Returns the actions of the permission this {@code UnresolvedPermission}
is resolved to.
return targetActions;
|
public java.security.cert.Certificate[] | getUnresolvedCerts()Returns the certificates of the permission this {@code
UnresolvedPermission} is resolved to.
if (targetCerts != null) {
Certificate[] certs = new Certificate[targetCerts.length];
System.arraycopy(targetCerts, 0, certs, 0, certs.length);
return certs;
}
return null;
|
public java.lang.String | getUnresolvedName()Returns the name of the permission this {@code UnresolvedPermission} is
resolved to.
return targetName;
|
public java.lang.String | getUnresolvedType()Returns the fully qualified class name of the permission this {@code
UnresolvedPermission} is resolved to.
return super.getName();
|
public int | hashCode()Returns the hash code value for this {@code UnresolvedPermission}.
Returns the same hash code for {@code UnresolvedPermission}s that are
equal to each other as required by the general contract of
{@link Object#hashCode}.
if (hash == 0) {
hash = getName().hashCode();
if (targetName != null) {
hash ^= targetName.hashCode();
}
if (targetActions != null) {
hash ^= targetActions.hashCode();
}
}
return hash;
|
public boolean | implies(java.security.Permission permission)Indicates whether the specified permission is implied by this {@code
UnresolvedPermission}. {@code UnresolvedPermission} objects imply nothing
since nothing is known about them yet.
Before actual implication checking, this method tries to resolve
UnresolvedPermissions (if any) against the passed instance. Successfully
resolved permissions (if any) are taken into account during further
processing.
return false;
|
public java.security.PermissionCollection | newPermissionCollection()Returns a new {@code PermissionCollection} for holding {@code
UnresolvedPermission} objects.
return new UnresolvedPermissionCollection();
|
private void | readObject(java.io.ObjectInputStream in)
checkType(getUnresolvedType());
ObjectInputStream.GetField fields = in.readFields();
if (!getUnresolvedType().equals(fields.get("type", null))) { //$NON-NLS-1$
throw new InvalidObjectException(Messages.getString("security.31")); //$NON-NLS-1$
}
targetName = (String)fields.get("name", null); //$NON-NLS-1$
targetActions = (String)fields.get("actions", null); //$NON-NLS-1$
int certNumber = in.readInt();
if (certNumber != 0) {
targetCerts = new Certificate[certNumber];
for (int i = 0; i < certNumber; i++) {
try {
String type = in.readUTF();
int length = in.readInt();
byte[] enc = new byte[length];
in.readFully(enc, 0, length);
targetCerts[i] = CertificateFactory.getInstance(type)
.generateCertificate(new ByteArrayInputStream(enc));
} catch (CertificateException cee) {
throw ((IOException)new IOException(
Messages.getString("security.32")).initCause(cee)); //$NON-NLS-1$
}
}
}
|
java.security.Permission | resolve(java.lang.Class targetType)Tries to resolve this permission into the specified class.
It is assumed that the class has a proper name (as returned by {@code
getName()} of this unresolved permission), so no check is performed to
verify this. However, the class must have all required certificates (as
per {@code getUnresolvedCerts()}) among the passed collection of signers.
If it does, a zero, one, and/or two-argument constructor is tried to
instantiate a new permission, which is then returned.
If an appropriate constructor is not available or the class is improperly
signed, {@code null} is returned.
// check signers at first
if (PolicyUtils.matchSubset(targetCerts, targetType.getSigners())) {
try {
return PolicyUtils.instantiatePermission(targetType,
targetName,
targetActions);
} catch (Exception ignore) {
//TODO log warning?
}
}
return null;
|
public java.lang.String | toString()Returns a string containing a concise, human-readable description of this
{@code UnresolvedPermission} including its target name and its target
actions.
return "(unresolved " + getName() + " " + targetName + " " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ targetActions + ")"; //$NON-NLS-1$
|
private void | writeObject(java.io.ObjectOutputStream out)
ObjectOutputStream.PutField fields = out.putFields();
fields.put("type", getUnresolvedType()); //$NON-NLS-1$
fields.put("name", getUnresolvedName()); //$NON-NLS-1$
fields.put("actions", getUnresolvedActions()); //$NON-NLS-1$
out.writeFields();
if (targetCerts == null) {
out.writeInt(0);
} else {
out.writeInt(targetCerts.length);
for (int i = 0; i < targetCerts.length; i++) {
try {
byte[] enc = targetCerts[i].getEncoded();
out.writeUTF(targetCerts[i].getType());
out.writeInt(enc.length);
out.write(enc);
} catch (CertificateEncodingException cee) {
throw ((IOException)new NotSerializableException(
Messages.getString("security.30", //$NON-NLS-1$
targetCerts[i])).initCause(cee));
}
}
}
|