Пример #1
0
        protected internal virtual string Serialize(LegacyCredential cred)
        {
            string encodedSalt     = HexString.encodeHexString(cred.Salt());
            string encodedPassword = HexString.encodeHexString(cred.PasswordHash());

            return(string.join(CREDENTIAL_SEPARATOR, LegacyCredential.DIGEST_ALGO, encodedPassword, encodedSalt));
        }
Пример #2
0
        public virtual string AsHex()
        {
            // Convert the flags to a byte-array, each
            // flag represented as a single bit.
            sbyte[] bits = new sbyte[_flags.Length / 8];

            // Go over the flags, eight at a time to align
            // with sticking eight bits at a time into the
            // output array.
            for (int i = 0; i < _flags.Length; i += 8)
            {
                bits[i / 8] = ( sbyte )((Bit(i) << 7) | (Bit(i + 1) << 6) | (Bit(i + 2) << 5) | (Bit(i + 3) << 4) | (Bit(i + 4) << 3) | (Bit(i + 5) << 2) | (Bit(i + 6) << 1) | (Bit(i + 7)));
            }
            return(HexString.encodeHexString(bits));
        }
Пример #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private LegacyCredential deserializeCredentials(String part, int lineNumber) throws org.neo4j.server.security.auth.exception.FormatException
        private LegacyCredential DeserializeCredentials(string part, int lineNumber)
        {
            string[] split = part.Split(CREDENTIAL_SEPARATOR, false);
            if (split.Length != 3)
            {
                throw new FormatException(format("wrong number of credential fields [line %d]", lineNumber));
            }
            if (!split[0].Equals(LegacyCredential.DIGEST_ALGO))
            {
                throw new FormatException(format("unknown digest \"%s\" [line %d]", split[0], lineNumber));
            }
            sbyte[] decodedPassword = HexString.decodeHexString(split[1]);
            sbyte[] decodedSalt     = HexString.decodeHexString(split[2]);
            return(new LegacyCredential(decodedSalt, decodedPassword));
        }