Skip to content
Snippets Groups Projects
Commit 9915409c authored by MEDEDJI Setondji's avatar MEDEDJI Setondji :speech_balloon:
Browse files

Commit intermédiaire

parent 34159c91
No related branches found
No related tags found
No related merge requests found
package authentication;
public interface AuthenticationService {
boolean isAMatch(String identifier, String autenthicationData);
Strength dataStrenth(String autenthicationData);
}
package authentication;
public enum Strength {
VERY_WEAK, WEAK, REGULAR, STRONG
}
package interfacemanualmocking;
import authentication.AuthenticationService;
import authentication.Strength;
public class AuthenticationByBiometryService implements AuthenticationService {
private DirectoryInterface directory;
private StrengthEstimationServiceInterface strengthEstimationService;
public AuthenticationByBiometryService(DirectoryInterface directory, StrengthEstimationServiceInterface strengthEstimationService) {
this.directory = directory;
this.strengthEstimationService = strengthEstimationService;
}
@Override
public boolean isAMatch(String identifier, String autenthicationData) {
String match = directory.getMatch(identifier);
return match.equals(autenthicationData);
}
@Override
public Strength dataStrenth(String autenthicationData) {
return Strength.STRONG;
}
}
package interfacemanualmocking;
import authentication.AuthenticationService;
import authentication.Strength;
public class AuthenticationByPasswordService implements AuthenticationService {
private DirectoryInterface directory;
private StrengthEstimationServiceInterface strengthEstimationService;
public AuthenticationByPasswordService(DirectoryInterface directory, StrengthEstimationServiceInterface strengthEstimationService) {
this.directory = directory;
this.strengthEstimationService = strengthEstimationService;
}
@Override
public boolean isAMatch(String identifier, String autenthicationData) {
String match = directory.getMatch(identifier);
return match.equals(autenthicationData);
}
@Override
public Strength dataStrenth(String autenthicationData) {
int datasize = autenthicationData.length();
int alphabetSize = 142;
int strength = strengthEstimationService.equivalentBitLength(alphabetSize,datasize)
if( strength >= 0 && strength <= 49 ) {
return Strength.VERY_WEAK;
}
if( strength >= 50 && strength <= 79 ) {
return Strength.WEAK;
}
if ( strength >= 80 && strength <= 99 ) {
return Strength.REGULAR;
}
if ( strength >= 100 ) {
return Strength.STRONG;
}
}
private boolean isMatch(String identifier, String autenthicationData) {
String match = directory.getMatch(identifier);
return match.equals(autenthicationData);
}
//private StrengthEstimationServiceInterface dataStrenth(String autenthicationData) {
// int alphabetSize = 0;
// int datasize = autenthicationData.length();
//return strengthEstimationService.equivalentBitLength(alphabetSize, datasize);
}
package interfacemanualmocking;
public interface DirectoryInterface {
String getMatch(String identifier);
}
package interfacemanualmocking;
public interface StrengthEstimationServiceInterface {
int equivalentBitLength(int alphabetSize, int datasize);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment