/* (non-Javadoc)
@see com.att.cadi.aaf.v2_0.AAFCon#basicAuth(java.lang.String, java.lang.String)
181372
@Override
	public SecuritySetter<HttpURLConnection> basicAuth(String user, String password) throws CadiException {
		if(password.startsWith("enc:???")) {
			try {
				password = access.decrypt(password, true);
			} catch (IOException e) {
				throw new CadiException("Error decrypting password",e);
			}
		}
		try {
			return new HBasicAuthSS(user,password,si);
		} catch (IOException e) {
			throw new CadiException("Error creating HBasicAuthSS",e);
		}
	}
595996
def basicauthfail(self, realm = b'all'):
        
        if not isinstance(realm, bytes):
            realm = realm.encode('ascii')
        self.start_response(401, [(b'WWW-Authenticate', b'Basic realm="' + realm + b'"')])
        self.exit(b'<h1>' + _createstatus(401) + b'</h1>')
333984
public void setUsername(String username) {
        for (Authentication auth : authentications.values()) {
            if (auth instanceof HttpBasicAuth) {
                ((HttpBasicAuth) auth).setUsername(username);
                return;
            }
        }
        throw new RuntimeException("No HTTP basic authentication configured!");
    }
1290815
public static Result parse(String pAuthInfo) {
        StringTokenizer stok = new StringTokenizer(pAuthInfo);
        String method = stok.nextToken();
        if (!HttpServletRequest.BASIC_AUTH.equalsIgnoreCase(method)) {
            throw new IllegalArgumentException("Only BasicAuthentication is supported");
        }

        String b64Auth = stok.nextToken();
        String auth = new String(Base64Util.decode(b64Auth));

        int p = auth.indexOf(':');
        String user;
        String password;
        boolean valid;
        if (p != -1) {
            user = auth.substring(0, p);
            password = auth.substring(p+1);
            valid = true;
        } else {
            valid = false;
            user = null;
            password = null;
        }
        return new Result(method,user,password,valid);
    }
596355
public String authenticateBASIC(final HttpServletRequest request) {
        LOG.debug("authenticateBASIC");
        boolean valid = false;
        String userID = null;
        String password = null;
        try {
            final String authHeader = request.getHeader("Authorization");
            if (authHeader != null) {
                final StringTokenizer st = new StringTokenizer(authHeader);
                if (st.hasMoreTokens()) {
                    final String basic = st.nextToken();
                    if (basic.equalsIgnoreCase("Basic")) {
                        final String credentials = st.nextToken();
                        final String userPass = new String(Base64.decodeBase64(credentials.getBytes()));
                        final int p = userPass.indexOf(":");
                        if (p != -1) {
                            userID = userPass.substring(0, p);
                            password = userPass.substring(p + 1);

                            // Validate the User.
                            valid = validateUser(userID, password);
                        }
                    }
                }
            }
        } catch (final Exception e) {
            LOG.debug("An error occured while processing Basic authentication", e);
        }
        if (valid) {
            // For now assume userID as userName
            return userID;
        }
        return null;
    }
654476
def basicauth(self, realm = b'all', nofail = False):
        ""
        if b'authorization' in self.headerdict:
            auth = self.headerdict[b'authorization']
            auth_pair = auth.split(b' ', 1)
            if len(auth_pair) < 2:
                raise HttpInputException('Authorization header is malformed')
            if auth_pair[0].lower() == b'basic':
                try:
                    userpass = base64.b64decode(auth_pair[1])
                except Exception:
                    raise HttpInputException('Invalid base-64 string')
                userpass_pair = userpass.split(b':', 1)
                if len(userpass_pair) != 2:
                    raise HttpInputException('Authorization header is malformed')
                return userpass_pair
        if nofail:
            return (None, None)
        else:
            self.basicauthfail(realm)
1187067
public CLIConnectionFactory basicAuth(String userInfo) {
        return authorization("Basic " + new String(Base64.encodeBase64((userInfo).getBytes())));
    }
620112
func BasicAuth(username, password string) ClientOption {
	return func(config *RealisConfig) {
		config.username = username
		config.password = password
	}
}
592296
private static String generateBase64Authentication(String username, String password) {
    requireNonNull(username, password);
    String userPass = username + ":" + password;
    String userPassBase64 = Base64.getEncoder().encodeToString(userPass.getBytes(UTF_8));
    return "Basic " + userPassBase64;
  }
244833
func BasicAuther(username, password string) Handler {
	return Handler{
		Name: "BasicAuther",
		Fn: func(r *Request) {
			r.HTTPRequest.SetBasicAuth(username, password)
		},
	}
}
1078582
protected void startMakingOAuthAPICall(final String code, final String baseDomain) {
        if (apiCallStarted.getAndSet(true)) {
            return;
        }
        showSpinner();
        if (baseDomain != null) {
            mSession.getAuthInfo().setBaseDomain(baseDomain);
            BoxLogUtils.nonFatalE("setting Base Domain", baseDomain, new RuntimeException("base domain being used"));
        }
        new Thread(){
            public void run(){
                try {
                    BoxAuthenticationInfo sessionAuth = BoxAuthentication.getInstance().create(mSession, code).get();

                    String restrictedUserId = getIntent().getStringExtra(EXTRA_USER_ID_RESTRICTION);
                    if (!SdkUtils.isEmptyString(restrictedUserId) && !sessionAuth.getUser().getId().equals(restrictedUserId)){
                        // the user logged in as does not match the user id this activity was restricted to, treat this as a failure.
                        throw new RuntimeException("Unexpected user logged in. Expected "+ restrictedUserId + " received " + sessionAuth.getUser().getId());
                    }
                    dismissSpinnerAndFinishAuthenticate(sessionAuth);
                } catch (Exception e){
                    e.printStackTrace();
                    dismissSpinnerAndFailAuthenticate(e);
                }


            }
        }.start();
    }
1237091
@SuppressWarnings("unused")
    public void setBasicAuth(@Nullable String username, @Nullable String password) {
        mUsername = username;
        mPassword = password;
    }
666650
protected boolean startAuthentication(final C context, final List<Client> currentClients) {
        return isNotEmpty(currentClients) && currentClients.get(0) instanceof IndirectClient;
    }
173383
func BasicAuth(fn BasicAuthValidator) echo.MiddlewareFunc {
	c := DefaultBasicAuthConfig
	c.Validator = fn
	return BasicAuthWithConfig(c)
}
1201389
public static String getBasicAuth(String user, final String pass) {

    return "Basic " + java.util.Base64.getEncoder().encodeToString((user + ":" + pass).getBytes());
  }
62400
def process_basic_auth(auth)
      case auth
      when String
        self.login, self.password = auth.split(':', 2)
      when Hash
        self.login    = auth[:login]
        self.password = auth[:password]
      end
    end
631864
@Override
	public SecuritySetter<HttpURLConnection> basicAuthSS(BasicPrincipal principal) throws CadiException {
		try {
			return new HBasicAuthSS(principal,si);
		} catch (IOException e) {
			throw new CadiException("Error creating HBasicAuthSS",e);
		}
	}