Ya encontré algo:
security.xml Código HTML:
<authentication-provider user-service-ref="userDao">
<password-encoder ref="passwordEncoder"/>
</authentication-provider>
<beans:bean id="dbUserService" class="paquete.UserDaoJava">
<beans:property name="userDao" ref="userDao" />
</beans:bean>
UserDetailsService.java
package com.opensistemas.app.dao;
Código PHP:
import org.springframework.dao.DataAccessException;
import org.springframework.security.providers.ProviderManager;
import org.springframework.security.userdetails.UserDetails;
import org.springframework.security.userdetails.UsernameNotFoundException;
public interface UserDetailsService {
UserDetails loadUserByUsername(String username)
throws UsernameNotFoundException, DataAccessException;
}
UserDaoJava.java Código PHP:
import org.springframework.beans.InvalidPropertyException;
import org.springframework.dao.DataAccessException;
import org.springframework.security.Authentication;
import org.springframework.security.GrantedAuthority;
import org.springframework.security.GrantedAuthorityImpl;
import org.springframework.security.userdetails.UserDetails;
import org.springframework.security.userdetails.UsernameNotFoundException;
public class UserDaoJava implements UserDetailsService {
public Authentication userDao;
public UserDaoWs() {
System.out.println("INI CONSTRUCTOR USERDAOWS");
}
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException, InvalidPropertyException {
//Cómo rescato el username aquí!!!!
System.out.println("Username USER_DAO: "+ username);
System.out.println("USUARIO?: "+ userDao.getPrincipal().toString());
throw new UnsupportedOperationException("Not supported yet.");
}
//Con los getters & setters toma el valor desde security.xml (Inyección)
public Authentication getUserDao() {
return userDao;
}
public void setUserDao(Authentication userDao) {
this.userDao = userDao;
}
}
Necesito ayuda urgente con esto por favor, si alguien sabe y se maneja.
Compila bien, pasa por el constructor de esta clase, pero no sé cómo obtener el valor del
username.
Ayuda. Por favor :(