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

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


        String userName = request.getHeader("Remote-User");
        if (StringUtils.isEmpty(userName)) {
            return super.authenticate(request, response);
        } else {
            return new AuthenticationToken(userName, userName, getType());
        }
    }
View Full Code Here


   */
  @Override
  public AuthenticationToken authenticate(HttpServletRequest request,
      HttpServletResponse response) throws IOException, AuthenticationException {

    AuthenticationToken token;
    String delegationParam = this.getEncodedDelegationTokenFromRequest(request);
    if (delegationParam != null) {
      Token<RMDelegationTokenIdentifier> dt =
          new Token<RMDelegationTokenIdentifier>();
      ;
      dt.decodeFromUrlString(delegationParam);
      UserGroupInformation ugi = this.verifyToken(dt);
      if (ugi == null) {
        throw new AuthenticationException("Invalid token");
      }
      final String shortName = ugi.getShortUserName();
      token = new AuthenticationToken(shortName, ugi.getUserName(), getType());
    } else {
      token = super.authenticate(request, response);
      if (token != null) {
        // create a token with auth type set correctly
        token =
            new AuthenticationToken(token.getUserName(), token.getName(),
              super.getType());
      }
    }
    return token;
  }
View Full Code Here

   */
  @Override
  public AuthenticationToken authenticate(HttpServletRequest request,
      HttpServletResponse response)
      throws IOException, AuthenticationException {
    AuthenticationToken token;
    String delegationParam =
        request
            .getParameter(TimelineAuthenticationConsts.DELEGATION_PARAM);
    if (delegationParam != null) {
      Token<TimelineDelegationTokenIdentifier> dt =
          new Token<TimelineDelegationTokenIdentifier>();
      dt.decodeFromUrlString(delegationParam);
      TimelineDelegationTokenSecretManagerService secretManager =
          AHSWebApp.getInstance()
              .getTimelineDelegationTokenSecretManagerService();
      UserGroupInformation ugi = secretManager.verifyToken(dt);
      final String shortName = ugi.getShortUserName();
      // creating a ephemeral token
      token = new AuthenticationToken(shortName, ugi.getUserName(), getType());
      token.setExpires(0);
    } else {
      token = super.authenticate(request, response);
    }
    return token;
  }
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

    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

     * @throws AuthenticationException thrown if an authentication error occurs
     */
    @Override
    public AuthenticationToken alternateAuthenticate(HttpServletRequest request, HttpServletResponse response)
            throws IOException, AuthenticationException {
        AuthenticationToken token = null;
        Cookie[] cookies = request.getCookies();
        Cookie authCookie = verifyAndExtractAltAuth(cookies);
        String altAuthUserName = getAltAuthUserName(authCookie);
        // Authenticated
        if (altAuthUserName != null) {
            token = new AuthenticationToken(altAuthUserName, altAuthUserName, getType());
        }
        // Not Authenticated
        else {
            StringBuffer sb = request.getRequestURL();
            if (request.getQueryString() != null) {
View Full Code Here

     * @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

     * @throws AuthenticationException thrown if an authentication error occurs
     */
    @Override
    public AuthenticationToken alternateAuthenticate(HttpServletRequest request, HttpServletResponse response)
            throws IOException, AuthenticationException {
        AuthenticationToken token = null;
        Cookie[] cookies = request.getCookies();
        Cookie authCookie = verifyAndExtractAltAuth(cookies);
        String altAuthUserName = getAltAuthUserName(authCookie);
        // Authenticated
        if (altAuthUserName != null) {
            token = new AuthenticationToken(altAuthUserName, altAuthUserName, getType());
        }
        // Not Authenticated
        else {
            StringBuffer sb = request.getRequestURL();
            if (request.getQueryString() != null) {
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.