Package org.apache.hadoop.security.authentication.server

Examples of org.apache.hadoop.security.authentication.server.AuthenticationToken


     * @throws AuthenticationException thrown if an authentication error occurred
     */
    @Override
    public AuthenticationToken authenticate(HttpServletRequest request, HttpServletResponse response)
            throws IOException, AuthenticationException {
        AuthenticationToken token;
        if (isBrowser(request.getHeader("User-Agent"))) {
            token = alternateAuthenticate(request, response);
        }
        else {
            token = super.authenticate(request, response);
View Full Code Here


        // We need the request to return the auth cookie
        Cookie[] cookies = {new Cookie("some.other.cookie", "someValue"),
                            new Cookie("oozie.web.login.auth", "someUser")};
        Mockito.when(request.getCookies()).thenReturn(cookies);

        AuthenticationToken token = handler.authenticate(request, response);
        assertEquals("someUser", token.getUserName());
        assertEquals("someUser", token.getName());
        assertEquals("alt-kerberos", token.getType());
    }
View Full Code Here

        // We need the request to return the auth cookie
        Cookie[] cookies = {new Cookie("some.other.cookie", "someValue"),
                            new Cookie("oozie.web.login.auth", "\"someUser\"")};
        Mockito.when(request.getCookies()).thenReturn(cookies);

        AuthenticationToken token = handler.authenticate(request, response);
        assertEquals("someUser", token.getUserName());
        assertEquals("someUser", token.getName());
        assertEquals("alt-kerberos", token.getType());
    }
View Full Code Here

    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    Assert.assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED,
                        conn.getResponseCode());


    AuthenticationToken token =
      new AuthenticationToken("u", "p",
        HttpFSKerberosAuthenticationHandlerForTesting.TYPE);
    token.setExpires(System.currentTimeMillis() + 100000000);
    Signer signer = new Signer("secret".getBytes());
    String tokenSigned = signer.sign(token.toString());

    url = new URL(TestJettyHelper.getJettyURL(),
                  "/webhdfs/v1/?op=GETHOMEDIRECTORY");
    conn = (HttpURLConnection) url.openConnection();
    conn.setRequestProperty("Cookie",
View Full Code Here

    Mockito.when(request.getParameter(HttpFSFileSystem.OP_PARAM)).
      thenReturn(op.toString());
    Mockito.when(request.getMethod()).
      thenReturn(op.getHttpMethod());

    AuthenticationToken token = Mockito.mock(AuthenticationToken.class);
    Mockito.when(token.getUserName()).thenReturn("user");
    Assert.assertFalse(handler.managementOperation(null, request, response));
    Mockito.when(request.getParameter(HttpFSKerberosAuthenticator.RENEWER_PARAM)).
      thenReturn(renewer);

    Mockito.reset(response);
View Full Code Here

    Mockito.verify(response).sendError(
      Mockito.eq(HttpServletResponse.SC_UNAUTHORIZED),
      Mockito.contains("equires SPNEGO authentication established"));

    Mockito.reset(response);
    AuthenticationToken token = Mockito.mock(AuthenticationToken.class);
    Mockito.when(token.getUserName()).thenReturn("user");
    Assert.assertFalse(handler.managementOperation(token, request, response));
    Mockito.verify(response).sendError(
      Mockito.eq(HttpServletResponse.SC_BAD_REQUEST),
      Mockito.contains("requires the parameter [token]"));
View Full Code Here

      HttpFSServerWebApp.get().get(DelegationTokenManager.class).createToken(
        UserGroupInformation.getCurrentUser(), "user");
    Mockito.when(request.getParameter(HttpFSKerberosAuthenticator.DELEGATION_PARAM)).
      thenReturn(dToken.encodeToUrlString());

    AuthenticationToken token = handler.authenticate(request, response);
    Assert.assertEquals(UserGroupInformation.getCurrentUser().getShortUserName(),
                        token.getUserName());
    Assert.assertEquals(0, token.getExpires());
    Assert.assertEquals(HttpFSKerberosAuthenticationHandler.TYPE,
                        token.getType());
    Assert.assertTrue(token.isExpired());
  }
View Full Code Here

   */
  @Override
  public AuthenticationToken authenticate(HttpServletRequest request,
                                          HttpServletResponse response)
    throws IOException, AuthenticationException {
    AuthenticationToken token;
    String delegationParam =
      request.getParameter(HttpFSKerberosAuthenticator.DELEGATION_PARAM);
    if (delegationParam != null) {
      try {
        Token<DelegationTokenIdentifier> dt =
          new Token<DelegationTokenIdentifier>();
        dt.decodeFromUrlString(delegationParam);
        DelegationTokenManager tokenManager =
          HttpFSServerWebApp.get().get(DelegationTokenManager.class);
        UserGroupInformation ugi = tokenManager.verifyToken(dt);
        final String shortName = ugi.getShortUserName();

        // creating a ephemeral token
        token = new AuthenticationToken(shortName, ugi.getUserName(),
                                        getType());
        token.setExpires(0);
      } catch (Throwable ex) {
        throw new AuthenticationException("Could not verify DelegationToken, " +
                                          ex.toString(), ex);
      }
    } else {
View Full Code Here

    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    Assert.assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED,
                        conn.getResponseCode());


    AuthenticationToken token =
      new AuthenticationToken("u", "p",
        HttpFSKerberosAuthenticationHandlerForTesting.TYPE);
    token.setExpires(System.currentTimeMillis() + 100000000);
    Signer signer = new Signer("secret".getBytes());
    String tokenSigned = signer.sign(token.toString());

    url = new URL(TestJettyHelper.getJettyURL(),
                  "/webhdfs/v1/?op=GETHOMEDIRECTORY");
    conn = (HttpURLConnection) url.openConnection();
    conn.setRequestProperty("Cookie",
View Full Code Here

    Mockito.when(request.getParameter(HttpFSFileSystem.OP_PARAM)).
      thenReturn(op.toString());
    Mockito.when(request.getMethod()).
      thenReturn(op.getHttpMethod());

    AuthenticationToken token = Mockito.mock(AuthenticationToken.class);
    Mockito.when(token.getUserName()).thenReturn("user");
    Assert.assertFalse(handler.managementOperation(null, request, response));
    Mockito.when(request.getParameter(HttpFSKerberosAuthenticator.RENEWER_PARAM)).
      thenReturn(renewer);

    Mockito.reset(response);
View Full Code Here

TOP

Related Classes of org.apache.hadoop.security.authentication.server.AuthenticationToken

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.