Create user:password string for authentication.

@return user:password string
343660
public static String getBasicAuthenticationEncoding(String username, String password) throws FoxHttpRequestException {
        String userPassword = username + ":" + password;

        Class<?> base64;
        try {
            base64 = Class.forName("java.util.Base64");
            Object objectToInvokeOn = base64.getEnclosingClass();
            Method encoderMethod = base64.getDeclaredMethod("getEncoder");
            Object encoder = encoderMethod.invoke(objectToInvokeOn);
            Method method = encoder.getClass().getDeclaredMethod("encodeToString", byte[].class);

            return (String) (method.invoke(encoder, (Object) userPassword.getBytes()));
        } catch (ClassNotFoundException e) {
            try {
                base64 = Class.forName("android.util.Base64");

                Object objectToInvokeOn = base64.getEnclosingClass();
                Method encoderMethod = base64.getDeclaredMethod("encodeToString", byte[].class, int.class);

                return (String) (encoderMethod.invoke(objectToInvokeOn, userPassword.getBytes(), 2));
            } catch (Exception e1) {
                throw new FoxHttpRequestException(e1);
            }
        } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
            throw new FoxHttpRequestException(e);
        }

    }
1024345
def generate_reset_password_token(self, user):
        
        password_hash = self.hash_data(user.password) if user.password else None
        data = [str(user.id), password_hash]
        return self.security.reset_serializer.dumps(data)
292095
def create_user(self, username, password, tags=""):
        
        path = Client.urls['users_by_name'] % username
        body = json.dumps({'password': password, 'tags': tags})
        return self._call(path, 'PUT', body=body,
                                 headers=Client.json_headers)
225885
public T authentication(String username, String password) {
        return authentication(username, password, false);
    }
25069
def create_user(self, user_object, password):
        
        LOGGER.warning("Creating User %s", user_object['username'])

        try:
            return self.user_service.createObject(user_object, password, None)
        except exceptions.SoftLayerAPIError as ex:
            if ex.faultCode == "SoftLayer_Exception_User_Customer_DelegateIamIdInvitationToPaas":
                raise exceptions.SoftLayerError("Your request for a new user was received, but it needs to be "
                                                "processed by the Platform Services API first. Barring any errors on "
                                                "the Platform Services side, your new user should be created shortly.")
            raise
870508
def generate_password():
    
    chars = uppercase + lowercase + digits
    return ''.join(SystemRandom().choice(chars) for x in xrange(16))
998167
def create_user(self, username, password, roles):
    
    return users.create_user(self, username, password, roles)
890792
def create_token(self, user):
        
        # The password is expected to be a secure hash but we hash it again
        # for additional safety. We default to MD5 to minimize the length of
        # the token. (Remember, if an attacker obtains the URL, he can already
        # log in. This isn't high security.)
        h = crypto.pbkdf2(
            self.get_revocation_key(user),
            self.salt,
            self.iterations,
            digest=self.digest,
        )
        return self.sign(self.packer.pack_pk(user.pk) + h)
731403
def set_password(self, user, password):
        
        url = self._build_url(self.endpoint.set_password(id=user))
        return self._post(url, payload=dict(password=password))
759521
def basic_auth_string(username, password):
    
    b64 = base64.encodestring('%s:%s' % (username, password)).strip()
    return 'Basic %s' % b64
1334241
public static Map<String, String> createBasicAuthenticationProperty(final String username, final String password) {
        Map<String, String> map = new TreeMap<String, String>();
        try {
            String base64Binary = DatatypeConverter.printBase64Binary((username + ":" + password).getBytes("US-ASCII"));
            map.put("Authorization", "Basic " + base64Binary);
        } catch (UnsupportedEncodingException e) {
            // unreachable code
            throw new RuntimeException(e);
        }
        return map;
    }
666216
public static String encodePassword(final char[] password) {
        if (password == null) {
            return null;
        }
        final EncodedStringConverter converter = new EncodedStringConverter();
        return converter.toString(new String(password));
    }
452259
private static String encodeAuthPlain(String username, char[] password) {
        // PLAIN mechanism encoding - NUL + username + NUL + password
        int size = username.length() + password.length + 2;
        ByteBuffer buffer = ByteBuffer.allocate(size);
        buffer.put((byte)0);
        buffer.put(username.getBytes());
        buffer.put((byte)0);
        buffer.put(new String(password).getBytes());
        
        buffer.flip();
        
        // Nulling out the password for security. 
        Arrays.fill(password, '\0');

        int len = buffer.remaining();
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < len; i++)
        {
            builder.append((char)(buffer.get() & 0xff)); 

        }
        String s = builder.toString();
        return s;

    }
1365717
def login(username, password)
      params = { grant_type: "password", username: username, password: password }
      response = self['token'].get({ params: params })
      user_uuid = response.data['user']['uuid']
      user_access_token = response.data['access_token']
      Thread.current[:usergrid_user_id] = user_uuid
      Thread.current[:usergrid_auth_token] = user_access_token
      @current_user = self["/users/#{user_uuid}"].get.entity
      response
    end
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;
    }
1196916
protected String buildBasicAuthValue(String user, String password){
		StringBuilder sb = new StringBuilder();
		if (StringUtils.isNotEmpty(user)){
			sb.append(user);
		}
		if (StringUtils.isNotEmpty(password)){
			if (sb.length() > 0){
				sb.append(':');
			}
			sb.append(password);
		}
		return buildBasicAuthValue(sb.toString());
	}
811350
def generate_reset_password_token(user):
    # type: (User) -> Any
    
    data = [str(user.id), md5(user.password)]
    return get_serializer("reset").dumps(data)