abstractdog commented on code in PR #5399: URL: https://github.com/apache/hive/pull/5399#discussion_r1735845551
########## service/src/java/org/apache/hive/service/auth/HttpAuthService.java: ########## @@ -0,0 +1,265 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hive.service.auth; + +import org.apache.hive.service.CookieSigner; +import org.apache.hive.service.auth.ldap.HttpEmptyAuthenticationException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.core.NewCookie; +import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; +import java.security.SecureRandom; +import java.util.Base64; + +public class HttpAuthService { + private static final Logger LOG = LoggerFactory.getLogger(HttpAuthService.class); + public static final String USERNAME_REQUEST_PARAM_NAME = "username"; + public static final String PASSWORD_REQUEST_PARAM_NAME = "password"; + private static final SecureRandom RAN = new SecureRandom(); + private final CookieSigner signer; + private final String cookieDomain; + private final String cookiePath; + private final int cookieMaxAge; + private final boolean isCookieSecure; + private final String authCookieName; + + public HttpAuthService(String cookieDomain, String cookiePath, int cookieMaxAge, boolean isCookieSecure, + String authCookieName) { + String secret = Long.toString(RAN.nextLong()); + this.signer = new CookieSigner(secret.getBytes()); + this.cookieMaxAge = cookieMaxAge; + this.cookieDomain = cookieDomain; + this.cookiePath = cookiePath; + this.authCookieName = authCookieName; + this.isCookieSecure = isCookieSecure; + } + + public Cookie signAndcreateCookie(String cookieToken) { Review Comment: nit camelcase: signAndCreateCookie -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org