diff options
author | Ade Lee <alee@redhat.com> | 2011-12-08 21:15:59 -0500 |
---|---|---|
committer | Ade Lee <alee@redhat.com> | 2011-12-08 21:15:59 -0500 |
commit | 171aaece4f23709d33d180cf36eb3af5e454b0c9 (patch) | |
tree | 1485f9f0a7bd10de4ff25030db575dbb8dafae74 /pki/base/util/src/netscape/security/x509/IA5StringConverter.java | |
parent | adad2fcee8a29fdb82376fbce07dedb11fccc182 (diff) | |
download | pki-171aaece4f23709d33d180cf36eb3af5e454b0c9.tar.gz pki-171aaece4f23709d33d180cf36eb3af5e454b0c9.tar.xz pki-171aaece4f23709d33d180cf36eb3af5e454b0c9.zip |
Revert "Formatting"
This reverts commit 32150d3ee32f8ac27118af7c792794b538c78a2f.
Diffstat (limited to 'pki/base/util/src/netscape/security/x509/IA5StringConverter.java')
-rw-r--r-- | pki/base/util/src/netscape/security/x509/IA5StringConverter.java | 137 |
1 files changed, 74 insertions, 63 deletions
diff --git a/pki/base/util/src/netscape/security/x509/IA5StringConverter.java b/pki/base/util/src/netscape/security/x509/IA5StringConverter.java index c7ad58fed..f3fa50da0 100644 --- a/pki/base/util/src/netscape/security/x509/IA5StringConverter.java +++ b/pki/base/util/src/netscape/security/x509/IA5StringConverter.java @@ -24,98 +24,109 @@ import netscape.security.util.DerValue; import sun.io.CharToByteConverter; /** - * A AVAValueConverter that converts a IA5String attribute to a DerValue and - * vice versa. An example an attribute that is a IA5String string is "E". - * + * A AVAValueConverter that converts a IA5String attribute to a DerValue + * and vice versa. An example an attribute that is a IA5String string is "E". * @see AVAValueConverter - * + * * @author Lily Hsiao, Slava Galperin at Netscape Communications, Inc. */ -public class IA5StringConverter implements AVAValueConverter { - // public constructors +public class IA5StringConverter implements AVAValueConverter +{ + // public constructors - /* + /* * Contructs a IA5String Converter. */ - public IA5StringConverter() { - } + public IA5StringConverter() + { + } /* * Converts a string with ASN.1 IA5String characters to a DerValue. * - * @param valueString a string with IA5String characters. + * @param valueString a string with IA5String characters. * - * @return a DerValue. + * @return a DerValue. * - * @exception IOException if a IA5String CharToByteConverter is not - * available for the conversion. + * @exception IOException if a IA5String CharToByteConverter is not + * available for the conversion. */ - public DerValue getValue(String valueString) throws IOException { - return getValue(valueString, null); + public DerValue getValue(String valueString) + throws IOException + { + return getValue(valueString, null); } public DerValue getValue(String valueString, byte[] encodingOrder) - throws IOException { - ASN1CharStrConvMap map; - CharToByteConverter cbc; - byte[] bbuf = new byte[valueString.length()]; - map = ASN1CharStrConvMap.getDefault(); - try { - cbc = map.getCBC(DerValue.tag_IA5String); - if (cbc == null) - throw new IOException("No CharToByteConverter for IA5String"); - cbc.convert(valueString.toCharArray(), 0, valueString.length(), - bbuf, 0, bbuf.length); - } catch (java.io.CharConversionException e) { - throw new IllegalArgumentException( - "Invalid IA5String AVA Value string"); - } catch (InstantiationException e) { - throw new IOException("Cannot instantiate CharToByteConverter"); - } catch (IllegalAccessException e) { - throw new IOException("Illegal access loading CharToByteConverter"); - } - return new DerValue(DerValue.tag_IA5String, bbuf); + throws IOException + { + ASN1CharStrConvMap map; + CharToByteConverter cbc; + byte[] bbuf = new byte[valueString.length()]; + map = ASN1CharStrConvMap.getDefault(); + try { + cbc = map.getCBC(DerValue.tag_IA5String); + if (cbc == null) + throw new IOException("No CharToByteConverter for IA5String"); + cbc.convert(valueString.toCharArray(), 0, valueString.length(), + bbuf, 0, bbuf.length); + } + catch (java.io.CharConversionException e) { + throw new IllegalArgumentException( + "Invalid IA5String AVA Value string"); + } catch (InstantiationException e) { + throw new IOException("Cannot instantiate CharToByteConverter"); + } catch (IllegalAccessException e) { + throw new IOException("Illegal access loading CharToByteConverter"); + } + return new DerValue(DerValue.tag_IA5String, bbuf); } /* - * Converts a BER encoded value of IA5String to a DER encoded value. Checks - * if the BER encoded value is a IA5String. NOTE only DER encoding is - * currently supported on for the BER encoded value. + * Converts a BER encoded value of IA5String to a DER encoded value. + * Checks if the BER encoded value is a IA5String. + * NOTE only DER encoding is currently supported on for the BER + * encoded value. * - * @param berStream a byte array of the BER encoded value. + * @param berStream a byte array of the BER encoded value. * - * @return a DerValue. + * @return a DerValue. * - * @exception IOException if the BER value cannot be converted to a - * IA5String DER value. + * @exception IOException if the BER value cannot be converted + * to a IA5String DER value. */ - public DerValue getValue(byte[] berStream) throws IOException { - DerValue value = new DerValue(berStream); - if (value.tag == DerValue.tag_IA5String) - return value; - if (value.tag == DerValue.tag_PrintableString) - return value; - throw new IOException("Invalid IA5String AVA Value."); + public DerValue getValue(byte[] berStream) + throws IOException + { + DerValue value = new DerValue(berStream); + if (value.tag == DerValue.tag_IA5String) + return value; + if (value.tag == DerValue.tag_PrintableString) + return value; + throw new IOException("Invalid IA5String AVA Value."); } /* - * Converts a DerValue of IA5String to a java string with IA5String - * characters. - * - * @param avaValue a DerValue. - * - * @return a string with IA5String characters. + * Converts a DerValue of IA5String to a java string with IA5String + * characters. * - * @exception IOException if the DerValue is not a IA5String i.e. The - * DerValue cannot be converted to a string with IA5String characters. + * @param avaValue a DerValue. + * + * @return a string with IA5String characters. + * + * @exception IOException if the DerValue is not a IA5String i.e. + * The DerValue cannot be converted to a string + * with IA5String characters. */ - public String getAsString(DerValue avaValue) throws IOException { - if (avaValue.tag == DerValue.tag_IA5String) - return avaValue.getIA5String(); - if (avaValue.tag == DerValue.tag_PrintableString) - return avaValue.getPrintableString(); - throw new IOException("Invalid IA5String AVA Value."); + public String getAsString(DerValue avaValue) + throws IOException + { + if (avaValue.tag == DerValue.tag_IA5String) + return avaValue.getIA5String(); + if (avaValue.tag == DerValue.tag_PrintableString) + return avaValue.getPrintableString(); + throw new IOException("Invalid IA5String AVA Value."); } } |