8282220: contentType should not be a PKCS7's member

Reviewed-by: xuelei
This commit is contained in:
John Jiang 2022-02-22 09:35:48 +00:00
parent bc43320fd3
commit b95310b090

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -53,8 +53,6 @@ import sun.security.x509.*;
*/ */
public class PKCS7 { public class PKCS7 {
private ObjectIdentifier contentType;
// the ASN.1 members for a signedData (and other) contentTypes // the ASN.1 members for a signedData (and other) contentTypes
private BigInteger version = null; private BigInteger version = null;
private AlgorithmId[] digestAlgorithmIds = null; private AlgorithmId[] digestAlgorithmIds = null;
@ -167,7 +165,7 @@ public class PKCS7 {
throws IOException throws IOException
{ {
ContentInfo block = new ContentInfo(derin, oldStyle); ContentInfo block = new ContentInfo(derin, oldStyle);
contentType = block.contentType; ObjectIdentifier contentType = block.contentType;
DerValue content = block.getContent(); DerValue content = block.getContent();
if (contentType.equals(ContentInfo.SIGNED_DATA_OID)) { if (contentType.equals(ContentInfo.SIGNED_DATA_OID)) {
@ -240,14 +238,10 @@ public class PKCS7 {
bais.close(); bais.close();
bais = null; bais = null;
} }
} catch (CertificateException ce) { } catch (CertificateException | IOException ce) {
ParsingException pe = new ParsingException(ce.getMessage()); ParsingException pe = new ParsingException(ce.getMessage());
pe.initCause(ce); pe.initCause(ce);
throw pe; throw pe;
} catch (IOException ioe) {
ParsingException pe = new ParsingException(ioe.getMessage());
pe.initCause(ioe);
throw pe;
} finally { } finally {
if (bais != null) if (bais != null)
bais.close(); bais.close();
@ -330,14 +324,10 @@ public class PKCS7 {
} }
count++; count++;
} }
} catch (CertificateException ce) { } catch (CertificateException | IOException ce) {
ParsingException pe = new ParsingException(ce.getMessage()); ParsingException pe = new ParsingException(ce.getMessage());
pe.initCause(ce); pe.initCause(ce);
throw pe; throw pe;
} catch (IOException ioe) {
ParsingException pe = new ParsingException(ioe.getMessage());
pe.initCause(ioe);
throw pe;
} finally { } finally {
if (bais != null) if (bais != null)
bais.close(); bais.close();
@ -444,14 +434,10 @@ public class PKCS7 {
bais.close(); bais.close();
bais = null; bais = null;
} }
} catch (CertificateException ce) { } catch (CertificateException | IOException ce) {
ParsingException pe = new ParsingException(ce.getMessage()); ParsingException pe = new ParsingException(ce.getMessage());
pe.initCause(ce); pe.initCause(ce);
throw pe; throw pe;
} catch (IOException ioe) {
ParsingException pe = new ParsingException(ioe.getMessage());
pe.initCause(ioe);
throw pe;
} finally { } finally {
if (bais != null) if (bais != null)
bais.close(); bais.close();