From fa522c41fca4f5c08707c7f04f1228b929e61b68 Mon Sep 17 00:00:00 2001 From: mdb Date: Wed, 16 Oct 2002 00:44:48 +0000 Subject: [PATCH] Go ahead and throw the exception in StringUtil since everyone else will end up doing something like that anyway. git-svn-id: https://samskivert.googlecode.com/svn/trunk@865 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../java/com/samskivert/servlet/user/UserUtil.java | 11 ++--------- .../src/java/com/samskivert/util/StringUtil.java | 10 ++++++---- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/projects/samskivert/src/java/com/samskivert/servlet/user/UserUtil.java b/projects/samskivert/src/java/com/samskivert/servlet/user/UserUtil.java index 6c28e227..97557965 100644 --- a/projects/samskivert/src/java/com/samskivert/servlet/user/UserUtil.java +++ b/projects/samskivert/src/java/com/samskivert/servlet/user/UserUtil.java @@ -1,5 +1,5 @@ // -// $Id: UserUtil.java,v 1.5 2002/10/16 00:42:26 mdb Exp $ +// $Id: UserUtil.java,v 1.6 2002/10/16 00:44:48 mdb Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Michael Bayne @@ -40,14 +40,7 @@ public class UserUtil buf.append(Math.random()); // and MD5 hash it - String auth = StringUtil.md5hex(buf.toString()); - if (auth == null) { - throw new RuntimeException("JVM missing MD5 message digest " + - "algorithm implementation. User " + - "management facilities require MD5 " + - "encoding capabilities."); - } - return auth; + return StringUtil.md5hex(buf.toString()); } /** diff --git a/projects/samskivert/src/java/com/samskivert/util/StringUtil.java b/projects/samskivert/src/java/com/samskivert/util/StringUtil.java index 3139ffd7..06143c9f 100644 --- a/projects/samskivert/src/java/com/samskivert/util/StringUtil.java +++ b/projects/samskivert/src/java/com/samskivert/util/StringUtil.java @@ -1,5 +1,5 @@ // -// $Id: StringUtil.java,v 1.38 2002/10/16 00:42:26 mdb Exp $ +// $Id: StringUtil.java,v 1.39 2002/10/16 00:44:48 mdb Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Michael Bayne @@ -579,8 +579,10 @@ public class StringUtil } /** - * Returns a hex string representing the MD5 encoded source or null if - * the MD5 codec was not available in this JVM. + * Returns a hex string representing the MD5 encoded source. + * + * @exception RuntimeException thrown if the MD5 codec was not + * available in this JVM. */ public static String md5hex (String source) { @@ -588,7 +590,7 @@ public class StringUtil MessageDigest digest = MessageDigest.getInstance("MD5"); return hexlate(digest.digest(source.getBytes())); } catch (NoSuchAlgorithmException nsae) { - return null; + throw new RuntimeException("MD5 codec not available"); } }