Author: tchemit Date: 2008-02-13 21:44:23 +0000 (Wed, 13 Feb 2008) New Revision: 933 Added: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationServiceHelper.java Log: introduction helper pour authentication service Added: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationServiceHelper.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationServiceHelper.java (rev 0) +++ trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationServiceHelper.java 2008-02-13 21:44:23 UTC (rev 933) @@ -0,0 +1,57 @@ +/* +* \#\#% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, +* Tony Chemit, Gabriel Landais +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* \#\#% */ +package fr.cemagref.simexplorer.is.service; + +import org.codelutin.util.ConverterUtil; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +/** @author chemit */ +public class AuthenticationServiceHelper { + + + protected AuthenticationServiceHelper() { + // no instance + } + + /** + * Compute hash. + * + * @param clearString the clear string + * + * @return the string + * + * @throws SimExplorerServiceException the sim explorer service exception + */ + public static String computeHash(char[] clearString) throws SimExplorerServiceException { + MessageDigest messageDigest; + try { + messageDigest = MessageDigest.getInstance("SHA-1"); + } catch (NoSuchAlgorithmException e) { + throw new SimExplorerServiceException(e); + } + messageDigest.reset(); + byte[] bytes = ConverterUtil.convert(clearString); + messageDigest.update(bytes); + String hashedPassword; + hashedPassword = new String(messageDigest.digest()); + return hashedPassword; + } +}
participants (1)
-
tchemit@users.labs.libre-entreprise.org