Asserts a users credentials. Returns a boolean value indicating if
assertion was successful or not.

@return true if assertion was successful, false if not
@since 1.0.0
548219
private boolean validateCredentials() {
        LOGGER.debug("Validating credentials for: " + username);
        final LdapConnectionWrapper ldap = new LdapConnectionWrapper();
        DirContext dirContext = null;
        LdapContext ldapContext = null;
        try (AlpineQueryManager qm = new AlpineQueryManager()) {
            final LdapUser ldapUser = qm.getLdapUser(username);
            if (ldapUser != null && ldapUser.getDN() != null && ldapUser.getDN().contains("=")) {
                ldapContext = ldap.createLdapContext(ldapUser.getDN(), password);
                LOGGER.debug("The supplied credentials are valid for: " + username);
                return true;
            } else {
                dirContext = ldap.createDirContext();
                final SearchResult result = ldap.searchForSingleUsername(dirContext, username);
                if (result != null ) {
                    ldapContext = ldap.createLdapContext(result.getNameInNamespace(), password);
                    LOGGER.debug("The supplied credentials are invalid for: " + username);
                    return true;
                }
            }
        } catch (NamingException e) {
            LOGGER.debug("An error occurred while attempting to validate credentials", e);
        } finally {
            ldap.closeQuietly(ldapContext);
            ldap.closeQuietly(dirContext);
        }
        return false;
    }
20965
def verify_credentials(self, delegate=None):
        ""
        parser = txml.Users(delegate)
        return self.__downloadPage('/account/verify_credentials.xml', parser)
573813
function() {
	   if(this.options.confirmPasswordField) {
	      if(this.options.confirmPasswordField.getValue() != this.getValue() ) {
	         return false;
	      }
	   }
	   return inputEx.PasswordField.superclass.validate.call(this);
	}
1096618
public static boolean verify(String host, String username, String password, int port) throws SMTPException {
	try {
	    return _verify(host, username, password, port);
	}
	catch (MessagingException e) {

	    // check user
	    if (!StringUtil.isEmpty(username)) {
		try {
		    _verify(host, null, null, port);
		    throw new SMTPExceptionImpl("can't connect to mail server, authentication settings are invalid");
		}
		catch (MessagingException e1) {

		}
	    }
	    // check port
	    if (port > 0 && port != 25) {
		try {
		    _verify(host, null, null, 25);
		    throw new SMTPExceptionImpl("can't connect to mail server, port definition is invalid");
		}
		catch (MessagingException e1) {}
	    }

	    throw new SMTPExceptionImpl("can't connect to mail server");
	}
    }
1104914
public boolean isRevocationValid() {
        if (basicResp == null)
            return false;
        if (signCerts.size() < 2)
            return false;
        try {
            X509Certificate[] cs = (X509Certificate[])getSignCertificateChain();
            SingleResp sr = basicResp.getResponses()[0];
            CertificateID cid = sr.getCertID();
            X509Certificate sigcer = getSigningCertificate();
            X509Certificate isscer = cs[1];
            CertificateID tis = new CertificateID(
               new JcaDigestCalculatorProviderBuilder().build().get(CertificateID.HASH_SHA1), new JcaX509CertificateHolder(isscer), sigcer.getSerialNumber());
            return tis.equals(cid);
        }
        catch (Exception ex) {
        }
        return false;
    }
209347
protected final boolean isAuthenticated(Context context) {
        Account account = context.getSession(AuthConstants.ACCOUNT_ATTRIBUTE);
        if (account == null) {
            account = context.getLocal(AuthConstants.ACCOUNT_ATTRIBUTE);
        }
        return account != null && account.isAuthenticated();
    }
1233995
public boolean verify() throws SignatureException {
        if (verified)
            return verifyResult;
        if (sigAttr != null) {
            sig.update(sigAttr);
            if (RSAdata != null) {
                byte msd[] = messageDigest.digest();
                messageDigest.update(msd);
            }
            verifyResult = (Arrays.equals(messageDigest.digest(), digestAttr) && sig.verify(digest));
        }
        else {
            if (RSAdata != null)
                sig.update(messageDigest.digest());
            verifyResult = sig.verify(digest);
        }
        verified = true;
        return verifyResult;
    }
849627
public boolean validation() throws ParallelTaskInvalidException {

        if (this.commandLine == null) {
            throw new ParallelTaskInvalidException(
                    "commandSshLine is null for ssh");
        }
        if (this.sshLoginType == null) {
            throw new ParallelTaskInvalidException(
                    "sshLoginType is null for ssh");
        }

        if (this.userName == null) {
            throw new ParallelTaskInvalidException("userName is null for ssh. "
                    + "UserName is required for both key/password based login");
        }


        if (this.sshLoginType == SshLoginType.PASSWORD && password == null) {
            throw new ParallelTaskInvalidException(
                    "use password but it is null for ssh");
        }
        if (this.sshLoginType == SshLoginType.KEY
                && this.privKeyRelativePath == null) {
            throw new ParallelTaskInvalidException(
                    "use public key but private key path is null for ssh");
        }

        if (this.sshLoginType == SshLoginType.KEY
                && this.privKeyUsePassphrase && this.passphrase == null) {
            throw new ParallelTaskInvalidException(
                    "use public key and also with private key passphrase but it is null for ssh");
        }

        return true;

    }
280187
public function checkCredentials($credentials, UserInterface $user): bool
    {
        $plainPassword = $credentials->getPlainPassword();
        $encoder = $this->passwordEncoder;

        if (!$encoder->isPasswordValid($user, $plainPassword)) {
            throw new BadCredentialsException();
        }

        return true;
    }
325083
private static boolean areSame(Credentials c1, Credentials c2) {
        if (c1 == null) {
            return c2 == null;
        } else {
            return StringUtils.equals(c1.getUserPrincipal().getName(), c1.getUserPrincipal().getName()) &&
                    StringUtils.equals(c1.getPassword(), c1.getPassword());
        }
    }
447451
public static boolean authenticate(String userName, String userPassword) {
        LOGGER.entering(userName, StringUtils.isBlank(userPassword) ? userPassword : userPassword.replaceAll(".", "*"));
        boolean validLogin = false;
        byte[] currentAuthData;
        byte[] hashedInputData;
        if (StringUtils.isBlank(userName) || StringUtils.isBlank(userPassword)) {
            return validLogin;
        }
        try {
            File authFile = new File(AUTH_FILE_LOCATION);
            if (!authFile.exists()) {
                authFile.createNewFile();
                createAuthFile(authFile, DEFAULT_USERNAME, DEFAULT_PASSWORD);
            }
            currentAuthData = getBytesFromFile(authFile);
            hashedInputData = hashData(userName, userPassword);
            validLogin = Arrays.equals(currentAuthData, hashedInputData);
        } catch (Exception e) {
            validLogin = false;
        }
        LOGGER.exiting(validLogin);
        return validLogin;
    }
1078368
public boolean signUp(){
        SignUpCredentials creds = new SignUpCredentials(getUsername(),getEmailAddress(),getPassword());
        SignUpResponse response = getAM().signUp(creds);
        if(response.getStatus().isSuccess()){
            this.initFrom(response.get());
            return true;
        } else return false;
    }
256482
@POST
    @Produces(MediaType.TEXT_PLAIN)
    @ApiOperation(
            value = "Assert login credentials",
            notes = "Upon a successful login, a JWT will be returned in the response. This functionality requires authentication to be enabled.",
            response = String.class
    )
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Success"),
            @ApiResponse(code = 401, message = "Unauthorized")
    })
    @AuthenticationNotRequired
    public Response validateCredentials(@FormParam("username") String username, @FormParam("password") String password) {
        final Authenticator auth = new Authenticator(username, password);
        try {
            final Principal principal = auth.authenticate();
            if (principal != null) {
                LOGGER.info(SecurityMarkers.SECURITY_AUDIT, "Login succeeded (username: " + username
                        + " / ip address: " + super.getRemoteAddress()
                        + " / agent: " + super.getUserAgent() + ")");

                final JsonWebToken jwt = new JsonWebToken();
                final String token = jwt.createToken(principal);
                return Response.ok(token).build();
            }
        } catch (AuthenticationException e) {
            LOGGER.warn(SecurityMarkers.SECURITY_AUDIT, "Unauthorized login attempt (username: "
                    + username + " / ip address: " + super.getRemoteAddress()
                    + " / agent: " + super.getUserAgent() + ")");
        }
        return Response.status(Response.Status.UNAUTHORIZED).build();
    }
690957
public boolean hasPermission(Authentication authentication,
                                 Object resource,
                                 Object privilege) {
        boolean logPermission = isLogPermission(resource);
        return checkRole(authentication, privilege, logPermission)
            || checkPermission(authentication, resource, privilege, true, logPermission);
    }
522512
private void validateCredentials(String username, String password, ApiRequest request, IPolicyContext context,
            BasicAuthenticationConfig config, IAsyncResultHandler<Boolean> handler) {
        if (config.getStaticIdentity() != null) {
            staticIdentityValidator.validate(username, password, request, context, config.getStaticIdentity(), handler);
        } else if (config.getLdapIdentity() != null) {
            ldapIdentityValidator.validate(username, password, request, context, config.getLdapIdentity(), handler);
        } else if (config.getJdbcIdentity() != null) {
            jdbcIdentityValidator.validate(username, password, request, context, config.getJdbcIdentity(), handler);
        } else {
            handler.handle(AsyncResultImpl.create(Boolean.FALSE));
        }
    }
924459
protected function checkToken() {
        //instantiate MultiOtp Wrapper
        $multiOtpWrapper = new MultiotpWrapper();
        
        //get the username
        $currentUserName = $this->getCurrentUsername();
        
        //assert that username is set
        if (!(\strlen((string) $currentUserName))) {
            throw new UserCredentialException('Cannot validate a TOTP token when username is not set!', 2106);
        }
        
        //assert that the token exists
        $tokenExists = $multiOtpWrapper->CheckTokenExists($currentUserName);
        
        if (!($tokenExists)) {
            throw new UserCredentialException('The TOTP token for the current user does not exist', 2107);
        }

        //username mapped to their token name
        $multiOtpWrapper->setToken($currentUserName);
        
        //validate the Token
        $oneTimeToken = $this->getOneTimeToken();
        $tokenCheckResult = $multiOtpWrapper->CheckToken($oneTimeToken);
        
        //The results are reversed
        //TODO: Add intepretation of MultiOtp return results here to enable exception handling
        if ($tokenCheckResult == 0) {
            return true;
        } else {
            return false;
        }
    }
683547
@SuppressWarnings("unchecked")
    @Override
    public Boolean execute() {
        api.logout(CommandUtil.getSfsUser(username, api));
        return Boolean.TRUE;
    }