APIdia Launch Partner
Top Description Fields Constructors Methods
javax.crypto

pack-priv Class CryptoPermission

Additional top-level class in compilation unit: CryptoPermissionCollection.

extends Permission
Class Inheritance
Known Direct Subclasses
javax.crypto.CryptoAllPermission
Imports
java.io.Serial, .Serializable, java.security.*, java.security.spec.AlgorithmParameterSpec, java.util.Enumeration, .Objects, .Vector, javax.crypto.spec.*

The CryptoPermission class extends the java.security.Permission class. A CryptoPermission object is used to represent the ability of an application to use certain algorithms with certain key sizes and other restrictions in certain environments.
Authors
Jan Luehe, Sharon Liu
Since
1.4
See Also
java.security.Permission

Field Summary

Modifier and TypeField and Description
private final String
pack-priv static final String
private AlgorithmParameterSpec
private boolean
private String
private int
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv
CryptoPermission(String
the algorithm name.
alg
)

Constructor that takes an algorithm name.

pack-priv
CryptoPermission(String
the algorithm name.
alg
,
int
the maximum allowable key size, specified in number of bits.
maxKeySize
)

Constructor that takes an algorithm name and a maximum key size.

pack-priv
CryptoPermission(String
the algorithm name.
alg
,
int
the maximum allowable key size, specified in number of bits.
maxKeySize
,
AlgorithmParameterSpec
the limits for allowable algorithm parameters.
algParamSpec
)

Constructor that takes an algorithm name, a maximum key size, and an AlgorithmParameterSpec object.

pack-priv
CryptoPermission(String
the algorithm name.
alg
,
String
the name of the exemption mechanism.
exemptionMechanism
)

Constructor that takes an algorithm name and the name of an exemption mechanism.

pack-priv
CryptoPermission(String
the algorithm name.
alg
,
int
the maximum allowable key size, specified in number of bits.
maxKeySize
,
String
the name of the exemption mechanism.
exemptionMechanism
)

Constructor that takes an algorithm name, a maximum key size, and the name of an exemption mechanism.

pack-priv
CryptoPermission(String
the algorithm name.
alg
,
int
the maximum allowable key size, specified in number of bits.
maxKeySize
,
AlgorithmParameterSpec
the limit for allowable algorithm parameter spec.
algParamSpec
,
String
the name of the exemption mechanism.
exemptionMechanism
)

Constructor that takes an algorithm name, a maximum key size, the name of an exemption mechanism, and an AlgorithmParameterSpec object.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if obj is equal to this object.
equals
(Object
the object to test for equality with this object.
obj
)

Implements abstract java.security.Permission.equals.

Checks two CryptoPermission objects for equality.

public String
getActions()

Implements abstract java.security.Permission.getActions.

There is no action defined for a CryptoPermission object.

pack-priv final String
getAlgorithm()

Returns the algorithm name associated with this CryptoPermission object.

pack-priv final AlgorithmParameterSpec
getAlgorithmParameterSpec()

Returns the AlgorithmParameterSpec associated with this CryptoPermission object.

pack-priv final boolean
getCheckParam()

Returns true if there is a limitation on the AlgorithmParameterSpec associated with this CryptoPermission object and false if otherwise.

pack-priv final String
getExemptionMechanism()

Returns the exemption mechanism name associated with this CryptoPermission object.

pack-priv final int
getMaxKeySize()

Returns the maximum allowable key size associated with this CryptoPermission object.

public int

Returns:

the hash code value for this object
hashCode
()

Implements abstract java.security.Permission.hashCode.

Returns the hash code value for this object.

public boolean

Returns:

true if the specified permission is equal to or implied by this permission, false otherwise.
implies
(Permission
the permission to check against.
p
)

Implements abstract java.security.Permission.implies.

Checks if the specified permission is "implied" by this object.

private boolean
impliesExemptionMechanism(String exemptionMechanism)

private boolean
impliesParameterSpec(boolean checkParam, AlgorithmParameterSpec algParamSpec)

public PermissionCollection

Returns:

a new PermissionCollection object suitable for storing CryptoPermissions.
newPermissionCollection
()

Overrides java.security.Permission.newPermissionCollection.

Returns a new PermissionCollection object for storing CryptoPermission objects.

public String

Returns:

information about this CryptoPermission object.
toString
()

Overrides java.security.Permission.toString.

Returns a string describing this CryptoPermission object.

Inherited from java.security.Permission:
checkGuardgetName

Field Detail

algback to summary
private final String alg
ALG_NAME_WILDCARDback to summary
pack-priv static final String ALG_NAME_WILDCARD
algParamSpecback to summary
private AlgorithmParameterSpec algParamSpec
Annotations
@SuppressWarnings:serial
checkParamback to summary
private boolean checkParam
exemptionMechanismback to summary
private String exemptionMechanism
maxKeySizeback to summary
private int maxKeySize
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.security.Permission.serialVersionUID.

Annotations
@Serial

Constructor Detail

CryptoPermissionback to summary
pack-priv CryptoPermission(String alg)

Constructor that takes an algorithm name. This constructor implies that the given algorithm can be used without any restrictions.

Parameters
alg:String

the algorithm name.

CryptoPermissionback to summary
pack-priv CryptoPermission(String alg, int 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:String

the algorithm name.

maxKeySize:int

the maximum allowable key size, specified in number of bits.

CryptoPermissionback to summary
pack-priv CryptoPermission(String alg, int maxKeySize, AlgorithmParameterSpec 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:String

the algorithm name.

maxKeySize:int

the maximum allowable key size, specified in number of bits.

algParamSpec:AlgorithmParameterSpec

the limits for allowable algorithm parameters.

CryptoPermissionback to summary
pack-priv CryptoPermission(String alg, String 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:String

the algorithm name.

exemptionMechanism:String

the name of the exemption mechanism.

CryptoPermissionback to summary
pack-priv CryptoPermission(String alg, int maxKeySize, String exemptionMechanism)

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:String

the algorithm name.

maxKeySize:int

the maximum allowable key size, specified in number of bits.

exemptionMechanism:String

the name of the exemption mechanism.

CryptoPermissionback to summary
pack-priv CryptoPermission(String alg, int maxKeySize, AlgorithmParameterSpec algParamSpec, String exemptionMechanism)

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:String

the algorithm name.

maxKeySize:int

the maximum allowable key size, specified in number of bits.

algParamSpec:AlgorithmParameterSpec

the limit for allowable algorithm parameter spec.

exemptionMechanism:String

the name of the exemption mechanism.

Method Detail

equalsback to summary
public boolean equals(Object obj)

Implements abstract java.security.Permission.equals.

Checks two CryptoPermission objects for equality. Checks that obj is a CryptoPermission object, and has the same algorithm name, exemption mechanism name, maximum allowable key size and algorithm parameter spec as this object.

Parameters
obj:Object

the object to test for equality with this object.

Returns:boolean

true if obj is equal to this object.

Annotations
@Override
getActionsback to summary
public String getActions()

Implements abstract java.security.Permission.getActions.

There is no action defined for a CryptoPermission object.

getAlgorithmback to summary
pack-priv final String getAlgorithm()

Returns the algorithm name associated with this CryptoPermission object.

getAlgorithmParameterSpecback to summary
pack-priv final AlgorithmParameterSpec getAlgorithmParameterSpec()

Returns the AlgorithmParameterSpec associated with this CryptoPermission object.

getCheckParamback to summary
pack-priv final boolean getCheckParam()

Returns true if there is a limitation on the AlgorithmParameterSpec associated with this CryptoPermission object and false if otherwise.

getExemptionMechanismback to summary
pack-priv final String getExemptionMechanism()

Returns the exemption mechanism name associated with this CryptoPermission object.

getMaxKeySizeback to summary
pack-priv final int getMaxKeySize()

Returns the maximum allowable key size associated with this CryptoPermission object.

hashCodeback to summary
public int hashCode()

Implements abstract java.security.Permission.hashCode.

Returns the hash code value for this object.

Returns:int

the hash code value for this object

Annotations
@Override
impliesback to summary
public boolean implies(Permission p)

Implements abstract java.security.Permission.implies.

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).
Parameters
p:Permission

the permission to check against.

Returns:boolean

true if the specified permission is equal to or implied by this permission, false otherwise.

impliesExemptionMechanismback to summary
private boolean impliesExemptionMechanism(String exemptionMechanism)
impliesParameterSpecback to summary
private boolean impliesParameterSpec(boolean checkParam, AlgorithmParameterSpec algParamSpec)
newPermissionCollectionback to summary
public PermissionCollection newPermissionCollection()

Overrides java.security.Permission.newPermissionCollection.

Returns a new PermissionCollection object for storing CryptoPermission objects.

Returns:PermissionCollection

a new PermissionCollection object suitable for storing CryptoPermissions.

toStringback to summary
public String toString()

Overrides java.security.Permission.toString.

Returns a string describing this CryptoPermission object. 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")'.

Returns:String

information about this CryptoPermission object.