Java Code Examples for org.bouncycastle.asn1.ASN1Integer#getInstance()
The following examples show how to use
org.bouncycastle.asn1.ASN1Integer#getInstance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SSDManager.java From snowflake-jdbc with Apache License 2.0 | 6 votes |
SFTrustManager.OcspResponseCacheKey getWildCardCertId() { DigestCalculator digest = new SFTrustManager.SHA1DigestCalculator(); AlgorithmIdentifier algo = digest.getAlgorithmIdentifier(); ASN1OctetString nameHash = ASN1OctetString.getInstance("0"); ASN1OctetString keyHash = ASN1OctetString.getInstance("0"); ASN1Integer serial_number = ASN1Integer.getInstance(0); CertID cid = new CertID(algo, nameHash, keyHash, serial_number); SFTrustManager.OcspResponseCacheKey keyOcspResp = null; try { keyOcspResp = new SFTrustManager.OcspResponseCacheKey( ASN1OctetString.getInstance("0").getEncoded(), ASN1OctetString.getInstance("0").getEncoded(), ASN1Integer.getInstance(0).getValue()); } catch (Throwable ex) { LOGGER.debug("Could not create wildcard certid as cache key"); keyOcspResp = null; } return keyOcspResp; }
Example 2
Source File: X509Ext.java From keystore-explorer with GNU General Public License v3.0 | 6 votes |
private String getMsCaVersionStringValue(byte[] octets) { /* "The extension data is a DWORD value (encoded as X509_INTEGER in the extension); the low 16 bits are the certificate index, and the high 16 bits are the key index." */ ASN1Integer asn1Integer = ASN1Integer.getInstance(octets); int version = asn1Integer.getValue().intValue(); String certIndex = String.valueOf(version & 0xffff); String keyIndex = String.valueOf(version >> 16); StringBuilder sb = new StringBuilder(); sb.append(MessageFormat.format(res.getString("MSCaVersion.CertIndex"), certIndex)); sb.append(NEWLINE); sb.append(MessageFormat.format(res.getString("MSCaVersion.KeyIndex"), keyIndex)); sb.append(NEWLINE); return sb.toString(); }
Example 3
Source File: ExtensionsChecker.java From xipki with Apache License 2.0 | 5 votes |
private void checkExtnTlsFeature(StringBuilder failureMsg, byte[] extensionValue, Extensions requestedExtns, ExtensionControl extControl) { TlsFeature conf = tlsFeature; if (tlsFeature == null) { checkConstantExtnValue(Extn.id_pe_tlsfeature, failureMsg, extensionValue, requestedExtns, extControl); return; } Set<String> isFeatures = new HashSet<>(); ASN1Sequence seq = ASN1Sequence.getInstance(extensionValue); final int n = seq.size(); for (int i = 0; i < n; i++) { ASN1Integer asn1Feature = ASN1Integer.getInstance(seq.getObjectAt(i)); isFeatures.add(asn1Feature.getPositiveValue().toString()); } Set<String> expFeatures = new HashSet<>(); for (DescribableInt m : conf.getFeatures()) { expFeatures.add(Integer.toString(m.getValue())); } Set<String> diffs = strInBnotInA(expFeatures, isFeatures); if (CollectionUtil.isNotEmpty(diffs)) { failureMsg.append("features ").append(diffs).append(" are present but not expected; "); } diffs = strInBnotInA(isFeatures, expFeatures); if (CollectionUtil.isNotEmpty(diffs)) { failureMsg.append("features ").append(diffs).append(" are absent but are required; "); } }
Example 4
Source File: ExtensionsChecker.java From xipki with Apache License 2.0 | 5 votes |
private void checkExtnInhibitAnyPolicy(StringBuilder failureMsg, byte[] extensionValue, Extensions requestedExtns, ExtensionControl extControl) { InhibitAnyPolicy conf = inhibitAnyPolicy; if (conf == null) { checkConstantExtnValue(Extension.inhibitAnyPolicy, failureMsg, extensionValue, requestedExtns, extControl); return; } ASN1Integer asn1Int = ASN1Integer.getInstance(extensionValue); int isSkipCerts = asn1Int.getPositiveValue().intValue(); if (isSkipCerts != conf.getSkipCerts()) { addViolation(failureMsg, "skipCerts", isSkipCerts, conf.getSkipCerts()); } }
Example 5
Source File: ExtensionSyntaxChecker.java From xipki with Apache License 2.0 | 4 votes |
private static ASN1Encodable getParsedImplicitValue(String name, ASN1TaggedObject taggedObject, FieldType fieldType) throws BadCertTemplateException { try { switch (fieldType) { case BIT_STRING: return DERBitString.getInstance(taggedObject, false); case BMPString: return DERBMPString.getInstance(taggedObject, false); case BOOLEAN: return ASN1Boolean.getInstance(taggedObject, false); case ENUMERATED: return ASN1Enumerated.getInstance(taggedObject, false); case GeneralizedTime: return DERGeneralizedTime.getInstance(taggedObject, false); case IA5String: return DERIA5String.getInstance(taggedObject, false); case INTEGER: return ASN1Integer.getInstance(taggedObject, false); case Name: return X500Name.getInstance(taggedObject, false); case NULL: if (!(taggedObject.getObject() instanceof ASN1OctetString && ((ASN1OctetString) taggedObject.getObject()).getOctets().length == 0)) { throw new BadCertTemplateException("invalid " + name); } return DERNull.INSTANCE; case OCTET_STRING: return DEROctetString.getInstance(taggedObject, false); case OID: return ASN1ObjectIdentifier.getInstance(taggedObject, false); case PrintableString: return DERPrintableString.getInstance(taggedObject, false); case RAW: return taggedObject.getObject(); case SEQUENCE: case SEQUENCE_OF: return ASN1Sequence.getInstance(taggedObject, false); case SET: case SET_OF: return ASN1Set.getInstance(taggedObject, false); case TeletexString: return DERT61String.getInstance(taggedObject, false); case UTCTime: return DERUTCTime.getInstance(taggedObject, false); case UTF8String: return DERUTF8String.getInstance(taggedObject, false); default: throw new RuntimeException("Unknown FieldType " + fieldType); } } catch (IllegalArgumentException ex) { throw new BadCertTemplateException("invalid " + name, ex); } }