Example #1
0
            /// <exception cref="System.Exception"/>
            public Void Run()
            {
                DelegationTokenAuthenticatedURL.Token token = new DelegationTokenAuthenticatedURL.Token
                                                                  ();
                DelegationTokenAuthenticatedURL aUrl = new DelegationTokenAuthenticatedURL();
                HttpURLConnection conn = aUrl.OpenConnection(url, token, TestWebDelegationToken.OkUser
                                                             );

                Assert.Equal(HttpURLConnection.HttpOk, conn.GetResponseCode());
                IList <string> ret = IOUtils.ReadLines(conn.GetInputStream());

                Assert.Equal(1, ret.Count);
                Assert.Equal(TestWebDelegationToken.OkUser, ret[0]);
                conn = aUrl.OpenConnection(url, token, TestWebDelegationToken.FailUser);
                Assert.Equal(HttpURLConnection.HttpForbidden, conn.GetResponseCode
                                 ());
                aUrl.GetDelegationToken(url, token, TestWebDelegationToken.FooUser);
                UserGroupInformation ugi = UserGroupInformation.GetCurrentUser();

                ugi.AddToken(token.GetDelegationToken());
                token = new DelegationTokenAuthenticatedURL.Token();
                conn  = aUrl.OpenConnection(url, token, TestWebDelegationToken.OkUser);
                Assert.Equal(HttpURLConnection.HttpOk, conn.GetResponseCode());
                ret = IOUtils.ReadLines(conn.GetInputStream());
                Assert.Equal(1, ret.Count);
                Assert.Equal(TestWebDelegationToken.FooUser, ret[0]);
                return(null);
            }
Example #2
0
            /// <exception cref="System.Exception"/>
            public Void Run()
            {
                DelegationTokenAuthenticatedURL.Token token = new DelegationTokenAuthenticatedURL.Token
                                                                  ();
                DelegationTokenAuthenticatedURL aUrl = new DelegationTokenAuthenticatedURL();
                HttpURLConnection conn = aUrl.OpenConnection(url, token);

                Assert.Equal(HttpURLConnection.HttpOk, conn.GetResponseCode());
                IList <string> ret = IOUtils.ReadLines(conn.GetInputStream());

                Assert.Equal(1, ret.Count);
                Assert.Equal("remoteuser="******":ugi=" + TestWebDelegationToken.FooUser, ret[0]);
                conn = aUrl.OpenConnection(url, token, TestWebDelegationToken.OkUser);
                Assert.Equal(HttpURLConnection.HttpOk, conn.GetResponseCode());
                ret = IOUtils.ReadLines(conn.GetInputStream());
                Assert.Equal(1, ret.Count);
                Assert.Equal("realugi=" + TestWebDelegationToken.FooUser + ":remoteuser="******":ugi=" + TestWebDelegationToken.OkUser, ret[
                                 0]);
                return(null);
            }
Example #3
0
            /// <exception cref="System.Exception"/>
            public Void Run()
            {
                DelegationTokenAuthenticatedURL.Token token = new DelegationTokenAuthenticatedURL.Token
                                                                  ();
                DelegationTokenAuthenticatedURL aUrl = new DelegationTokenAuthenticatedURL();
                HttpURLConnection conn = aUrl.OpenConnection(url, token);

                Assert.Equal(HttpURLConnection.HttpOk, conn.GetResponseCode());
                IList <string> ret = IOUtils.ReadLines(conn.GetInputStream());

                Assert.Equal(1, ret.Count);
                Assert.Equal(TestWebDelegationToken.FooUser, ret[0]);
                aUrl.GetDelegationToken(url, token, TestWebDelegationToken.FooUser);
                NUnit.Framework.Assert.IsNotNull(token.GetDelegationToken());
                Assert.Equal(new Text("token-kind"), token.GetDelegationToken(
                                 ).GetKind());
                return(null);
            }
Example #4
0
            /// <exception cref="System.Exception"/>
            public Void Run()
            {
                DelegationTokenAuthenticatedURL.Token token = new DelegationTokenAuthenticatedURL.Token
                                                                  ();
                DelegationTokenAuthenticatedURL aUrl = new DelegationTokenAuthenticatedURL();
                HttpURLConnection conn = aUrl.OpenConnection(url, token);

                Assert.Equal(HttpURLConnection.HttpOk, conn.GetResponseCode());
                IList <string> ret = IOUtils.ReadLines(conn.GetInputStream());

                Assert.Equal(1, ret.Count);
                Assert.Equal(TestWebDelegationToken.FooUser, ret[0]);
                try
                {
                    aUrl.GetDelegationToken(url, token, TestWebDelegationToken.FooUser);
                    NUnit.Framework.Assert.Fail();
                }
                catch (AuthenticationException ex)
                {
                    Assert.True(ex.Message.Contains("delegation token operation"));
                }
                return(null);
            }