// Path: src/main/java/es/urjc/etsii/mtenrero/BusinessLogic/Helpers/ParseHelper.java
// public class ParseHelper {
//     /** Return a List with all words in a given String **/
//     public static List<String> stringSplitter(String string) {
//         String[] words = string.split(" ");
//         return Arrays.asList(words);
//     }
// 
//     /** Check if a String can be casted to Integer **/
//     public static boolean isInteger(String string) {
//         boolean isNumber = true;
//         try {
//             Integer.parseInt(string);
//         } catch (final NumberFormatException exception) {
//             isNumber = false;
//         }
//         return isNumber;
//     }
// }
// 
// Path: src/main/java/es/urjc/etsii/mtenrero/Entities/User.java
// @MappedSuperclass
// public abstract class User implements Serializable {
//     @Id
//     @GeneratedValue(strategy = GenerationType.AUTO)
//     private long id;
//     @Column(unique=true)
//     private String logon;
//     private String password;
//     @ElementCollection(fetch = FetchType.EAGER)
//     private List<String> roles;
// 
//     public User() {
//         this.roles = new ArrayList<>();
//     }
// 
//     public User(String name, String password, String... roles) {
//         this.logon = name;
//         this.password = new BCryptPasswordEncoder().encode(password);
//         this.roles = new ArrayList<>(Arrays.asList(roles));
//     }
// 
//     public String getLogon() {
//         return logon;
//     }
// 
//     public void setLogon(String logon) {
//         this.logon = logon;
//     }
// 
//     public String getPasswordHash() {
//         return password;
//     }
// 
//     public void setPasswordHash(String password) {
//         this.password = new BCryptPasswordEncoder().encode(password);
//     }
// 
//     public void setRoles(String... roles) {
//         this.roles = new ArrayList<>(Arrays.asList(roles));
//     }
// 
//     public List<String> getRoles() {
//         return roles;
//     }
// }
// 
// Path: src/main/java/es/urjc/etsii/mtenrero/Repositories/ClientRepository.java
// public interface ClientRepository extends UserRepository<Client> {
//     @CachePut("vetmanager")
//     Client save(Client client);
//     @Cacheable("vetmanager")
//     Client findByLegalID(int legalID);
// 
//     Collection<? extends Client> findFirst10ByPhone1(int i);
// 
//     Collection<? extends Client> findFirst10ByLastNameContainingIgnoreCase(String word);
// 
//     Collection<? extends Client> findFirst10ByFirstNameContainingIgnoreCase(String word);
// 
//     Collection<? extends Client> findFirst10ByLegalID(int i);
//     @Cacheable("vetmanager")
//     Client findById(long id);
// }
// 
// Path: src/main/java/es/urjc/etsii/mtenrero/Repositories/ManagerRepository.java
// @Transactional
// public interface ManagerRepository extends UserRepository<Manager> {
// }


import es.urjc.etsii.mtenrero.BusinessLogic.Helpers.ParseHelper;
import es.urjc.etsii.mtenrero.Entities.User;
import es.urjc.etsii.mtenrero.Repositories.ClientRepository;
import es.urjc.etsii.mtenrero.Repositories.ManagerRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
package es.urjc.etsii.mtenrero;



/**
 * Created by was12 on 14/03/2017.
 */
@Component
public class UserRepositoryAuthenticationProvider implements AuthenticationProvider {
    @Autowired
    private ClientRepository clientRepository;
// Path: src/main/java/es/urjc/etsii/mtenrero/BusinessLogic/Helpers/ParseHelper.java
// public class ParseHelper {
//     /** Return a List with all words in a given String **/
//     public static List<String> stringSplitter(String string) {
//         String[] words = string.split(" ");
//         return Arrays.asList(words);
//     }
// 
//     /** Check if a String can be casted to Integer **/
//     public static boolean isInteger(String string) {
//         boolean isNumber = true;
//         try {
//             Integer.parseInt(string);
//         } catch (final NumberFormatException exception) {
//             isNumber = false;
//         }
//         return isNumber;
//     }
// }
// 
// Path: src/main/java/es/urjc/etsii/mtenrero/Entities/User.java
// @MappedSuperclass
// public abstract class User implements Serializable {
//     @Id
//     @GeneratedValue(strategy = GenerationType.AUTO)
//     private long id;
//     @Column(unique=true)
//     private String logon;
//     private String password;
//     @ElementCollection(fetch = FetchType.EAGER)
//     private List<String> roles;
// 
//     public User() {
//         this.roles = new ArrayList<>();
//     }
// 
//     public User(String name, String password, String... roles) {
//         this.logon = name;
//         this.password = new BCryptPasswordEncoder().encode(password);
//         this.roles = new ArrayList<>(Arrays.asList(roles));
//     }
// 
//     public String getLogon() {
//         return logon;
//     }
// 
//     public void setLogon(String logon) {
//         this.logon = logon;
//     }
// 
//     public String getPasswordHash() {
//         return password;
//     }
// 
//     public void setPasswordHash(String password) {
//         this.password = new BCryptPasswordEncoder().encode(password);
//     }
// 
//     public void setRoles(String... roles) {
//         this.roles = new ArrayList<>(Arrays.asList(roles));
//     }
// 
//     public List<String> getRoles() {
//         return roles;
//     }
// }
// 
// Path: src/main/java/es/urjc/etsii/mtenrero/Repositories/ClientRepository.java
// public interface ClientRepository extends UserRepository<Client> {
//     @CachePut("vetmanager")
//     Client save(Client client);
//     @Cacheable("vetmanager")
//     Client findByLegalID(int legalID);
// 
//     Collection<? extends Client> findFirst10ByPhone1(int i);
// 
//     Collection<? extends Client> findFirst10ByLastNameContainingIgnoreCase(String word);
// 
//     Collection<? extends Client> findFirst10ByFirstNameContainingIgnoreCase(String word);
// 
//     Collection<? extends Client> findFirst10ByLegalID(int i);
//     @Cacheable("vetmanager")
//     Client findById(long id);
// }
// 
// Path: src/main/java/es/urjc/etsii/mtenrero/Repositories/ManagerRepository.java
// @Transactional
// public interface ManagerRepository extends UserRepository<Manager> {
// }


// Path: src/main/java/es/urjc/etsii/mtenrero/UserRepositoryAuthenticationProvider.java
import es.urjc.etsii.mtenrero.BusinessLogic.Helpers.ParseHelper;
import es.urjc.etsii.mtenrero.Entities.User;
import es.urjc.etsii.mtenrero.Repositories.ClientRepository;
import es.urjc.etsii.mtenrero.Repositories.ManagerRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;

package es.urjc.etsii.mtenrero;



/**
 * Created by was12 on 14/03/2017.
 */
@Component
public class UserRepositoryAuthenticationProvider implements AuthenticationProvider {
    @Autowired
    private ClientRepository clientRepository;
    @Autowired