Does User/Password authentication as defined in rfc1929.
@return An array containnig in, out streams, or null if authentication
fails.
518583
public Object[] doSocksAuthentication(int methodId,
                                         java.net.Socket proxySocket)
                   throws java.io.IOException{

      if(methodId != METHOD_ID) return null;

      java.io.InputStream in = proxySocket.getInputStream();
      java.io.OutputStream out = proxySocket.getOutputStream();

      out.write(request);
      int version = in.read();
      if(version < 0) return null; //Server closed connection
      int status = in.read();
      if(status != 0) return null; //Server closed connection, or auth failed.

      return new Object[] {in,out};
   }
1261986
public static boolean checkBasicAuth(HttpServletRequest servletRequest, String username, String password) {

		String basicAuth = servletRequest.getHeader("Authorization");
		if (StringUtils.isNullOrEmptyTrimmed(basicAuth) || !basicAuth.startsWith("Basic ")) {
			return false;
		}

		String base64Credentials = basicAuth.substring("Basic".length()).trim();
		String credentials = new String(Base64.getDecoder().decode(base64Credentials), Charset.forName("UTF-8"));

		// credentials = username:password
		final String[] values = credentials.split(":", 2);
		if (values.length != 2) {
			return false;
		}

		return StringUtils.equals(values[0], username) && StringUtils.equals(values[1], password);
	}
1240644
private boolean assertValidParams() {
        return username != null && !this.username.isEmpty() &&
                password != null && !this.password.isEmpty() &&
                sqlString != null && !this.sqlString.isEmpty() &&
        ( (database != null && !this.database.isEmpty()) || (jdbcConnString != null && !jdbcConnString.isEmpty()) );
    }
522093
@Override
  public boolean isSecure()
  {
    if (_s == null || _sslSocketClass == null)
      return false;
    else
      return _sslSocketClass.isAssignableFrom(_s.getClass());
  }
507322
public char[] getPassword() {
        String result = properties.getProperty(LocalJcrDriver.PASSWORD_PROPERTY_NAME);
        return result != null ? result.toCharArray() : null;
    }
17958
boolean checkCredentials() {


		if(!httpPut)
		{
			if (token.equals(CONFIG_TOKEN) || token.equals(""))
			{
				//Check if set in an environment variable, used with PaaS providers
				String envToken = getEnvVar( CONFIG_TOKEN);

				if (envToken == ""){
					dbg(INVALID_TOKEN);
					return false;
				}

				this.setToken(envToken);
			}

			return checkValidUUID(this.getToken());
		}else{
			if ( !checkValidUUID(this.getKey()) || this.getLocation().equals(""))
				return false;

			return true;
		}
	}
532666
public function isAuthenticated()
    {
        if(!array_key_exists(self::AUTHENTICATED, $this->_map))
            return false;

        $authc      = $this->_map[self::AUTHENTICATED];
        $authStatus = ($authc != null && $authc);
        return $authStatus;
    }
1170045
public static Authentication getAuthentication() {
        SecurityContext sc = getSecurityContext();
        return sc == null ? null : sc.getAuthentication();
    }
990814
@Override
    public boolean supports(final Credential credentials) {
        return credentials != null && WsFederationCredential.class.isAssignableFrom(credentials.getClass());
    }
1035211
public static function get_basic_auth() {
	// normally it just works
	if (!empty($_SERVER['PHP_AUTH_USER'])) {
		return [
			'USER' => $_SERVER['PHP_AUTH_USER'],
			'PW'   => $_SERVER['PHP_AUTH_PW'],
		];
	}
	
	// php cgi mode requires a work around
	if (!empty($_SERVER['REDIRECT_REMOTE_USER']) && strpos($_SERVER['REDIRECT_REMOTE_USER'], 'Basic ') === 0) {
		$credentials = substr($_SERVER['REDIRECT_REMOTE_USER'], strlen('Basic '));
		$credentials = base64_decode($credentials);
		if (strpos($credentials, ':')) {
			$credentials = explode(':', $credentials);
			return [
				'USER' => $credentials[0],
				'PW'   => $credentials[1],
			];
		}
	}
	
	return null;
}
1249941
private function isUserTokenAuthenticated()
    {
        try
        {
            $token = $this->TokenUser->getTokenInterface()->get();
            $this->TokenUser->validate($token);
        }
        catch (Exception $exception)
        {
            // We will re-throw this error later if no other authentication types give a successful result
            return $exception;
        }

        return true;
    }
459694
public static boolean isValidAuthentication(Authentication authentication) {
    if (authentication == null) {
      return false;
    }

    // if UserDetails are set then it must be of Class OwncloudUserDetails
    if (authentication.getDetails() != null && !ClassUtils.isAssignable(authentication.getPrincipal().getClass(), OwncloudUserDetails.class)) {
      return false;
    }

    if (authentication.getCredentials() != null) {
      // if Credentials are available then these must be of Class CharSequence and not empty
      return CharSequence.class.isAssignableFrom(authentication.getCredentials().getClass()) &&
          StringUtils.isNotBlank((CharSequence) authentication.getCredentials());
    }

    if (authentication.getPrincipal() != null) {
      // Password of the UserDetails must not be empty
      UserDetails userDetails = (UserDetails) authentication.getPrincipal();
      return StringUtils.isNotBlank(userDetails.getPassword());
    }

    return false;
  }
300852
private boolean isUserAuthorized(HttpServletRequest httpRequest) {
		if (authorizedUsers == null) {
			return true;
		}
		// Get Authorization header
		final String auth = httpRequest.getHeader("Authorization");
		if (auth == null) {
			return false; // no auth
		}
		if (!auth.toUpperCase(Locale.ENGLISH).startsWith("BASIC ")) {
			return false; // we only do BASIC
		}
		// Get encoded "user:password", comes after "BASIC "
		final String userpassEncoded = auth.substring("BASIC ".length());
		// Decode it
		final String userpassDecoded = Base64Coder.decodeString(userpassEncoded);

		final boolean authOk = authorizedUsers.contains(userpassDecoded);
		return checkLockAgainstBruteForceAttack(authOk);
	}
144792
private boolean authenticate(Session session, String userName, String password, PasswordEncrypter pe)
      throws Exception
   {
      boolean authenticated;

      Node userNode;
      try
      {
         userNode = utils.getUserNode(session, userName);
      }
      catch (PathNotFoundException e)
      {
         return false;
      }
      boolean enabled = userNode.canAddMixin(JCROrganizationServiceImpl.JOS_DISABLED);
      if (!enabled)
      {
         throw new DisabledUserException(userName);
      }

      if (pe == null)
      {
         authenticated = utils.readString(userNode, UserProperties.JOS_PASSWORD).equals(password);
      }
      else
      {
         String encryptedPassword =
            new String(pe.encrypt(utils.readString(userNode, UserProperties.JOS_PASSWORD).getBytes()));
         authenticated = encryptedPassword.equals(password);
      }
      if (authenticated)
      {
         Calendar lastLoginTime = Calendar.getInstance();
         userNode.setProperty(UserProperties.JOS_LAST_LOGIN_TIME, lastLoginTime);
         session.save();
      }
      return authenticated;
   }
411521
@Override
    public Authentication authenticate(Authentication authentication) throws AuthenticationException {
        if (authentication == null) {
            return authentication;
        }
        UsernamePasswordAuthenticationToken output = null;
        if (authentication instanceof UsernamePasswordAuthenticationToken) {
            output = (UsernamePasswordAuthenticationToken) authentication;
        } else {
            output = new UsernamePasswordAuthenticationToken(authentication, authentication.getCredentials(),
                            authentication.getAuthorities());
            output.setAuthenticated(authentication.isAuthenticated());
            output.setDetails(authentication.getDetails());
        }
        return delegate.authenticate(output);
    }
251597
@Nullable
    private BasicCredentials getCredentials(String header) {
        if (header == null) {
            return null;
        }

        final int space = header.indexOf(' ');
        if (space <= 0) {
            return null;
        }

        final String method = header.substring(0, space);
        if (!prefix.equalsIgnoreCase(method)) {
            return null;
        }

        final String decoded;
        try {
            decoded = new String(Base64.getDecoder().decode(header.substring(space + 1)), StandardCharsets.UTF_8);
        } catch (IllegalArgumentException e) {
            logger.warn("Error decoding credentials", e);
            return null;
        }

        // Decoded credentials is 'username:password'
        final int i = decoded.indexOf(':');
        if (i <= 0) {
            return null;
        }

        final String username = decoded.substring(0, i);
        final String password = decoded.substring(i + 1);
        return new BasicCredentials(username, password);
    }
407779
public boolean hasValidCredentials() {
        String accessToken = storage.retrieveString(KEY_ACCESS_TOKEN);
        String refreshToken = storage.retrieveString(KEY_REFRESH_TOKEN);
        String idToken = storage.retrieveString(KEY_ID_TOKEN);
        Long expiresAt = storage.retrieveLong(KEY_EXPIRES_AT);

        return !(isEmpty(accessToken) && isEmpty(idToken) ||
                expiresAt == null ||
                expiresAt <= getCurrentTimeInMillis() && refreshToken == null);
    }