From c53ca291e21761f1de5417ef596afba395a7f5d1 Mon Sep 17 00:00:00 2001 From: Abhishek Koneru Date: Wed, 6 Jun 2012 16:55:54 -0400 Subject: Fixes for NULL_RETURNS Coverity Issues - Part 2 --- .../netscape/certsrv/authentication/AuthToken.java | 48 ++++++++-------------- .../certsrv/authentication/IAuthToken.java | 18 +++++--- 2 files changed, 29 insertions(+), 37 deletions(-) (limited to 'base/common/src/com/netscape/certsrv/authentication') diff --git a/base/common/src/com/netscape/certsrv/authentication/AuthToken.java b/base/common/src/com/netscape/certsrv/authentication/AuthToken.java index d934f62e8..1b5bf2350 100644 --- a/base/common/src/com/netscape/certsrv/authentication/AuthToken.java +++ b/base/common/src/com/netscape/certsrv/authentication/AuthToken.java @@ -291,17 +291,13 @@ public class AuthToken implements IAuthToken { return set(name, out.toByteArray()); } - public CertificateExtensions getInCertExts(String name) { + public CertificateExtensions getInCertExts(String name) throws IOException { CertificateExtensions exts = null; byte[] data = getInByteArray(name); if (data != null) { - try { - exts = new CertificateExtensions(); - // exts.decode() doesn't work for empty CertExts - exts.decodeEx(new ByteArrayInputStream(data)); - } catch (IOException e) { - return null; - } + exts = new CertificateExtensions(); + // exts.decode() doesn't work for empty CertExts + exts.decodeEx(new ByteArrayInputStream(data)); } return exts; } @@ -321,7 +317,7 @@ public class AuthToken implements IAuthToken { return set(name, out.toByteArray()); } - public Certificates getInCertificates(String name) { + public Certificates getInCertificates(String name) throws IOException, CertificateException { X509CertImpl[] certArray; byte[] byteValue = getInByteArray(name); @@ -329,18 +325,12 @@ public class AuthToken implements IAuthToken { return null; } - try { - DerInputStream in = new DerInputStream(byteValue); - DerValue[] derValues = in.getSequence(5); - certArray = new X509CertImpl[derValues.length]; - for (int i = 0; i < derValues.length; i++) { - byte[] certData = derValues[i].toByteArray(); - certArray[i] = new X509CertImpl(certData); - } - } catch (IOException e) { - return null; - } catch (CertificateException e) { - return null; + DerInputStream in = new DerInputStream(byteValue); + DerValue[] derValues = in.getSequence(5); + certArray = new X509CertImpl[derValues.length]; + for (int i = 0; i < derValues.length; i++) { + byte[] certData = derValues[i].toByteArray(); + certArray[i] = new X509CertImpl(certData); } return new Certificates(certArray); } @@ -372,22 +362,18 @@ public class AuthToken implements IAuthToken { } } - public byte[][] getInByteArrayArray(String name) { + public byte[][] getInByteArrayArray(String name) throws IOException { byte[][] retval; byte[] byteValue = getInByteArray(name); if (byteValue == null) { return null; } - try { - DerInputStream in = new DerInputStream(byteValue); - DerValue[] derValues = in.getSequence(5); - retval = new byte[derValues.length][]; - for (int i = 0; i < derValues.length; i++) { - retval[i] = derValues[i].getOctetString(); - } - } catch (IOException e) { - return null; + DerInputStream in = new DerInputStream(byteValue); + DerValue[] derValues = in.getSequence(5); + retval = new byte[derValues.length][]; + for (int i = 0; i < derValues.length; i++) { + retval[i] = derValues[i].getOctetString(); } return retval; } diff --git a/base/common/src/com/netscape/certsrv/authentication/IAuthToken.java b/base/common/src/com/netscape/certsrv/authentication/IAuthToken.java index 25a73b8f1..e469f3786 100644 --- a/base/common/src/com/netscape/certsrv/authentication/IAuthToken.java +++ b/base/common/src/com/netscape/certsrv/authentication/IAuthToken.java @@ -17,7 +17,9 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.certsrv.authentication; +import java.io.IOException; import java.math.BigInteger; +import java.security.cert.CertificateException; import java.util.Date; import java.util.Enumeration; @@ -176,9 +178,10 @@ public interface IAuthToken { * Retrieves the CertificateExtensions value for name. * * @param name The attribute name. - * @return The value or null on error. + * @return The value. + * @throws IOException */ - public CertificateExtensions getInCertExts(String name); + public CertificateExtensions getInCertExts(String name) throws IOException; /** * Stores the CertificateExtensions with the associated key. @@ -193,9 +196,11 @@ public interface IAuthToken { * Retrieves the Certificates value for name. * * @param name The attribute name. - * @return The value or null on error. + * @return The value. + * @throws IOException + * @throws CertificateException */ - public Certificates getInCertificates(String name); + public Certificates getInCertificates(String name) throws IOException, CertificateException; /** * Stores the Certificates with the associated key. @@ -210,9 +215,10 @@ public interface IAuthToken { * Retrieves the byte[][] value for name. * * @param name The attribute name. - * @return The value or null on error. + * @return The value. + * @throws IOException */ - public byte[][] getInByteArrayArray(String name); + public byte[][] getInByteArrayArray(String name) throws IOException; /** * Stores the byte[][] with the associated key. -- cgit