org.eurekaclinical.common.config.ServletModuleSupport Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eurekaclinical-common Show documentation
Show all versions of eurekaclinical-common Show documentation
A library of classes shared across the Eureka! Clinical platform.
package org.eurekaclinical.common.config;
/*-
* #%L
* Eureka! Clinical Common
* %%
* Copyright (C) 2016 Emory University
* %%
* 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.
* #L%
*/
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Map;
import org.eurekaclinical.standardapis.props.CasEurekaClinicalProperties;
/**
*
* @author Andrew Post
*/
final class ServletModuleSupport {
private static final Logger LOGGER = LoggerFactory
.getLogger(ServletModuleSupport.class);
private static final String CAS_PROXY_CALLBACK_PATH = "/proxyCallback";
private final CasEurekaClinicalProperties properties;
private final String contextPath;
ServletModuleSupport(String contextPath,
CasEurekaClinicalProperties inProperties) {
this.properties = inProperties;
this.contextPath = contextPath;
}
/**
* Gets a parameter map with default values for the following
* CAS authentication filter parameters:
* * casServerLoginUrl
* * serverName
* * renew
* * gateway
*
* @return a newly created parameter map, guaranteed not null.
*/
Map getCasAuthenticationFilterInitParams() {
Map params = new HashMap<>();
params.put("casServerLoginUrl", this.getCasLoginUrl());
params.put("serverName", this.properties.getProxyCallbackServer());
params.put("renew", Boolean.toString(this.properties.getCasLoginRenew()));
params.put("gateway", Boolean.toString(this.properties.getCasLoginGateway()));
if (LOGGER.isDebugEnabled()) {
this.printParams(params);
}
return params;
}
Map getServletRequestWrapperFilterInitParams() {
Map params = new HashMap<>();
params.put("roleAttribute", "authorities");
if (LOGGER.isDebugEnabled()) {
this.printParams(params);
}
return params;
}
CasEurekaClinicalProperties getApplicationProperties() {
return this.properties;
}
protected String getCasProxyCallbackUrl() {
return this.properties.getProxyCallbackServer() + this.contextPath
+ CAS_PROXY_CALLBACK_PATH;
}
protected String getCasProxyCallbackPath() {
return CAS_PROXY_CALLBACK_PATH;
}
private void printParams(Map inParams) {
for (Map.Entry entry : inParams.entrySet()) {
LOGGER.debug(entry.getKey() + " -> " + entry.getValue());
}
}
private String getCasLoginUrl() {
return this.properties.getCasLoginUrl();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy