-
Notifications
You must be signed in to change notification settings - Fork 712
Provide support to add named configs map for authenticators #4363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.10.x
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,16 +78,26 @@ public static class AuthenticatorConfig { | |
|
|
||
| private Map<String, String> parameters = new Hashtable<String, String>(); | ||
|
|
||
| private final Map<String, Map<String, String>> parameterMap; | ||
|
|
||
| private List<String> authenticationSkippingUrls = new ArrayList<String>(); | ||
|
|
||
| private List<String> sessionValidationSkippingUrls = new ArrayList<String>(); | ||
|
|
||
| private AuthenticatorConfig(String name, int priority, boolean disabled, Map<String, | ||
| String> params) { | ||
| String> params, Map<String, Map<String, String>> paramMap) { | ||
| this.name = name; | ||
| this.priority = priority; | ||
| this.disabled = disabled; | ||
| this.parameters = params; | ||
|
|
||
| // Make sure that outer map and inner maps are unmodifiable. | ||
| Map<String, Map<String, String>> unmodifiableParamMap = new HashMap<>(); | ||
| for (Map.Entry<String, Map<String, String>> entry : paramMap.entrySet()) { | ||
| unmodifiableParamMap.put(entry.getKey(), | ||
| Collections.unmodifiableMap(new HashMap<>(entry.getValue()))); | ||
| } | ||
| this.parameterMap = Collections.unmodifiableMap(unmodifiableParamMap); | ||
|
sahandilshan marked this conversation as resolved.
|
||
| } | ||
|
|
||
| public String getName() { | ||
|
|
@@ -106,6 +116,14 @@ public Map<String, String> getParameters() { | |
| return parameters; | ||
| } | ||
|
|
||
| public Map<String, Map<String, String>> getParameterMap() { | ||
| return parameterMap; | ||
| } | ||
|
|
||
| public Map<String, String> getConfigFromParameterMap(String configName) { | ||
| return parameterMap.get(configName); | ||
| } | ||
|
|
||
| public void addAuthenticationSkippingUrl(String url) { | ||
| this.authenticationSkippingUrls.add(url); | ||
| } | ||
|
|
@@ -208,10 +226,36 @@ private AuthenticatorConfig processAuthenticatorElement(OMElement authenticatorE | |
| } | ||
|
|
||
| // read the config parameters | ||
| Map<String, String> parameterMap = new Hashtable<String, String>(); | ||
| Map<String, String> parameterMap = new Hashtable<>(); | ||
| Map<String, Map<String, String>> nestedParameterMap = new HashMap<>(); | ||
|
|
||
| for(Iterator configElemItr = authenticatorElem.getChildrenWithLocalName(ELEM_CONFIG); | ||
| configElemItr.hasNext();){ | ||
| OMElement configElement = (OMElement)configElemItr.next(); | ||
|
|
||
| // Only process configs that have an explicit name attribute. | ||
| OMAttribute configNameAttr = configElement.getAttribute(new QName(ATTR_NAME)); | ||
| if(configNameAttr == null){ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Formatting issue
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It unclear what are we trying to achieve here.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently we can have define as below With this new config we are providing the support to define named config along with the previous support. so now we can have something like this |
||
| // Skip configs without name attribute - process parameters for flat map only. | ||
| for(Iterator paramIterator = configElement.getChildrenWithLocalName(ELEM_PARAMETER); | ||
|
sahandilshan marked this conversation as resolved.
Outdated
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we avoid iterating the elements twice? |
||
| paramIterator.hasNext();){ | ||
| OMElement paramElem = (OMElement)paramIterator.next(); | ||
| OMAttribute paramNameAttr = paramElem.getAttribute(new QName(ATTR_NAME)); | ||
| if(paramNameAttr == null){ | ||
|
sahandilshan marked this conversation as resolved.
Outdated
|
||
| log.warn("An Authenticator Parameter should have a name attribute. Skipping the parameter."); | ||
| continue; | ||
| } | ||
| // Add to flat map for backward compatibility. | ||
| parameterMap.put(paramNameAttr.getAttributeValue(), paramElem.getText()); | ||
| } | ||
| continue; | ||
| } | ||
|
|
||
| String configName = configNameAttr.getAttributeValue(); | ||
|
|
||
| // Create a map for this config's parameters. | ||
| Map<String, String> configParametersMap = new HashMap<>(); | ||
|
|
||
| for(Iterator paramIterator = configElement.getChildrenWithLocalName(ELEM_PARAMETER); | ||
| paramIterator.hasNext();){ | ||
| OMElement paramElem = (OMElement)paramIterator.next(); | ||
|
|
@@ -220,12 +264,22 @@ private AuthenticatorConfig processAuthenticatorElement(OMElement authenticatorE | |
| log.warn("An Authenticator Parameter should have a name attribute. Skipping the parameter."); | ||
| continue; | ||
| } | ||
| parameterMap.put(paramNameAttr.getAttributeValue(), paramElem.getText()); | ||
| String paramName = paramNameAttr.getAttributeValue(); | ||
| String paramValue = paramElem.getText(); | ||
|
|
||
| // Add to both the flat map (for backward compatibility) and the nested map. | ||
| parameterMap.put(paramName, paramValue); | ||
|
sahandilshan marked this conversation as resolved.
|
||
| configParametersMap.put(paramName, paramValue); | ||
| } | ||
|
|
||
| // Add the config parameters to the nested parameterMap if it has any parameters. | ||
| if(!configParametersMap.isEmpty()){ | ||
|
sahandilshan marked this conversation as resolved.
Outdated
|
||
| nestedParameterMap.put(configName, configParametersMap); | ||
| } | ||
| } | ||
|
|
||
| AuthenticatorConfig authenticatorConfig = new AuthenticatorConfig(authenticatorName, | ||
| priority, disabled, parameterMap); | ||
| priority, disabled, parameterMap, nestedParameterMap); | ||
|
|
||
| // read authentication skipping urls | ||
| for(Iterator configElemItr = authenticatorElem.getChildrenWithLocalName(ELEM_SKIP_AUTHENTICATION); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.