Perform auth

@param infos connection information
@return auth
358006
public PqAuth doAuth(ConnectionInfo[] infos) {
        TransportRate rate = new TransportRate(infos);
        for (int i = 0; i < AUTH_ATTEMPT_COUNT; i++) {
            ConnectionType connectionType = rate.tryConnection();
            try {
                context = new PlainTcpConnection(connectionType.getHost(), connectionType.getPort());
                rate.onConnectionSuccess(connectionType.getId());
            } catch (IOException e) {
                Logger.e(TAG, e);
                rate.onConnectionFailure(connectionType.getId());
                continue;
            }

            try {
                return authAttempt();
            } catch (IOException e) {
                Logger.e(TAG, e);
            } finally {
                if (context != null) {
                    context.destroy();
                    context = null;
                }
            }

            try {
                Thread.sleep(300);
            } catch (InterruptedException e) {
                return null;
            }
        }
        return null;
    }
782199
def get_auth_info(self):
        
        try:
            response = self.session.get(self.auth_root, headers={
                'Accept': 'application/protobuf'
            })
            message = web_pb2.AuthInfo()
            message.ParseFromString(response.content)
            return AuthInfo(message)
        except requests.exceptions.ConnectionError:
            raise ConnectionFailure('Connection to {} refused'.format(self.address))
1022686
function createAuthDetails( request ) {
   var auth= { scopedUsers: {} };
   request._connect_auth= auth;
   if( request.session ) {
     request.session.auth= auth;
   }
 }
1144752
def _auth(uri):
    '''
    
    '''

    user, password = _get_credentials()
    if user is False or password is False:
        return False

    basic = _HTTPBasicAuthHandler()
    basic.add_password(realm='Tomcat Manager Application', uri=uri,
                       user=user, passwd=password)
    digest = _HTTPDigestAuthHandler()
    digest.add_password(realm='Tomcat Manager Application', uri=uri,
                        user=user, passwd=password)
    return _build_opener(basic, digest)
474675
public AuthParams newAuthParams(String name, long expires) {
        AuthParams set = new AuthParams();
        set.name(name);
        set.expires(expires);
        auth.add(set);
        return set;
    }
888993
public HFCAInfo info() throws InfoException, InvalidArgumentException {

        logger.debug(format("info url:%s", url));
        if (cryptoSuite == null) {
            throw new InvalidArgumentException("Crypto primitives not set.");
        }

        setUpSSL();

        try {

            JsonObjectBuilder factory = Json.createObjectBuilder();

            if (caName != null) {
                factory.add(HFCAClient.FABRIC_CA_REQPROP, caName);
            }
            JsonObject body = factory.build();

            String responseBody = httpPost(url + HFCA_INFO, body.toString(),
                    (UsernamePasswordCredentials) null);

            logger.debug("response:" + responseBody);

            JsonReader reader = Json.createReader(new StringReader(responseBody));
            JsonObject jsonst = (JsonObject) reader.read();

            boolean success = jsonst.getBoolean("success");
            logger.debug(format("[HFCAClient] enroll success:[%s]", success));

            if (!success) {
                throw new EnrollmentException(format("FabricCA failed info %s", url));
            }

            JsonObject result = jsonst.getJsonObject("result");
            if (result == null) {
                throw new InfoException(format("FabricCA info error  - response did not contain a result url %s", url));
            }

            String caName = result.getString("CAName");
            String caChain = result.getString("CAChain");
            String version = null;
            if (result.containsKey("Version")) {
                version = result.getString("Version");
            }
            String issuerPublicKey = null;
            if (result.containsKey("IssuerPublicKey")) {
                issuerPublicKey = result.getString("IssuerPublicKey");
            }
            String issuerRevocationPublicKey = null;
            if (result.containsKey("IssuerRevocationPublicKey")) {
                issuerRevocationPublicKey = result.getString("IssuerRevocationPublicKey");
            }

            logger.info(format("CA Name: %s, Version: %s, issuerPublicKey: %s, issuerRevocationPublicKey: %s", caName, caChain, issuerPublicKey, issuerRevocationPublicKey));
            return new HFCAInfo(caName, caChain, version, issuerPublicKey, issuerRevocationPublicKey);

        } catch (Exception e) {
            InfoException ee = new InfoException(format("Url:%s, Failed to get info", url), e);
            logger.error(e.getMessage(), e);
            throw ee;
        }

    }
279006
protected function _createSubject($token, $info, $existing, $roles=array())
    {
        global $logger;
        $context = $this->createSubjectContext();
        $context->setAuthenticated(true);
        $context->setAuthenticationToken($token);
        $context->setAuthenticationInfo($info);
        $context->setRoles($roles);
        if ($existing !== null)
            $context->setSubject($existing);
        return $this->createSubject($context);

    }
836212
public Set<Auth> createAuthsFromString(String authInfo) {

    if ("".equals(authInfo) || authInfo == null) return Collections.emptySet();

    String[] parts = authInfo.split(",");

    final Set<Auth> auths = new HashSet<Auth>();

    try {
      for (String auth : parts) {

        StringTokenizer tokenizer = new StringTokenizer(auth, ":");

        while (tokenizer.hasMoreTokens()) {
          auths.add(new Auth(tokenizer.nextToken(), tokenizer.nextToken(), tokenizer.nextToken(),
              tokenizer.nextToken()));
        }

      }

      return auths;
    } catch (NoSuchElementException e) {
      final StringBuilder b = new StringBuilder();
      for (String auth : parts) {
        b.append(auth);
      }
      throw new IllegalArgumentException(
          "Auth configuration is configured wrongly:" + b.toString(), e);
    }
  }
23349
@Override
    public Authentication execute() throws Auth0Exception {
        Credentials credentials = credentialsRequest.execute();
        UserProfile profile = userInfoRequest
                .addHeader(HEADER_AUTHORIZATION, "Bearer " + credentials.getAccessToken())
                .execute();
        return new Authentication(profile, credentials);
    }
1146164
function getAuthInfo($grants = false)
    {
        if ($this->_c_info)
            return $this->_c_info;


        $options = null;
        if ( $grants )
            $options['include_grants'] = true;

        try {
            $info = $this->federation()->getMyAccountInfo($options);

        } catch (exOAuthAccessDenied $e) {
            throw new exAccessDenied($e->getMessage(), $e->getCode(), $e);
        }

        return $this->_c_info = $info;
    }
765712
public AccountInfo getAccountInfo() {
        OAuthRequest request = new OAuthRequest(Verb.GET, INFO_URL);
        service.signRequest(accessToken, request);
        String content = check(request.send()).getBody();

        return Json.parse(content, AccountInfo.class);
    }
1106970
function auth (username, password, callback) {
    return relax({
      method: 'POST',
      db: '_session',
      form: {
        name: username,
        password: password
      }
    }, callback)
  }
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);
		}
	}
54733
@Restricted(NoExternalUse.class)
    public @Nonnull
    Authentication impersonate(@Nonnull UserDetails userDetails) {
        return new UsernamePasswordAuthenticationToken(userDetails.getUsername(), "", userDetails.getAuthorities());
    }
1227546
public static AuthRequest createAuthRequest (
            Credentials creds, String version, String[] bootGroups, boolean requireSecureAuth,
            PublicKeyCredentials pkcreds, SecureResponse resp)
    {
        byte[] secret = resp == null ? null : resp.getCodeBytes(pkcreds);
        if (pkcreds == null || secret == null) {
            return new AuthRequest(requireSecureAuth ? null : creds, version, bootGroups);
        }
        return new AESAuthRequest(secret, creds, version, bootGroups);
    }
562892
public CouchDB auth(String username, String password) {
        return username(username).password(password);
    }
543534
@Override
  public Access authenticate() {
    try {
      JSONObject user = new JSONObject();
      user.put("id", mUserId);
      user.put("password", mPassword);
      JSONObject password = new JSONObject();
      password.put("user", user);
      JSONArray methods = new JSONArray();
      methods.add("password");
      JSONObject identity = new JSONObject();
      identity.put("methods", methods);
      identity.put("password", password);
      JSONObject project = new JSONObject();
      project.put("id", mProjectId);
      JSONObject scope = new JSONObject();
      scope.put("project", project);
      JSONObject auth = new JSONObject();
      auth.put("identity", identity);
      auth.put("scope", scope);
      JSONObject requestBody = new JSONObject();
      requestBody.put("auth", auth);
      HttpURLConnection connection =
          (HttpURLConnection) new URL(mAuthUrl).openConnection();
      connection.setDoOutput(true);
      connection.setRequestProperty("Accept", "application/json");
      connection.setRequestProperty("Content-Type", "application/json");
      OutputStream output = connection.getOutputStream();
      output.write(requestBody.toString().getBytes());
      HttpStatusChecker.verifyCode(STATUS_CHECKERS, connection.getResponseCode());
      final String res;
      try (final BufferedReader bufReader =
          new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
        res = bufReader.readLine();
      }
      JSONParser parser = new JSONParser();
      JSONObject jsonResponse = (JSONObject) parser.parse(res);

      String token = connection.getHeaderField("X-Subject-Token");
      PasswordScopeAccess access = new PasswordScopeAccess(jsonResponse, token,
          mPrefferedRegion);
      connection.disconnect();
      return access;
    } catch (IOException | ParseException e) {
      LOG.error(e.getMessage());
      throw new CommandException("Unable to execute the HTTP call or to convert the HTTP Response",
              e);
    }
  }