/*
 * Copyright 2016 EPAM Systems
 * 
 * 
 * This file is part of EPAM Report Portal.
 * https://github.com/reportportal/commons-dao
 * 
 * Report Portal 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 3 of the License, or
 * (at your option) any later version.
 * 
 * Report Portal 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 Report Portal.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.epam.ta.reportportal.database.entity.user;

import org.apache.commons.validator.routines.EmailValidator;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * User entry related utilities
 *
 * @author Andrei_Ramanchuk
 */
public class UserUtils {

    /**
     * MD5 password hashing
     *
     * @param initial
     * @return
     */
    public static String generateMD5(String initial) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] byteInitial = initial.getBytes("UTF-8");
            byteInitial = md.digest(byteInitial);
            // convert the byte to hex format
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < byteInitial.length; i++) {
                sb.append(Integer.toString((byteInitial[i] & 0xff) + 0x100, 16).substring(1));
            }
            return sb.toString();
        } catch (NoSuchAlgorithmException ex) {
            throw new RuntimeException("Unable apply MD5 algorithm for password hashing: ", ex);
        } catch (UnsupportedEncodingException unsEx) {
            throw new RuntimeException("Unable apply UTF-8 encoding for password string: ", unsEx);
        }
    }

    /**
     * Validate email format against RFC822
     *
     * @param email Email to be validated
     * @return TRUE of email is valid
     */
    public static boolean isEmailValid(String email) {
        EmailValidator validator = EmailValidator.getInstance();
        return validator.isValid(email);
    }
}

@@ -908,1179 +908,103 @@
 r;%0A%0A
-import java.io.UnsupportedEncodingException;%0Aimport java.security.MessageDigest;%0Aimport java.security.NoSuchAlgorithmException;%0A%0A/**%0A * User entry related utilities%0A *%0A * @author Andrei_Ramanchuk%0A */%0Apublic class UserUtils %7B%0A%0A    /**%0A     * MD5 password hashing%0A     *%0A     * @param initial%0A     * @return%0A     */%0A    public static String generateMD5(String initial) %7B%0A        try %7B%0A            MessageDigest md = MessageDigest.getInstance(%22MD5%22);%0A            byte%5B%5D byteInitial = initial.getBytes(%22UTF-8%22);%0A            byteInitial = md.digest(byteInitial);%0A            // convert the byte to hex format%0A            StringBuffer sb = new StringBuffer();%0A            for (int i = 0; i %3C byteInitial.length; i++) %7B%0A                sb.append(Integer.toString((byteInitial%5Bi%5D & 0xff) + 0x100, 16).substring(1));%0A            %7D%0A            return sb.toString();%0A        %7D catch (NoSuchAlgorithmException ex) %7B%0A            throw new RuntimeException(%22Unable apply MD5 algorithm for password hashing: %22, ex);%0A        %7D catch (UnsupportedEncodingException unsEx) %7B%0A            throw new RuntimeException(%22Unable apply UTF-8 encoding for password string: %22, unsEx);%0A        %7D%0A    %7D
+/**%0A * User entry related utilities%0A *%0A * @author Andrei_Ramanchuk%0A */%0Apublic class UserUtils %7B
 %0A%0A  
@@ -1215,34 +1215,14 @@
     
-EmailValidator validator =
+return
  Ema
@@ -1250,34 +1250,8 @@
 ce()
-;%0A        return validator
 .isV

add utility method to user utils