Пример #1
0
        /// <summary>
        /// Deserializes a base64-encoded binary representation of a block access
        /// token.
        /// </summary>
        /// <param name="str">String to deserialize</param>
        /// <returns>BlockTokenIdentifier deserialized from str</returns>
        /// <exception cref="System.IO.IOException">if there is any I/O error</exception>
        private BlockTokenIdentifier DeserializeIdentifier(string str)
        {
            BlockTokenIdentifier identifier = new BlockTokenIdentifier();

            identifier.ReadFields(new DataInputStream(new ByteArrayInputStream(Base64.DecodeBase64
                                                                                   (str))));
            return(identifier);
        }
Пример #2
0
        /// <summary>
        /// Calculates the expected correct password on the server side for the
        /// general-purpose handshake.
        /// </summary>
        /// <remarks>
        /// Calculates the expected correct password on the server side for the
        /// general-purpose handshake.  The password consists of the block access
        /// token's password (known to the DataNode via its secret manager).  This
        /// expects that the client has supplied a user name consisting of its
        /// serialized block access token identifier.
        /// </remarks>
        /// <param name="userName">
        /// SASL user name containing serialized block access token
        /// identifier
        /// </param>
        /// <returns>expected correct SASL password</returns>
        /// <exception cref="System.IO.IOException">for any error</exception>
        private char[] BuildServerPassword(string userName)
        {
            BlockTokenIdentifier identifier = DeserializeIdentifier(userName);

            byte[] tokenPassword = blockPoolTokenSecretManager.RetrievePassword(identifier);
            return((new string(Base64.EncodeBase64(tokenPassword, false), Charsets.Utf8)).ToCharArray
                       ());
        }
Пример #3
0
            /// <exception cref="System.Exception"/>
            public LocatedBlocks Answer(InvocationOnMock arg0)
            {
                LocatedBlocks locatedBlocks = (LocatedBlocks)arg0.CallRealMethod();

                foreach (LocatedBlock lb in locatedBlocks.GetLocatedBlocks())
                {
                    Org.Apache.Hadoop.Security.Token.Token <BlockTokenIdentifier> token = lb.GetBlockToken
                                                                                              ();
                    BlockTokenIdentifier id = lb.GetBlockToken().DecodeIdentifier();
                    id.SetExpiryDate(Time.Now() + 10);
                    Org.Apache.Hadoop.Security.Token.Token <BlockTokenIdentifier> newToken = new Org.Apache.Hadoop.Security.Token.Token
                                                                                             <BlockTokenIdentifier>(id.GetBytes(), token.GetPassword(), token.GetKind(), token
                                                                                                                    .GetService());
                    lb.SetBlockToken(newToken);
                }
                return(locatedBlocks);
            }