Commit d28442df authored by Marco Descher's avatar Marco Descher
Browse files

[9918] Remove IExternalLoginService

parent 08e81a56
Loading
Loading
Loading
Loading
+0 −20
Original line number Diff line number Diff line
package ch.elexis.core.services;

import javax.security.auth.login.LoginException;

import ch.elexis.core.model.IUser;

public interface IExternalLoginService {
	
	/**
	 * Returns the {@link IUser} after an external login or {@link LoginException} if the login
	 * fails
	 * 
	 * @param username
	 * @param password
	 * @return
	 * @throws LoginException
	 */
	public IUser login(String username, char[] password) throws LoginException;
	
}
+0 −36
Original line number Diff line number Diff line
package ch.elexis.data.service.internal;

import javax.security.auth.login.LoginException;

import org.osgi.service.component.annotations.Component;

import ch.elexis.core.model.IUser;
import ch.elexis.core.model.RoleConstants;
import ch.elexis.core.services.IExternalLoginService;

@Component
public class CsvLoginService implements IExternalLoginService {
	
	private String[] rows;
	
	public void initCsvRows(String defaultContanctId){
		rows = new String[] {
			"sazgin1:password:" + defaultContanctId + ":" + RoleConstants.SYSTEMROLE_LITERAL_USER
				+ "," + RoleConstants.SYSTEMROLE_LITERAL_DOCTOR,
			"afi1:password:XXXXX:" + RoleConstants.SYSTEMROLE_LITERAL_USER + ","
				+ RoleConstants.SYSTEMROLE_LITERAL_EXECUTIVE_DOCTOR
		};
		
	}
	
	@Override
	public IUser login(String username, char[] password) throws LoginException{
		
		IUser csvUser = new CsvUser(rows).login(username, password);
		if (csvUser == null) {
			throw new LoginException("Authentication failed");
		}
		return csvUser;
		
	}
}