private String getUsername(HttpServletRequest request, String authType) throws HttpAuthenticationException { String creds[] = getAuthHeaderTokens(request, authType); // Username must be present if (creds[0] == null || creds[0].isEmpty()) { throw new HttpAuthenticationException("Authorization header received " + "from the client does not contain username."); } return creds[0]; }
response.addHeader(HttpAuthUtils.WWW_AUTHENTICATE, HttpAuthUtils.NEGOTIATE); response.getWriter().println("Authentication Error: " + e.getMessage());
private String getPassword(HttpServletRequest request, String authType) throws HttpAuthenticationException { String creds[] = getAuthHeaderTokens(request, authType); // Password must be present if (creds[1] == null || creds[1].isEmpty()) { throw new HttpAuthenticationException("Authorization header received " + "from the client does not contain username."); } return creds[1]; }
response.addHeader(HttpAuthUtils.WWW_AUTHENTICATE, HttpAuthUtils.NEGOTIATE); response.getWriter().println("Authentication Error: " + e.getMessage());
private String doTokenAuth(HttpServletRequest request, HttpServletResponse response) throws HttpAuthenticationException { String tokenStr = request.getHeader(HIVE_DELEGATION_TOKEN_HEADER); try { return hiveAuthFactory.verifyDelegationToken(tokenStr); } catch (HiveSQLException e) { throw new HttpAuthenticationException(e); } }
response.addHeader(HttpAuthUtils.WWW_AUTHENTICATE, HttpAuthUtils.NEGOTIATE); response.getWriter().println("Authentication Error: " + e.getMessage());
throw new HttpAuthenticationException("Authorization header received " + "from the client does not contain any data.");
response.addHeader(HttpAuthUtils.WWW_AUTHENTICATE, HttpAuthUtils.NEGOTIATE); response.getWriter().println("Authentication Error: " + e.getMessage());
throw new HttpAuthenticationException(e);
response.addHeader(HttpAuthUtils.WWW_AUTHENTICATE, HttpAuthUtils.NEGOTIATE); response.getWriter().println("Authentication Error: " + e.getMessage());
private String getPrincipalWithoutRealmAndHost(String fullPrincipal) throws HttpAuthenticationException { KerberosNameShim fullKerberosName; try { fullKerberosName = ShimLoader.getHadoopShims().getKerberosNameShim(fullPrincipal); return fullKerberosName.getShortName(); } catch (IOException e) { throw new HttpAuthenticationException(e); } } }
response.addHeader(HttpAuthUtils.WWW_AUTHENTICATE, HttpAuthUtils.NEGOTIATE); response.getWriter().println("Authentication Error: " + e.getMessage());
private String getPrincipalWithoutRealm(String fullPrincipal) throws HttpAuthenticationException { KerberosNameShim fullKerberosName; try { fullKerberosName = ShimLoader.getHadoopShims().getKerberosNameShim(fullPrincipal); } catch (IOException e) { throw new HttpAuthenticationException(e); } String serviceName = fullKerberosName.getServiceName(); String hostName = fullKerberosName.getHostName(); String principalWithoutRealm = serviceName; if (hostName != null) { principalWithoutRealm = serviceName + "/" + hostName; } return principalWithoutRealm; }
/** * Do the LDAP/PAM authentication * @param request * @param authType * @throws HttpAuthenticationException */ private String doPasswdAuth(HttpServletRequest request, String authType) throws HttpAuthenticationException { String userName = getUsername(request, authType); // No-op when authType is NOSASL if (!authType.equalsIgnoreCase(HiveAuthConstants.AuthTypes.NOSASL.toString())) { try { AuthMethods authMethod = AuthMethods.getValidAuthMethod(authType); PasswdAuthenticationProvider provider = AuthenticationProviderFactory.getAuthenticationProvider(authMethod, hiveConf); provider.Authenticate(userName, getPassword(request, authType)); } catch (Exception e) { throw new HttpAuthenticationException(e); } } return userName; }
throw new HttpAuthenticationException("Kerberos authentication failed: " + "unable to establish context with the service ticket " + "provided by the client."); throw new HttpAuthenticationException("Kerberos authentication failed: ", e);
private String getUsername(HttpServletRequest request, String authType) throws HttpAuthenticationException { String[] creds = getAuthHeaderTokens(request, authType); // Username must be present if (creds[0] == null || creds[0].isEmpty()) { throw new HttpAuthenticationException("Authorization header received " + "from the client does not contain username."); } return creds[0]; }
private String getUsername(HttpServletRequest request, String authType) throws HttpAuthenticationException { String creds[] = getAuthHeaderTokens(request, authType); // Username must be present if (creds[0] == null || creds[0].isEmpty()) { throw new HttpAuthenticationException("Authorization header received " + "from the client does not contain username."); } return creds[0]; }
private String getPassword(HttpServletRequest request, String authType) throws HttpAuthenticationException { String creds[] = getAuthHeaderTokens(request, authType); // Password must be present if (creds[1] == null || creds[1].isEmpty()) { throw new HttpAuthenticationException("Authorization header received " + "from the client does not contain username."); } return creds[1]; }
private String getUsername(HttpServletRequest request, String authType) throws HttpAuthenticationException { String creds[] = getAuthHeaderTokens(request, authType); // Username must be present if (creds[0] == null || creds[0].isEmpty()) { throw new HttpAuthenticationException("Authorization header received " + "from the client does not contain username."); } return creds[0]; }
private String getPassword(HttpServletRequest request, String authType) throws HttpAuthenticationException { String[] creds = getAuthHeaderTokens(request, authType); // Password must be present if (creds[1] == null || creds[1].isEmpty()) { throw new HttpAuthenticationException("Authorization header received " + "from the client does not contain username."); } return creds[1]; }