Skip to content
Snippets Groups Projects
Select Git revision
  • 7924b94f4cadde72f46e83f7c389230ff2eb6edd
  • main default protected
  • br1
3 results

ecs.php

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    AuthenticationByPasswordService.java 1.79 KiB
    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);
        }