/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.smartcardio;
/**
* 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.
*
* <p>A CardPermission with a name of <code>*</code> applies to all
* card terminals. The actions string is a comma separated list of the actions
* listed below, or <code>*</code> to signify "all actions."
*
* <p>Individual actions are:
* <dl>
* <dt>connect
* <dd>connect to a card using
* {@linkplain CardTerminal#connect CardTerminal.connect()}
*
* <dt>reset
* <dd>reset the card using {@linkplain Card#disconnect Card.disconnect(true)}
*
* <dt>exclusive
* <dd>establish exclusive access to a card using
* {@linkplain Card#beginExclusive} and {@linkplain Card#endExclusive
* endExclusive()}
*
* <dt>transmitControl
* <dd>transmit a control command using
* {@linkplain Card#transmitControlCommand Card.transmitControlCommand()}
*
* <dt>getBasicChannel
* <dd>obtain the basic logical channel using
* {@linkplain Card#getBasicChannel}
*
* <dt>openLogicalChannel
* <dd>open a new logical channel using
* {@linkplain Card#openLogicalChannel}
*
* </dl>
*
* @since 1.6
* @author Andreas Sterbenz
* @author JSR 268 Expert Group
*/
// sum of all the actions above
private final static int[] ARRAY_MASKS = {
};
};
private transient int mask;
/**
* @serial
*/
/**
* Constructs a new CardPermission with the specified actions.
* <code>terminalName</code> is the name of a CardTerminal or <code>*</code>
* if this permission applies to all terminals. <code>actions</code>
* contains a comma-separated list of the individual actions
* or <code>*</code> to signify all actions. For more information,
* see the documentation at the top of this {@linkplain CardPermission
* class}.
*
* @param terminalName the name of the card terminal, or <code>*</code>
* @param actions the action string (or null if the set of permitted
* actions is empty)
*
* @throws NullPointerException if terminalName is null
* @throws IllegalArgumentException if actions is an invalid actions
* specification
*/
super(terminalName);
if (terminalName == null) {
throw new NullPointerException();
}
}
throw new IllegalArgumentException("actions must not be empty");
}
// try exact matches for simple actions first
if (actions == ARRAY_STRINGS[i]) {
return ARRAY_MASKS[i];
}
}
}
int mask = 0;
if (ARRAY_STRINGS[i].equalsIgnoreCase(s)) {
mask |= ARRAY_MASKS[i];
continue outer;
}
}
}
return mask;
}
return S_ALL;
}
boolean first = true;
int action = ARRAY_MASKS[i];
if (first == false) {
} else {
first = false;
}
}
}
}
/**
* Returns the canonical string representation of the actions.
* It is <code>*</code> to signify all actions defined by this class or
* the string concatenation of the comma-separated,
* lexicographically sorted list of individual actions.
*
* @return the canonical string representation of the actions.
*/
}
return actions;
}
/**
* Checks if this CardPermission object implies the specified permission.
* That is the case, if and only if
* <ul>
* <li><p><code>permission</code> is an instance of CardPermission,</p>
* <li><p><code>permission</code>'s actions are a proper subset of this
* object's actions, and</p>
* <li><p>this object's <code>getName()</code> method is either
* <code>*</code> or equal to <code>permission</code>'s <code>name</code>.
* </p>
* </ul>
*
* @param permission the permission to check against
* @return true if and only if this CardPermission object implies the
* specified permission.
*/
if (permission instanceof CardPermission == false) {
return false;
}
return false;
}
return true;
}
return true;
}
return false;
}
/**
* Compares the specified object with this CardPermission for equality.
* This CardPermission is equal to another Object <code>object</code>, if
* and only if
* <ul>
* <li><p><code>object</code> is an instance of CardPermission,</p>
* <li><p><code>this.getName()</code> is equal to
* <code>((CardPermission)object).getName()</code>, and</p>
* <li><p><code>this.getActions()</code> is equal to
* <code>((CardPermission)object).getActions()</code>.</p>
* </ul>
*
* @param obj the object to be compared for equality with this CardPermission
* @return true if and only if the specified object is equal to this
* CardPermission
*/
if (this == obj) {
return true;
}
if (obj instanceof CardPermission == false) {
return false;
}
}
/**
* Returns the hash code value for this CardPermission object.
*
* @return the hash code value for this CardPermission object.
*/
public int hashCode() {
}
// Write out the actions. The superclass takes care of the name.
// Call getActions to make sure actions field is initialized
getActions();
}
s.defaultWriteObject();
}
throws IOException, ClassNotFoundException {
// Read in the actions, then restore the mask.
s.defaultReadObject();
}
}