[
https://issues.apache.org/jira/browse/KNOX-2554?focusedWorklogId=582373&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-582373
]
ASF GitHub Bot logged work on KNOX-2554:
----------------------------------------
Author: ASF GitHub Bot
Created on: 14/Apr/21 10:48
Start Date: 14/Apr/21 10:48
Worklog Time Spent: 10m
Work Description: moresandeep commented on a change in pull request #433:
URL: https://github.com/apache/knox/pull/433#discussion_r613140808
##########
File path:
gateway-server/src/main/java/org/apache/knox/gateway/services/token/impl/TokenStateDatabase.java
##########
@@ -0,0 +1,145 @@
+/*
+ * 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.knox.gateway.services.token.impl;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import javax.sql.DataSource;
+
+import org.apache.knox.gateway.services.security.token.TokenMetadata;
+
+public class TokenStateDatabase {
+ private static final String TOKENS_TABLE_NAME = "KNOX_TOKENS";
+ private static final String ADD_TOKEN_SQL = "INSERT INTO " +
TOKENS_TABLE_NAME + "(token_id, issue_time, expiration, max_lifetime) VALUES(?,
?, ?, ?)";
+ private static final String REMOVE_TOKENS_SQL_PREFIX = "DELETE FROM " +
TOKENS_TABLE_NAME + " WHERE token_id IN (";
Review comment:
I have seen this implemented in other projects where SQL was used
heavily. The idea being all SQL stays in one resource place and if you need to
tweak the SQL statements you don't have to worry about changing the java files.
Even better if you can have them as external resources you could change them at
runtime without changing class files (but that is not what I am expecting just
something that came to me while writing :) )
I am not opposed to having it in DAO but my thinking is SQLs statements are
more like resources.
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 582373)
Time Spent: 1h 10m (was: 1h)
> Implement JDBC TokenStateService
> --------------------------------
>
> Key: KNOX-2554
> URL: https://issues.apache.org/jira/browse/KNOX-2554
> Project: Apache Knox
> Issue Type: Task
> Reporter: Sandor Molnar
> Assignee: Sandor Molnar
> Priority: Major
> Fix For: 1.6.0
>
> Time Spent: 1h 10m
> Remaining Estimate: 0h
>
> Add a new TokenStateService implementation that stores token metadata in a
> relational database.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)