/// <exception cref="System.IO.IOException"/> public virtual void TestDecodeIdentifier() { TestDelegationToken.TestDelegationTokenSecretManager secretManager = new TestDelegationToken.TestDelegationTokenSecretManager (0, 0, 0, 0); secretManager.StartThreads(); TestDelegationToken.TestDelegationTokenIdentifier id = new TestDelegationToken.TestDelegationTokenIdentifier (new Text("owner"), new Text("renewer"), new Text("realUser")); Org.Apache.Hadoop.Security.Token.Token <TestDelegationToken.TestDelegationTokenIdentifier > token = new Org.Apache.Hadoop.Security.Token.Token <TestDelegationToken.TestDelegationTokenIdentifier >(id, secretManager); TokenIdentifier idCopy = token.DecodeIdentifier(); NUnit.Framework.Assert.AreNotSame(id, idCopy); Assert.Equal(id, idCopy); }
/// <summary> /// Get the token identifier object, or null if it could not be constructed /// (because the class could not be loaded, for example). /// </summary> /// <returns>the token identifier, or null</returns> /// <exception cref="System.IO.IOException"></exception> public virtual T DecodeIdentifier() { Type cls = GetClassForIdentifier(GetKind()); if (cls == null) { return(null); } TokenIdentifier tokenIdentifier = ReflectionUtils.NewInstance(cls, null); ByteArrayInputStream buf = new ByteArrayInputStream(identifier); DataInputStream @in = new DataInputStream(buf); tokenIdentifier.ReadFields(@in); @in.Close(); return((T)tokenIdentifier); }