org.spongycastle.asn1.esf.SPUserNotice Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scprov-jdk15 Show documentation
Show all versions of scprov-jdk15 Show documentation
Spongy Castle is a package-rename (org.bouncycastle.* to org.spongycastle.*) of Bouncy Castle intended for Android.
Android ships with a stripped-down version of Bouncy Castle - this causes classloader collisions if you try to add
an alternative (updated/complete) Bouncy Castle jar.
This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5.
package org.spongycastle.asn1.esf;
import org.spongycastle.asn1.x509.NoticeReference;
import org.spongycastle.asn1.x509.DisplayText;
import org.spongycastle.asn1.*;
import java.util.Enumeration;
public class SPUserNotice
{
private NoticeReference noticeRef;
private DisplayText explicitText;
public static SPUserNotice getInstance(
Object obj)
{
if (obj == null || obj instanceof SPUserNotice)
{
return (SPUserNotice) obj;
}
else if (obj instanceof ASN1Sequence)
{
return new SPUserNotice((ASN1Sequence) obj);
}
throw new IllegalArgumentException(
"unknown object in 'SPUserNotice' factory : "
+ obj.getClass().getName() + ".");
}
public SPUserNotice(
ASN1Sequence seq)
{
Enumeration e = seq.getObjects();
while (e.hasMoreElements())
{
DEREncodable object = (DEREncodable) e.nextElement();
if (object instanceof NoticeReference)
{
noticeRef = NoticeReference.getInstance(object);
}
else if (object instanceof DisplayText)
{
explicitText = DisplayText.getInstance(object);
}
else
{
throw new IllegalArgumentException("Invalid element in 'SPUserNotice'.");
}
}
}
public SPUserNotice(
NoticeReference noticeRef,
DisplayText explicitText)
{
this.noticeRef = noticeRef;
this.explicitText = explicitText;
}
public NoticeReference getNoticeRef()
{
return noticeRef;
}
public DisplayText getExplicitText()
{
return explicitText;
}
/**
*
* SPUserNotice ::= SEQUENCE {
* noticeRef NoticeReference OPTIONAL,
* explicitText DisplayText OPTIONAL }
*
*/
public DERObject toASN1Object()
{
ASN1EncodableVector v = new ASN1EncodableVector();
if (noticeRef != null)
{
v.add(noticeRef);
}
if (explicitText != null)
{
v.add(explicitText);
}
return new DERSequence(v);
}
}