| Constructor: |
CryptoPermission(String alg) {
super(null);
this.alg = alg;
}
Constructor that takes an algorithm name.
This constructor implies that the given algorithm can be
used without any restrictions. Parameters:
alg - the algorithm name.
|
CryptoPermission(String alg,
int maxKeySize) {
super(null);
this.alg = alg;
this.maxKeySize = maxKeySize;
}
Constructor that takes an algorithm name and a maximum
key size.
This constructor implies that the given algorithm can be
used with a key size up to maxKeySize. Parameters:
alg - the algorithm name.
maxKeySize - the maximum allowable key size,
specified in number of bits.
|
CryptoPermission(String alg,
String exemptionMechanism) {
super(null);
this.alg = alg;
this.exemptionMechanism = exemptionMechanism;
}
Constructor that takes an algorithm name and the name of
an exemption mechanism.
This constructor implies that the given algorithm can be
used without any key size or algorithm parameter restrictions
provided that the specified exemption mechanism is enforced. Parameters:
alg - the algorithm name.
exemptionMechanism - the name of the exemption mechanism.
|
CryptoPermission(String alg,
int maxKeySize,
AlgorithmParameterSpec algParamSpec) {
super(null);
this.alg = alg;
this.maxKeySize = maxKeySize;
this.checkParam = true;
this.algParamSpec = algParamSpec;
}
Constructor that takes an algorithm name, a maximum
key size, and an AlgorithmParameterSpec object.
This constructor implies that the given algorithm can be
used with a key size up to maxKeySize, and
algorithm
parameters up to the limits set in algParamSpec. Parameters:
alg - the algorithm name.
maxKeySize - the maximum allowable key size,
specified in number of bits.
algParamSpec - the limits for allowable algorithm
parameters.
|
CryptoPermission(String alg,
int maxKeySize,
String exemptionMechanism) {
super(null);
this.alg = alg;
this.exemptionMechanism = exemptionMechanism;
this.maxKeySize = maxKeySize;
}
Constructor that takes an algorithm name, a maximum key
size, and the name of an exemption mechanism.
This constructor implies that the given algorithm can be
used with a key size up to maxKeySize
provided that the
specified exemption mechanism is enforced. Parameters:
alg - the algorithm name.
maxKeySize - the maximum allowable key size,
specified in number of bits.
exemptionMechanism - the name of the exemption
mechanism.
|
CryptoPermission(String alg,
int maxKeySize,
AlgorithmParameterSpec algParamSpec,
String exemptionMechanism) {
super(null);
this.alg = alg;
this.exemptionMechanism = exemptionMechanism;
this.maxKeySize = maxKeySize;
this.checkParam = true;
this.algParamSpec = algParamSpec;
}
Constructor that takes an algorithm name, a maximum key
size, the name of an exemption mechanism, and an
AlgorithmParameterSpec object.
This constructor implies that the given algorithm can be
used with a key size up to maxKeySize
and algorithm
parameters up to the limits set in algParamSpec
provided that
the specified exemption mechanism is enforced. Parameters:
alg - the algorithm name.
maxKeySize - the maximum allowable key size,
specified in number of bits.
algParamSpec - the limit for allowable algorithm
parameter spec.
exemptionMechanism - the name of the exemption
mechanism.
|
| Method from javax.crypto.CryptoPermission Detail: |
public boolean equals(Object obj) {
if (obj == this)
return true;
if (!(obj instanceof CryptoPermission))
return false;
CryptoPermission that = (CryptoPermission) obj;
if (!(alg.equalsIgnoreCase(that.alg)) ||
(maxKeySize != that.maxKeySize)) {
return false;
}
if (this.checkParam != that.checkParam) {
return false;
}
return (equalObjects(this.exemptionMechanism,
that.exemptionMechanism) &&
equalObjects(this.algParamSpec,
that.algParamSpec));
}
Checks two CryptoPermission objects for equality. Checks that
obj is a CryptoPermission, and has the same
algorithm name,
exemption mechanism name, maximum allowable key size and
algorithm parameter spec
as this object.
|
public String getActions() {
return null;
}
There is no action defined for a CryptoPermission
onject. |
final String getAlgorithm() {
return alg;
}
Returns the algorithm name associated with
this CryptoPermission object. |
final AlgorithmParameterSpec getAlgorithmParameterSpec() {
return algParamSpec;
}
Returns the AlgorithmParameterSpec
associated with this CryptoPermission
object. |
final boolean getCheckParam() {
return checkParam;
}
Returns true if there is a limitation on the
AlgorithmParameterSpec associated with this
CryptoPermission object and false if otherwise. |
final String getExemptionMechanism() {
return exemptionMechanism;
}
Returns the exemption mechanism name
associated with this CryptoPermission
object. |
final int getMaxKeySize() {
return maxKeySize;
}
Returns the maximum allowable key size associated
with this CryptoPermission object. |
public int hashCode() {
int retval = alg.hashCode();
retval ^= maxKeySize;
if (exemptionMechanism != null) {
retval ^= exemptionMechanism.hashCode();
}
if (checkParam) retval ^= 100;
if (algParamSpec != null) {
retval ^= algParamSpec.hashCode();
}
return retval;
}
Returns the hash code value for this object. |
public boolean implies(Permission p) {
if (!(p instanceof CryptoPermission))
return false;
CryptoPermission cp = (CryptoPermission)p;
if ((!alg.equalsIgnoreCase(cp.alg)) &&
(!alg.equalsIgnoreCase(ALG_NAME_WILDCARD))) {
return false;
}
// alg is the same as cp's alg or
// alg is a wildcard.
if (cp.maxKeySize < = this.maxKeySize) {
// check algParamSpec.
if (!impliesParameterSpec(cp.checkParam, cp.algParamSpec)) {
return false;
}
// check exemptionMechanism.
if (impliesExemptionMechanism(cp.exemptionMechanism)) {
return true;
}
}
return false;
}
Checks if the specified permission is "implied" by
this object.
More specifically, this method returns true if:
- p is an instance of CryptoPermission, and
- p's algorithm name equals or (in the case of wildcards)
is implied by this permission's algorithm name, and
- p's maximum allowable key size is less or
equal to this permission's maximum allowable key size, and
- p's algorithm parameter spec equals or is
implied by this permission's algorithm parameter spec, and
- p's exemptionMechanism equals or
is implied by this permission's
exemptionMechanism (a
null exemption mechanism
implies any other exemption mechanism).
|
public PermissionCollection newPermissionCollection() {
return new CryptoPermissionCollection();
}
Returns a new PermissionCollection object for storing
CryptoPermission objects. |
public String toString() {
StringBuilder buf = new StringBuilder(100);
buf.append("(CryptoPermission " + alg + " " + maxKeySize);
if (algParamSpec != null) {
if (algParamSpec instanceof RC2ParameterSpec) {
buf.append(" , effective " +
((RC2ParameterSpec)algParamSpec).getEffectiveKeyBits());
} else if (algParamSpec instanceof RC5ParameterSpec) {
buf.append(" , rounds " +
((RC5ParameterSpec)algParamSpec).getRounds());
}
}
if (exemptionMechanism != null) { // OPTIONAL
buf.append(" " + exemptionMechanism);
}
buf.append(")");
return buf.toString();
}
Returns a string describing this CryptoPermission. The convention is to
specify the class name, the algorithm name, the maximum allowable
key size, and the name of the exemption mechanism, in the following
format: '("ClassName" "algorithm" "keysize" "exemption_mechanism")'. |