diff --git a/fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/auth2/FlightAuthUtils.java b/fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/auth2/FlightAuthUtils.java index a5f86e777b67a2..66e59fba13f658 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/auth2/FlightAuthUtils.java +++ b/fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/auth2/FlightAuthUtils.java @@ -1,33 +1,32 @@ - -/* - * Copyright (C) 2017-2019 Dremio Corporation - * - * Licensed 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. - */ +// 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.doris.service.arrowflight.auth2; +import org.apache.doris.analysis.UserIdentity; +import org.apache.doris.catalog.Env; +import org.apache.doris.common.AuthenticationException; +import org.apache.doris.service.arrowflight.tokens.TokenManager; + import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import org.apache.arrow.flight.CallStatus; import org.apache.logging.log4j.Logger; -import org.apache.doris.service.arrowflight.tokens.TokenManager; - -import org.apache.doris.analysis.UserIdentity; -import org.apache.doris.catalog.Env; -import org.apache.doris.common.AuthenticationException; - import java.util.List; /** diff --git a/fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/auth2/FlightBearerTokenAuthenticator.java b/fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/auth2/FlightBearerTokenAuthenticator.java index 4d548929d4515a..a5c1d9236b213c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/auth2/FlightBearerTokenAuthenticator.java +++ b/fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/auth2/FlightBearerTokenAuthenticator.java @@ -20,9 +20,7 @@ package org.apache.doris.service.arrowflight.auth2; -import org.apache.doris.common.Config; import org.apache.doris.service.arrowflight.tokens.TokenManager; -import org.apache.doris.service.arrowflight.tokens.TokenManagerImpl; import org.apache.arrow.flight.CallHeaders; import org.apache.arrow.flight.CallStatus; diff --git a/fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/tokens/SessionState.java b/fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/tokens/SessionState.java index adf559236c4a75..e4658c91bb6145 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/tokens/SessionState.java +++ b/fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/tokens/SessionState.java @@ -1,18 +1,19 @@ -/* - * Copyright (C) 2017-2019 Dremio Corporation - * - * Licensed 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. - */ +// 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.doris.service.arrowflight.tokens; diff --git a/fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/tokens/TokenDetails.java b/fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/tokens/TokenDetails.java index f778e51cd8df73..7f55d37dd990f1 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/tokens/TokenDetails.java +++ b/fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/tokens/TokenDetails.java @@ -1,18 +1,19 @@ -/* - * Copyright (C) 2017-2019 Dremio Corporation - * - * Licensed 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. - */ +// 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.doris.service.arrowflight.tokens; diff --git a/fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/tokens/TokenManager.java b/fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/tokens/TokenManager.java index 6b376ee0321afd..235cba10d1542b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/tokens/TokenManager.java +++ b/fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/tokens/TokenManager.java @@ -1,18 +1,19 @@ -/* - * Copyright (C) 2017-2019 Dremio Corporation - * - * Licensed 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. - */ +// 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.doris.service.arrowflight.tokens; diff --git a/fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/tokens/TokenManagerImpl.java b/fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/tokens/TokenManagerImpl.java index 3cf99da9b005ac..dfc248811c6b84 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/tokens/TokenManagerImpl.java +++ b/fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/tokens/TokenManagerImpl.java @@ -1,34 +1,35 @@ -/* - * Copyright (C) 2017-2019 Dremio Corporation - * - * Licensed 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. - */ +// 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.doris.service.arrowflight.tokens; import org.apache.doris.service.arrowflight.auth2.DorisAuthResult; -import static com.google.common.base.Preconditions.checkArgument; - -import java.math.BigInteger; -import java.security.SecureRandom; -import java.util.concurrent.TimeUnit; - import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; +import static com.google.common.base.Preconditions.checkArgument; import com.google.common.cache.LoadingCache; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import java.math.BigInteger; +import java.security.SecureRandom; +import java.util.concurrent.TimeUnit; + /** * Token manager implementation. */ @@ -80,18 +81,6 @@ public TokenDetails createToken(final String username, final DorisAuthResult dor return TokenDetails.of(token, username, expires); } - private SessionState getSessionState(final String token) { - checkArgument(token != null, "invalid token"); - final SessionState value; - try { - value = tokenCache.getUnchecked(token); - } catch (CacheLoader.InvalidCacheLoadException ignored) { - throw new IllegalArgumentException("invalid token"); - } - - return value; - } - @Override public TokenDetails validateToken(final String token) throws IllegalArgumentException { final SessionState value = getSessionState(token); @@ -109,5 +98,17 @@ public void invalidateToken(final String token) { LOG.trace("Invalidate token"); tokenCache.invalidate(token); // removes from the store as well } + + private SessionState getSessionState(final String token) { + checkArgument(token != null, "invalid token"); + final SessionState value; + try { + value = tokenCache.getUnchecked(token); + } catch (CacheLoader.InvalidCacheLoadException ignored) { + throw new IllegalArgumentException("invalid token"); + } + + return value; + } }