diff options
author | Sergio Giro <sgiro@google.com> | 2016-02-01 18:54:35 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2016-02-01 18:54:35 +0000 |
commit | 3e75bd6b407dd472c834a50f16aae54cca67ea9c (patch) | |
tree | b5eb091b97b2aade28e5b45a15352125a4a776d7 /bcpkix/src/main/java/org/bouncycastle/cert/cmp/GeneralPKIMessage.java | |
parent | 9218edabd1ef9852bc2f13115dcadc81b442dd6c (diff) | |
parent | c1040cb5656c3299f1c2d0fe0bd7c44b10466aaf (diff) | |
download | android_external_bouncycastle-3e75bd6b407dd472c834a50f16aae54cca67ea9c.tar.gz android_external_bouncycastle-3e75bd6b407dd472c834a50f16aae54cca67ea9c.tar.bz2 android_external_bouncycastle-3e75bd6b407dd472c834a50f16aae54cca67ea9c.zip |
Merge "Restoring the contents of aosp after"
Diffstat (limited to 'bcpkix/src/main/java/org/bouncycastle/cert/cmp/GeneralPKIMessage.java')
-rw-r--r-- | bcpkix/src/main/java/org/bouncycastle/cert/cmp/GeneralPKIMessage.java | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/bcpkix/src/main/java/org/bouncycastle/cert/cmp/GeneralPKIMessage.java b/bcpkix/src/main/java/org/bouncycastle/cert/cmp/GeneralPKIMessage.java deleted file mode 100644 index a928623..0000000 --- a/bcpkix/src/main/java/org/bouncycastle/cert/cmp/GeneralPKIMessage.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.bouncycastle.cert.cmp; - -import java.io.IOException; - -import org.bouncycastle.asn1.ASN1Primitive; -import org.bouncycastle.asn1.cmp.PKIBody; -import org.bouncycastle.asn1.cmp.PKIHeader; -import org.bouncycastle.asn1.cmp.PKIMessage; -import org.bouncycastle.cert.CertIOException; - -/** - * General wrapper for a generic PKIMessage - */ -public class GeneralPKIMessage -{ - private final PKIMessage pkiMessage; - - private static PKIMessage parseBytes(byte[] encoding) - throws IOException - { - try - { - return PKIMessage.getInstance(ASN1Primitive.fromByteArray(encoding)); - } - catch (ClassCastException e) - { - throw new CertIOException("malformed data: " + e.getMessage(), e); - } - catch (IllegalArgumentException e) - { - throw new CertIOException("malformed data: " + e.getMessage(), e); - } - } - - /** - * Create a PKIMessage from the passed in bytes. - * - * @param encoding BER/DER encoding of the PKIMessage - * @throws IOException in the event of corrupted data, or an incorrect structure. - */ - public GeneralPKIMessage(byte[] encoding) - throws IOException - { - this(parseBytes(encoding)); - } - - /** - * Wrap a PKIMessage ASN.1 structure. - * - * @param pkiMessage base PKI message. - */ - public GeneralPKIMessage(PKIMessage pkiMessage) - { - this.pkiMessage = pkiMessage; - } - - public PKIHeader getHeader() - { - return pkiMessage.getHeader(); - } - - public PKIBody getBody() - { - return pkiMessage.getBody(); - } - - /** - * Return true if this message has protection bits on it. A return value of true - * indicates the message can be used to construct a ProtectedPKIMessage. - * - * @return true if message has protection, false otherwise. - */ - public boolean hasProtection() - { - return pkiMessage.getHeader().getProtectionAlg() != null; - } - - public PKIMessage toASN1Structure() - { - return pkiMessage; - } -} |