本文整理汇总了Java中java.security.CryptoPrimitive类的典型用法代码示例。如果您正苦于以下问题:Java CryptoPrimitive类的具体用法?Java CryptoPrimitive怎么用?Java CryptoPrimitive使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CryptoPrimitive类属于java.security包,在下文中一共展示了CryptoPrimitive类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: permits
import java.security.CryptoPrimitive; //导入依赖的package包/类
@Override
public boolean permits(Set<CryptoPrimitive> primitives, Key key) {
boolean permitted = true;
if (peerAlgConstraints != null) {
permitted = peerAlgConstraints.permits(primitives, key);
}
if (permitted && userAlgConstraints != null) {
permitted = userAlgConstraints.permits(primitives, key);
}
if (permitted) {
permitted = tlsDisabledAlgConstraints.permits(primitives, key);
}
if (permitted && enabledX509DisabledAlgConstraints) {
permitted = x509DisabledAlgConstraints.permits(primitives, key);
}
return permitted;
}
示例2: createExtension
import java.security.CryptoPrimitive; //导入依赖的package包/类
static SupportedEllipticCurvesExtension createExtension(
AlgorithmConstraints constraints) {
ArrayList<Integer> idList = new ArrayList<>(supportedCurveIds.length);
for (int curveId : supportedCurveIds) {
if (constraints.permits(
EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
"EC", idToParams.get(curveId))) {
idList.add(curveId);
}
}
if (!idList.isEmpty()) {
int[] ids = new int[idList.size()];
int i = 0;
for (Integer id : idList) {
ids[i++] = id;
}
return new SupportedEllipticCurvesExtension(ids);
}
return null;
}
示例3: checkConstraints
import java.security.CryptoPrimitive; //导入依赖的package包/类
private boolean checkConstraints(Set<CryptoPrimitive> primitives,
String algorithm, Key key, AlgorithmParameters parameters) {
// check the key parameter, it cannot be null.
if (key == null) {
throw new IllegalArgumentException("The key cannot be null");
}
// check the signature algorithm
if (algorithm != null && algorithm.length() != 0) {
if (!permits(primitives, algorithm, parameters)) {
return false;
}
}
// check the key algorithm
if (!permits(primitives, key.getAlgorithm(), null)) {
return false;
}
// check the key constraints
return algorithmConstraints.permits(key);
}
示例4: getPreferredGroup
import java.security.CryptoPrimitive; //导入依赖的package包/类
NamedGroup getPreferredGroup(
AlgorithmConstraints constraints, NamedGroupType type) {
for (int groupId : requestedNamedGroupIds) {
NamedGroup namedGroup = NamedGroup.valueOf(groupId);
if ((namedGroup != null) && (namedGroup.type == type) &&
SupportedGroupsExtension.supports(namedGroup) &&
constraints.permits(EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
namedGroup.algorithm, namedGroupParams.get(namedGroup))) {
return namedGroup;
}
}
return null;
}
示例5: checkConstraints
import java.security.CryptoPrimitive; //导入依赖的package包/类
private boolean checkConstraints(Set<CryptoPrimitive> primitives,
String algorithm, Key key, AlgorithmParameters parameters) {
// check the key parameter, it cannot be null.
if (key == null) {
throw new IllegalArgumentException("The key cannot be null");
}
// check the signature algorithm with parameters
if (algorithm != null && algorithm.length() != 0) {
if (!permits(primitives, algorithm, parameters)) {
return false;
}
}
// check the key algorithm
if (!permits(primitives, key.getAlgorithm(), null)) {
return false;
}
// check the key constraints
return algorithmConstraints.permits(key);
}
示例6: permits
import java.security.CryptoPrimitive; //导入依赖的package包/类
public boolean permits(Set<CryptoPrimitive> primitives, Key key) {
boolean permitted = true;
if (peerAlgConstraints != null) {
permitted = peerAlgConstraints.permits(primitives, key);
}
if (permitted && userAlgConstraints != null) {
permitted = userAlgConstraints.permits(primitives, key);
}
if (permitted) {
permitted = tlsDisabledAlgConstraints.permits(primitives, key);
}
if (permitted && enabledX509DisabledAlgConstraints) {
permitted = x509DisabledAlgConstraints.permits(primitives, key);
}
return permitted;
}
示例7: permits
import java.security.CryptoPrimitive; //导入依赖的package包/类
@Override
final public boolean permits(Set<CryptoPrimitive> primitives,
String algorithm, AlgorithmParameters parameters) {
if (algorithm == null || algorithm.length() == 0) {
throw new IllegalArgumentException("No algorithm name specified");
}
if (primitives == null || primitives.isEmpty()) {
throw new IllegalArgumentException(
"No cryptographic primitive specified");
}
Set<String> elements = null;
for (String disabled : disabledAlgorithms) {
if (disabled == null || disabled.isEmpty()) {
continue;
}
// check the full name
if (disabled.equalsIgnoreCase(algorithm)) {
return false;
}
// decompose the algorithm into sub-elements
if (elements == null) {
elements = decomposes(algorithm);
}
// check the items of the algorithm
for (String element : elements) {
if (disabled.equalsIgnoreCase(element)) {
return false;
}
}
}
return true;
}
示例8: checkConstraints
import java.security.CryptoPrimitive; //导入依赖的package包/类
private boolean checkConstraints(Set<CryptoPrimitive> primitives,
String algorithm, Key key, AlgorithmParameters parameters) {
// check the key parameter, it cannot be null.
if (key == null) {
throw new IllegalArgumentException("The key cannot be null");
}
// check the target algorithm
if (algorithm != null && algorithm.length() != 0) {
if (!permits(primitives, algorithm, parameters)) {
return false;
}
}
// check the key algorithm
if (!permits(primitives, key.getAlgorithm(), null)) {
return false;
}
// check the key constraints
if (keySizeConstraints.disables(key)) {
return false;
}
return true;
}
示例9: getPreferredCurve
import java.security.CryptoPrimitive; //导入依赖的package包/类
private static int getPreferredCurve(int[] curves,
AlgorithmConstraints constraints) {
for (int curveId : curves) {
if (isSupported(curveId) && constraints.permits(
EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
"EC", idToParams.get(curveId))) {
return curveId;
}
}
return -1;
}
示例10: permits
import java.security.CryptoPrimitive; //导入依赖的package包/类
@Override
final public boolean permits(Set<CryptoPrimitive> primitives,
String algorithm, AlgorithmParameters parameters) {
if (primitives == null || primitives.isEmpty()) {
throw new IllegalArgumentException(
"No cryptographic primitive specified");
}
return checkAlgorithm(disabledAlgorithms, algorithm, decomposer);
}
示例11: getPreferredECGroup
import java.security.CryptoPrimitive; //导入依赖的package包/类
static NamedGroup getPreferredECGroup(AlgorithmConstraints constraints) {
for (NamedGroup namedGroup : supportedNamedGroups) {
if ((namedGroup.type == NamedGroupType.NAMED_GROUP_ECDHE) &&
constraints.permits(EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
namedGroup.algorithm, namedGroupParams.get(namedGroup))) {
return namedGroup;
}
}
return null;
}
示例12: isActivatable
import java.security.CryptoPrimitive; //导入依赖的package包/类
static boolean isActivatable(
AlgorithmConstraints constraints, NamedGroupType type) {
boolean hasFFDHEGroups = false;
for (NamedGroup namedGroup : supportedNamedGroups) {
if (namedGroup.type == type) {
if (constraints.permits(
EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
namedGroup.algorithm,
namedGroupParams.get(namedGroup))) {
return true;
}
if (!hasFFDHEGroups &&
(type == NamedGroupType.NAMED_GROUP_FFDHE)) {
hasFFDHEGroups = true;
}
}
}
// For compatibility, if no FFDHE groups are defined, the non-FFDHE
// compatible mode (using DHE cipher suite without FFDHE extension)
// is allowed.
//
// Note that the constraints checking on DHE parameters will be
// performed during key exchanging in a handshake.
if (!hasFFDHEGroups && (type == NamedGroupType.NAMED_GROUP_FFDHE)) {
return true;
}
return false;
}