Пример #1
0
func GetDigestMD5ChallengeResponse(protocol string, serverId string, challenge []byte, userToken *hadoop_common.TokenProto) (string, error) {
	if len(challenge) <= 0 {
		log.Fatal("challenge cannot be empty!")

		return "", errors.New("challenge cannot be empty!")
	}

	var err error

	challengeParams, err := getChallengeParams(string(challenge))
	if err != nil {
		log.Fatal("challenge params extraction failure! ", err)
		return "", err
	}

	err = validateChallengeParameters(challengeParams)
	if err != nil {
		log.Fatal("challenge params validation failure! ", err)
		return "", err
	}

	username := base64.StdEncoding.EncodeToString(userToken.GetIdentifier())
	password := base64.StdEncoding.EncodeToString(userToken.GetPassword())
	response, err := generateChallengeReponse(username, password, protocol, serverId, challengeParams)

	if err != nil {
		log.Fatal("Failed to generate challenge response! ", err)
		return "", err
	}

	return response, nil
}
Пример #2
0
func (ugi *UserGroupInformation) AddUserToken(token *hadoop_common.TokenProto) {
	if token == nil {
		log.Fatal("supplied token is nil!")
		return
	}

	ugi.AddUserTokenWithAlias(token.GetService(), token)
}