javax.smartcardio
public class: CardPermission [javadoc |
source]
java.lang.Object
java.security.Permission
javax.smartcardio.CardPermission
All Implemented Interfaces:
Guard, Serializable
A permission for Smart Card operations. A CardPermission consists of the
name of the card terminal the permission applies to and a set of actions
that are valid for that terminal.
A CardPermission with a name of * applies to all
card terminals. The actions string is a comma separated list of the actions
listed below, or * to signify "all actions."
Individual actions are:
- connect
- connect to a card using
{@linkplain CardTerminal#connect CardTerminal.connect()}
- reset
- reset the card using {@linkplain Card#disconnect Card.disconnect(true)}
- exclusive
- establish exclusive access to a card using
{@linkplain Card#beginExclusive} and {@linkplain Card#endExclusive
endExclusive()}
- transmitControl
- transmit a control command using
{@linkplain Card#transmitControlCommand Card.transmitControlCommand()}
- getBasicChannel
- obtain the basic logical channel using
{@linkplain Card#getBasicChannel}
- openLogicalChannel
- open a new logical channel using
{@linkplain Card#openLogicalChannel}
- since:
1.6 -
- author:
Andreas - Sterbenz
- author:
JSR - 268 Expert Group
| Constructor: |
public CardPermission(String terminalName,
String actions) {
super(terminalName);
if (terminalName == null) {
throw new NullPointerException();
}
mask = getMask(actions);
}
Constructs a new CardPermission with the specified actions.
terminalName is the name of a CardTerminal or *
if this permission applies to all terminals. actions
contains a comma-separated list of the individual actions
or * to signify all actions. For more information,
see the documentation at the top of this {@linkplain CardPermission
class}. Parameters:
terminalName - the name of the card terminal, or *
actions - the action string (or null if the set of permitted
actions is empty)
Throws:
NullPointerException - if terminalName is null
IllegalArgumentException - if actions is an invalid actions
specification
|
| Methods from java.lang.Object: |
|---|
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from javax.smartcardio.CardPermission Detail: |
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof CardPermission == false) {
return false;
}
CardPermission other = (CardPermission)obj;
return this.getName().equals(other.getName()) && (this.mask == other.mask);
}
Compares the specified object with this CardPermission for equality.
This CardPermission is equal to another Object object, if
and only if
object is an instance of CardPermission,
this.getName() is equal to
((CardPermission)object).getName(), and
this.getActions() is equal to
((CardPermission)object).getActions().
|
public String getActions() {
if (actions == null) {
actions = getActions(mask);
}
return actions;
}
Returns the canonical string representation of the actions.
It is * to signify all actions defined by this class or
the string concatenation of the comma-separated,
lexicographically sorted list of individual actions. |
public int hashCode() {
return getName().hashCode() + 31 * mask;
}
Returns the hash code value for this CardPermission object. |
public boolean implies(Permission permission) {
if (permission instanceof CardPermission == false) {
return false;
}
CardPermission other = (CardPermission)permission;
if ((this.mask & other.mask) != other.mask) {
return false;
}
String thisName = getName();
if (thisName.equals("*")) {
return true;
}
if (thisName.equals(other.getName())) {
return true;
}
return false;
}
Checks if this CardPermission object implies the specified permission.
That is the case, if and only if
permission is an instance of CardPermission,
permission's actions are a proper subset of this
object's actions, and
this object's getName() method is either
* or equal to permission's name.
|