Red Hat Application Migration Toolkit
package iaik.pkcs.pkcs7;
import iaik.asn1.ASN1Object;
import iaik.asn1.CON_SPEC;
import iaik.asn1.DerCoder;
import iaik.asn1.DerInputStream;
import iaik.asn1.ObjectID;
import iaik.asn1.SEQUENCE;
import iaik.pkcs.PKCSException;
import iaik.pkcs.PKCSParsingException;
import iaik.pkcs.pkcs7.ContentStream;
import iaik.pkcs.pkcs7.c;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class ContentInfoStream {
// $FF: synthetic field
static Class l;
// $FF: synthetic field
static Class i;
// $FF: synthetic field
static Class g;
// $FF: synthetic field
static Class h;
// $FF: synthetic field
static Class f;
// $FF: synthetic field
static Class j;
// $FF: synthetic field
static Class k;
boolean a = false;
DerInputStream e;
ContentStream d;
ObjectID c;
private static c b = new c();
static Class a(String var0) {
try {
return Class.forName(var0);
} catch (ClassNotFoundException var2) {
throw new NoClassDefFoundError(var2.getMessage());
}
}
public void writeTo(OutputStream var1) throws PKCSException, IOException {
DerCoder.encodeTo(this.toASN1Object(), var1);
}
public String toString(boolean var1) {
StringBuffer var2 = new StringBuffer();
var2.append("ContentType: " + this.c.getName() + " {\n");
if(this.d == null) {
var2.append("No content!\n");
} else {
var2.append(this.d.toString(var1) + "\n}");
}
return var2.toString();
}
public String toString() {
return this.toString(false);
}
public ASN1Object toASN1Object() throws PKCSException {
if(this.c == null) {
throw new PKCSException("Cannot create ASN.1 object. At least the content type must be set!");
} else {
SEQUENCE var1 = new SEQUENCE(true);
var1.addComponent(this.c);
if(!this.a) {
try {
this.a();
} catch (IOException var3) {
throw new PKCSException(var3.getMessage());
}
}
if(this.d != null) {
CON_SPEC var2 = new CON_SPEC(0, this.d.toASN1Object());
var2.setIndefiniteLength(true);
var1.addComponent(var2);
}
return var1;
}
}
public void setContent(ContentStream var1) {
this.c = var1.getContentType();
this.d = var1;
}
public static void register(ObjectID var0, Class var1) {
b.register(l != null?l:(l = a("iaik.pkcs.pkcs7.ContentStream")), var0, var1);
}
public boolean hasContent() {
return this.d != null || this.e != null;
}
public ObjectID getContentType() {
return this.c;
}
public InputStream getContentInputStream() {
this.a = true;
return this.e;
}
public ContentStream getContent() throws PKCSParsingException, IOException {
if(this.d != null) {
return this.d;
} else {
this.a();
return this.d;
}
}
public void destroyCriticalData() {
}
private void a() throws PKCSParsingException, IOException {
if(this.e != null) {
try {
this.d = create(this.c);
} catch (PKCSException var2) {
throw new PKCSParsingException(var2.getMessage());
}
this.d.decode(this.e);
this.a = true;
}
}
protected void decode(DerInputStream var1) throws PKCSParsingException, IOException {
DerInputStream var2 = var1.readSequence();
this.c = var2.readObjectID();
if(var2.nextTag() == -1) {
this.d = null;
} else {
this.e = var2.readContextSpecific();
}
}
public static ContentStream create(ObjectID var0, InputStream var1) throws PKCSParsingException, IOException {
try {
ContentStream var2 = create(var0);
var2.decode(var1);
return var2;
} catch (PKCSException var3) {
throw new PKCSParsingException(var3.getMessage());
}
}
public static ContentStream create(ObjectID var0) throws PKCSException {
try {
return (ContentStream)b.create(l != null?l:(l = a("iaik.pkcs.pkcs7.ContentStream")), var0, false);
} catch (InstantiationException var1) {
throw new PKCSException("No PKCS#7 type registered for the given object ID!");
}
}
public ContentInfoStream(InputStream var1) throws PKCSParsingException, IOException {
if(var1 instanceof DerInputStream) {
this.decode((DerInputStream)var1);
} else {
this.decode(new DerInputStream(var1));
}
}
public ContentInfoStream(ContentStream var1) {
this.c = var1.getContentType();
this.d = var1;
}
public ContentInfoStream(ObjectID var1) {
this.c = var1;
this.d = null;
}
private ContentInfoStream() {
}
static {
register(ObjectID.pkcs7_data, k != null?k:(k = a("iaik.pkcs.pkcs7.DataStream")));
register(ObjectID.pkcs7_digestedData, j != null?j:(j = a("iaik.pkcs.pkcs7.DigestedDataStream")));
register(ObjectID.pkcs7_signedData, f != null?f:(f = a("iaik.pkcs.pkcs7.SignedDataStream")));
register(ObjectID.pkcs7_envelopedData, h != null?h:(h = a("iaik.pkcs.pkcs7.EnvelopedDataStream")));
register(ObjectID.pkcs7_signedAndEnvelopedData, g != null?g:(g = a("iaik.pkcs.pkcs7.SignedAndEnvelopedDataStream")));
register(ObjectID.pkcs7_encryptedData, i != null?i:(i = a("iaik.pkcs.pkcs7.EncryptedDataStream")));
}
}