All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bouncycastle.asn1.x509.UserNotice Maven / Gradle / Ivy

Go to download

The FIPS 140-3 Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms certified to FIPS 140-3 level 1. This jar contains JCE provider and low-level API for the BC-FJA version 2.0.0, FIPS Certificate #4743. Please see certificate for certified platform details.

There is a newer version: 2.0.0
Show newest version
/***************************************************************/
/******    DO NOT EDIT THIS CLASS bc-java SOURCE FILE     ******/
/***************************************************************/
package org.bouncycastle.asn1.x509;

import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERSequence;

/**
 * UserNotice class, used in
 * CertificatePolicies X509 extensions (in policy
 * qualifiers).
 * 
 * UserNotice ::= SEQUENCE {
 *      noticeRef        NoticeReference OPTIONAL,
 *      explicitText     DisplayText OPTIONAL}
 *
 * 
* * @see PolicyQualifierId * @see PolicyInformation */ public class UserNotice extends ASN1Object { private final NoticeReference noticeRef; private final DisplayText explicitText; /** * Creates a new UserNotice instance. * * @param noticeRef a NoticeReference value * @param explicitText a DisplayText value */ public UserNotice( NoticeReference noticeRef, DisplayText explicitText) { this.noticeRef = noticeRef; this.explicitText = explicitText; } /** * Creates a new UserNotice instance. * * @param noticeRef a NoticeReference value * @param str the explicitText field as a String. */ public UserNotice( NoticeReference noticeRef, String str) { this(noticeRef, new DisplayText(str)); } /** * Creates a new UserNotice instance. *

Useful from reconstructing a UserNotice instance * from its encodable/encoded form. * * @param as an ASN1Sequence value obtained from either * calling @{link toASN1Primitive()} for a UserNotice * instance or from parsing it from a DER-encoded stream. */ private UserNotice( ASN1Sequence as) { if (as.size() == 2) { noticeRef = NoticeReference.getInstance(as.getObjectAt(0)); explicitText = DisplayText.getInstance(as.getObjectAt(1)); } else if (as.size() == 1) { if (as.getObjectAt(0).toASN1Primitive() instanceof ASN1Sequence) { noticeRef = NoticeReference.getInstance(as.getObjectAt(0)); explicitText = null; } else { explicitText = DisplayText.getInstance(as.getObjectAt(0)); noticeRef = null; } } else if (as.size() == 0) // neither field set! { noticeRef = null; explicitText = null; } else { throw new IllegalArgumentException("Bad sequence size: " + as.size()); } } public static UserNotice getInstance( Object obj) { if (obj instanceof UserNotice) { return (UserNotice)obj; } if (obj != null) { return new UserNotice(ASN1Sequence.getInstance(obj)); } return null; } public NoticeReference getNoticeRef() { return noticeRef; } public DisplayText getExplicitText() { return explicitText; } public ASN1Primitive toASN1Primitive() { ASN1EncodableVector av = new ASN1EncodableVector(); if (noticeRef != null) { av.add(noticeRef); } if (explicitText != null) { av.add(explicitText); } return new DERSequence(av); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy