[ 
https://issues.apache.org/jira/browse/KNOX-2597?focusedWorklogId=592026&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-592026
 ]

ASF GitHub Bot logged work on KNOX-2597:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 02/May/21 18:28
            Start Date: 02/May/21 18:28
    Worklog Time Spent: 10m 
      Work Description: smolnar82 commented on a change in pull request #441:
URL: https://github.com/apache/knox/pull/441#discussion_r624735857



##########
File path: 
gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/TokenResource.java
##########
@@ -207,6 +211,42 @@ public void init() throws AliasServiceException {
         log.noRenewersConfigured(topologyName);
       }
     }
+    setTokenStateServiceStatusMap();
+  }
+
+  private void setTokenStateServiceStatusMap() {
+    if (isServerManagedTokenStateEnabled()) {
+      tokenStateServiceStatusMap.put("tokenManagementEnabled", "true");
+      final GatewayConfig config = (GatewayConfig) 
request.getServletContext().getAttribute(GatewayConfig.GATEWAY_CONFIG_ATTRIBUTE);
+      final String configuredTokenStateServiceImpl = 
config.getServiceParameter(ServiceType.TOKEN_STATE_SERVICE.getShortName(), 
"impl");
+      final String configuredTokenServiceName = 
StringUtils.isBlank(configuredTokenStateServiceImpl) ? ""
+          : 
configuredTokenStateServiceImpl.substring(configuredTokenStateServiceImpl.lastIndexOf('.')
 + 1);
+      final String actualTokenStateServiceImpl = 
tokenStateService.getClass().getCanonicalName();
+      final String actualTokenServiceName = 
actualTokenStateServiceImpl.substring(actualTokenStateServiceImpl.lastIndexOf('.')
 + 1);
+      tokenStateServiceStatusMap.put("configuredTssBackend", 
configuredTokenServiceName);
+      tokenStateServiceStatusMap.put("actualTssBackend", 
actualTokenServiceName);
+      populateAllowedTokenStateBackendForTokenGenApp(actualTokenServiceName);
+    } else {
+      tokenStateServiceStatusMap.put("tokenManagementEnabled", "false");
+    }
+  }
+
+  private void populateAllowedTokenStateBackendForTokenGenApp(final String 
actualTokenServiceName) {
+    tokenStateServiceStatusMap.put("allowedTssForTokengen", "false");
+    final String allowedTssBackends = 
context.getInitParameter(TOKEN_EXP_TOKENGEN_ALLOWED_TSS_BACKENDS);
+    if (allowedTssBackends != null && !allowedTssBackends.isEmpty()) {
+      for (String allowedTssBackend : allowedTssBackends.split(",")) {
+        if (allowedTssBackend.trim().equals(actualTokenServiceName)) {
+          tokenStateServiceStatusMap.put("allowedTssForTokengen", "true");
+          break;
+        }
+      }
+    } else {
+      //as of now, we allow keystore and DB back-end for the tokengen 
application

Review comment:
       Going to make it clear.




-- 
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: 592026)
    Time Spent: 50m  (was: 40m)

> Fallback to AliasBasedTokenStateService in case of DB errors
> ------------------------------------------------------------
>
>                 Key: KNOX-2597
>                 URL: https://issues.apache.org/jira/browse/KNOX-2597
>             Project: Apache Knox
>          Issue Type: Task
>    Affects Versions: 1.6.0
>            Reporter: Sandor Molnar
>            Assignee: Sandor Molnar
>            Priority: Major
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> We recently added support to pure JDBC-based token state management. It'd be 
> great to make deployments smooth with the following safety net: if there is 
> (are) any issue(s) with the configured DB connection, the Knox Gateway should 
> start using the {{AliasBasedTokenStateService}} instead of fail-fast. 
> Additionally, the {{tokengen}} UI should indicate the fact if the underlying 
> token back-end is the one the user configured.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to