@Test (expected = IllegalArgumentException.class) public void testParseInvalidInvalidAlg () { MIC.parse ("VGVzdA==, blub"); }
@Nullable public static MIC parse (@Nullable final String sMIC) { if (StringHelper.hasNoText (sMIC)) return null; final StringTokenizer st = new StringTokenizer (sMIC, ", \t\r\n"); final String sMICBytes = st.nextToken (); final byte [] aMICBytes = Base64.safeDecode (sMICBytes); if (aMICBytes == null) throw new IllegalArgumentException ("Failed to base64 decode '" + sMICBytes + "'"); if (!st.hasMoreTokens ()) throw new IllegalArgumentException ("Separator after Base64 bytes is missing"); final String sAlgorithm = st.nextToken (); final ECryptoAlgorithmSign eDigestAlgorithm = ECryptoAlgorithmSign.getFromIDOrNull (sAlgorithm); if (eDigestAlgorithm == null) throw new IllegalArgumentException ("Failed to parse digest algorithm '" + sAlgorithm + "'"); return new MIC (aMICBytes, eDigestAlgorithm); }
MIC implements Serializable { @Nullable public static MIC parse (@Nullable final String sMIC) { if (StringHelper.hasNoText (sMIC)) return null; final StringTokenizer st = new StringTokenizer (sMIC, ", \t\r\n"); final String sMICBytes = st.nextToken (); final byte [] aMICBytes = Base64.safeDecode (sMICBytes); if (aMICBytes == null) throw new IllegalArgumentException ("Failed to base64 decode '" + sMICBytes + "'"); if (!st.hasMoreTokens ()) throw new IllegalArgumentException ("Separator after Base64 bytes is missing"); final String sAlgorithm = st.nextToken (); final ECryptoAlgorithmSign eDigestAlgorithm = ECryptoAlgorithmSign.getFromIDOrNull (sAlgorithm); if (eDigestAlgorithm == null) throw new IllegalArgumentException ("Failed to parse digest algorithm '" + sAlgorithm + "'"); return new MIC (aMICBytes, eDigestAlgorithm); } }
MIC implements Serializable { @Nullable public static MIC parse (@Nullable final String sMIC) { if (StringHelper.hasNoText (sMIC)) return null; final StringTokenizer st = new StringTokenizer (sMIC, ", \t\r\n"); final String sMICBytes = st.nextToken (); final byte [] aMICBytes = Base64.safeDecode (sMICBytes); if (aMICBytes == null) throw new IllegalArgumentException ("Failed to base64 decode '" + sMICBytes + "'"); if (!st.hasMoreTokens ()) throw new IllegalArgumentException ("Separator after Base64 bytes is missing"); final String sAlgorithm = st.nextToken (); final ECryptoAlgorithmSign eDigestAlgorithm = ECryptoAlgorithmSign.getFromIDOrNull (sAlgorithm); if (eDigestAlgorithm == null) throw new IllegalArgumentException ("Failed to parse digest algorithm '" + sAlgorithm + "'"); return new MIC (aMICBytes, eDigestAlgorithm); } MIC(@Nonnull final byte [] aMICBytes, @Nonnull final ECryptoAlgorithmSign eDigestAlgorithm); }
MIC implements Serializable { @Nullable public static MIC parse (@Nullable final String sMIC) { if (StringHelper.hasNoText (sMIC)) return null; final StringTokenizer st = new StringTokenizer (sMIC, ", \t\r\n"); final String sMICBytes = st.nextToken (); final byte [] aMICBytes = Base64.safeDecode (sMICBytes); if (aMICBytes == null) throw new IllegalArgumentException ("Failed to base64 decode '" + sMICBytes + "'"); if (!st.hasMoreTokens ()) throw new IllegalArgumentException ("Separator after Base64 bytes is missing"); final String sAlgorithm = st.nextToken (); final ECryptoAlgorithmSign eDigestAlgorithm = ECryptoAlgorithmSign.getFromIDOrNull (sAlgorithm); if (eDigestAlgorithm == null) throw new IllegalArgumentException ("Failed to parse digest algorithm '" + sAlgorithm + "'"); return new MIC (aMICBytes, eDigestAlgorithm); } MIC(@Nonnull final byte [] aMICBytes, @Nonnull final ECryptoAlgorithmSign eDigestAlgorithm); @Nonnull byte [] micBytes(); @Nonnull ECryptoAlgorithmSign getDigestAlgorithm(); @Nonnull @Nonempty String getAsAS2String(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); @Nullable static MIC parse(@Nullable final String sMIC); }
MIC implements Serializable { @Nullable public static MIC parse (@Nullable final String sMIC) { if (StringHelper.hasNoText (sMIC)) return null; final StringTokenizer st = new StringTokenizer (sMIC, ", \t\r\n"); final String sMICBytes = st.nextToken (); final byte [] aMICBytes = Base64.safeDecode (sMICBytes); if (aMICBytes == null) throw new IllegalArgumentException ("Failed to base64 decode '" + sMICBytes + "'"); if (!st.hasMoreTokens ()) throw new IllegalArgumentException ("Separator after Base64 bytes is missing"); final String sAlgorithm = st.nextToken (); final ECryptoAlgorithmSign eDigestAlgorithm = ECryptoAlgorithmSign.getFromIDOrNull (sAlgorithm); if (eDigestAlgorithm == null) throw new IllegalArgumentException ("Failed to parse digest algorithm '" + sAlgorithm + "'"); return new MIC (aMICBytes, eDigestAlgorithm); } MIC(@Nonnull final byte [] aMICBytes, @Nonnull final ECryptoAlgorithmSign eDigestAlgorithm); @Nonnull byte [] micBytes(); @Nonnull ECryptoAlgorithmSign getDigestAlgorithm(); @Nonnull @Nonempty String getAsAS2String(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); @Nullable static MIC parse(@Nullable final String sMIC);  }