From 3fada6cef21c9b16467177d866df778203b51b4d Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 5 Dec 2019 09:52:48 +0100 Subject: some code code-style modifications active code-quality checks! --- .../idp/auth/AbstractAuthenticationManager.java | 76 ++++++++++------------ 1 file changed, 35 insertions(+), 41 deletions(-) (limited to 'eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/AbstractAuthenticationManager.java') diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/AbstractAuthenticationManager.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/AbstractAuthenticationManager.java index 241b43c9..d2365e4a 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/AbstractAuthenticationManager.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/AbstractAuthenticationManager.java @@ -24,14 +24,22 @@ import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; + import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.text.StringEscapeUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + import at.gv.egiz.eaaf.core.api.IRequest; import at.gv.egiz.eaaf.core.api.IRequestStorage; -import at.gv.egiz.eaaf.core.api.data.EAAFConstants; +import at.gv.egiz.eaaf.core.api.data.EaafConstants; import at.gv.egiz.eaaf.core.api.idp.IConfiguration; -import at.gv.egiz.eaaf.core.api.idp.IspConfiguration; +import at.gv.egiz.eaaf.core.api.idp.ISpConfiguration; import at.gv.egiz.eaaf.core.api.idp.auth.IAuthenticationManager; import at.gv.egiz.eaaf.core.api.idp.auth.ISsoManager; import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; @@ -46,11 +54,6 @@ import at.gv.egiz.eaaf.core.impl.idp.auth.modules.ModuleRegistration; import at.gv.egiz.eaaf.core.impl.idp.controller.protocols.RequestImpl; import at.gv.egiz.eaaf.core.impl.idp.process.ExecutionContextImpl; import at.gv.egiz.eaaf.core.impl.utils.TransactionIdUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.text.StringEscapeUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; public abstract class AbstractAuthenticationManager implements IAuthenticationManager { private static final Logger log = LoggerFactory.getLogger(AbstractAuthenticationManager.class); @@ -73,14 +76,14 @@ public abstract class AbstractAuthenticationManager implements IAuthenticationMa protected IRevisionLogger revisionsLogger; @Autowired(required = false) protected ISsoManager ssoManager; - @Autowired ModuleRegistration moduleRegistration; + @Autowired + ModuleRegistration moduleRegistration; /* * (non-Javadoc) * - * @see - * at.gv.egiz.eaaf.core.impl.idp.auth.IAuthenticationManager#addParameterNameToWhiteList(java.lang - * .String) + * @see at.gv.egiz.eaaf.core.impl.idp.auth.IAuthenticationManager# + * addParameterNameToWhiteList(java.lang .String) */ @Override public final void addParameterNameToWhiteList(final String httpReqParam) { @@ -93,9 +96,8 @@ public abstract class AbstractAuthenticationManager implements IAuthenticationMa /* * (non-Javadoc) * - * @see - * at.gv.egiz.eaaf.core.impl.idp.auth.IAuthenticationManager#addHeaderNameToWhiteList(java.lang. - * String) + * @see at.gv.egiz.eaaf.core.impl.idp.auth.IAuthenticationManager# + * addHeaderNameToWhiteList(java.lang. String) */ @Override public final void addHeaderNameToWhiteList(final String httpReqParam) { @@ -108,9 +110,8 @@ public abstract class AbstractAuthenticationManager implements IAuthenticationMa /* * (non-Javadoc) * - * @see - * at.gv.egiz.eaaf.core.impl.idp.auth.IAuthenticationManager#addHeaderNameToWhiteList(java.lang. - * String) + * @see at.gv.egiz.eaaf.core.impl.idp.auth.IAuthenticationManager# + * addHeaderNameToWhiteList(java.lang. String) */ @Override public final boolean doAuthentication(final HttpServletRequest httpReq, @@ -124,7 +125,7 @@ public abstract class AbstractAuthenticationManager implements IAuthenticationMa } // load OA configuration from pending request - final IspConfiguration oaParam = pendingReq.getServiceProviderConfiguration(); + final ISpConfiguration oaParam = pendingReq.getServiceProviderConfiguration(); // set logging context and log unique OA identifier to revision log TransactionIdUtils.setServiceProviderId(oaParam.getUniqueIdentifier()); @@ -137,7 +138,6 @@ public abstract class AbstractAuthenticationManager implements IAuthenticationMa throw new NoPassivAuthenticationException(); } - // check Single Sign-On functionality if SSOManager is available boolean isValidSsoSession = false; if (ssoManager != null) { @@ -149,16 +149,15 @@ public abstract class AbstractAuthenticationManager implements IAuthenticationMa isValidSsoSession = ssoManager.checkAndValidateSsoSession(pendingReq, httpReq, httpResp) && pendingReq.needSingleSignOnFunctionality(); - } // check if session is already authenticated - // boolean isSessionAuthenticated = tryPerformAuthentication((RequestImpl) pendingReq, + // boolean isSessionAuthenticated = tryPerformAuthentication((RequestImpl) + // pendingReq, // isValidSSOSession); // boolean isSessionAuthenticated = isValidSSOSession && // StringUtils.isNotEmpty(pendingReq.getSSOSessionIdentifier()); - // force new authentication authentication process if (pendingReq.forceAuth()) { startAuthenticationProcess(httpReq, (RequestImpl) pendingReq); @@ -169,7 +168,6 @@ public abstract class AbstractAuthenticationManager implements IAuthenticationMa sendSingleSignOnConsentsEvaluation((RequestImpl) pendingReq); return false; - } else if (pendingReq.isPassiv()) { if (isValidSsoSession && StringUtils.isNotEmpty(pendingReq.getInternalSsoSessionIdentifier())) { @@ -207,7 +205,6 @@ public abstract class AbstractAuthenticationManager implements IAuthenticationMa log.debug("Close session. Remove pending request ... "); requestStoreage.removePendingRequest(pendingReq.getPendingRequestId()); - if (ssoManager != null) { try { log.trace("'SSOManager' active. Search for active SSO sessions ... "); @@ -229,11 +226,11 @@ public abstract class AbstractAuthenticationManager implements IAuthenticationMa /** * Populate process execution context and start process engine. * - * @param httpReq http request + * @param httpReq http request * @param pendingReq current pending request * @throws ServletException In case of a servlet error - * @throws IOException In case of an IO error - * @throws EaafException In case of EAAF processing error + * @throws IOException In case of an IO error + * @throws EaafException In case of EAAF processing error */ private void startAuthenticationProcess(final HttpServletRequest httpReq, final RequestImpl pendingReq) throws EaafException { @@ -245,15 +242,15 @@ public abstract class AbstractAuthenticationManager implements IAuthenticationMa final ExecutionContext executionContext = new ExecutionContextImpl(); // set oaIdentifeir - executionContext.put(EAAFConstants.PROCESS_ENGINE_SERVICE_PROVIDER_ENTITYID, + executionContext.put(EaafConstants.PROCESS_ENGINE_SERVICE_PROVIDER_ENTITYID, pendingReq.getServiceProviderConfiguration().getUniqueIdentifier()); // add X509 SSL client certificate if exist if (httpReq.getAttribute("javax.servlet.request.X509Certificate") != null) { log.debug("Find SSL-client-certificate on request --> Add it to context"); - executionContext.put(EAAFConstants.PROCESS_ENGINE_SSL_CLIENT_CERTIFICATE, + executionContext.put(EaafConstants.PROCESS_ENGINE_SSL_CLIENT_CERTIFICATE, (X509Certificate[]) httpReq.getAttribute("javax.servlet.request.X509Certificate")); - pendingReq.setRawDataToTransaction(EAAFConstants.PROCESS_ENGINE_SSL_CLIENT_CERTIFICATE, + pendingReq.setRawDataToTransaction(EaafConstants.PROCESS_ENGINE_SSL_CLIENT_CERTIFICATE, httpReq.getAttribute("javax.servlet.request.X509Certificate")); } @@ -287,8 +284,6 @@ public abstract class AbstractAuthenticationManager implements IAuthenticationMa } } - - // populate more IDP specific information to execution context populateExecutionContext(executionContext, pendingReq, httpReq); @@ -301,8 +296,8 @@ public abstract class AbstractAuthenticationManager implements IAuthenticationMa * Add additional parameters into context of process-engine. * * @param executionContext Process-engine context - * @param pendingReq Current pending request - * @param httpReq http request + * @param pendingReq Current pending request + * @param httpReq http request * * @throws EaafException In case of an error */ @@ -314,8 +309,8 @@ public abstract class AbstractAuthenticationManager implements IAuthenticationMa * * @param pendingReq current pending request * @throws ServletException In case of a servlet error - * @throws IOException In case of an IO error - * @throws EaafException In case of a EAAF processing error + * @throws IOException In case of an IO error + * @throws EaafException In case of a EAAF processing error */ private void sendSingleSignOnConsentsEvaluation(final RequestImpl pendingReq) throws EaafException { @@ -333,11 +328,10 @@ public abstract class AbstractAuthenticationManager implements IAuthenticationMa } - /** * Select a specific process and starting process engine. * - * @param pendingReq current pending request + * @param pendingReq current pending request * @param executionContext current context for process-engine * @throws EaafException In case of an process-engine error */ @@ -345,7 +339,7 @@ public abstract class AbstractAuthenticationManager implements IAuthenticationMa final ExecutionContext executionContext) throws EaafException { try { // put pending-request ID on execurtionContext - executionContext.put(EAAFConstants.PROCESS_ENGINE_PENDINGREQUESTID, + executionContext.put(EaafConstants.PROCESS_ENGINE_PENDINGREQUESTID, pendingReq.getPendingRequestId()); // create process instance @@ -354,7 +348,7 @@ public abstract class AbstractAuthenticationManager implements IAuthenticationMa if (processDefinitionId == null) { log.warn("No suitable process found for PendingReqId " + pendingReq.getPendingRequestId()); - throw new EaafException("process.02", new Object[] {pendingReq.getPendingRequestId()}); + throw new EaafException("process.02", new Object[] { pendingReq.getPendingRequestId() }); } @@ -383,7 +377,7 @@ public abstract class AbstractAuthenticationManager implements IAuthenticationMa } throw new EaafException("process.01", - new Object[] {pendingReq.getProcessInstanceId(), pendingReq.getPendingRequestId()}, e); + new Object[] { pendingReq.getProcessInstanceId(), pendingReq.getPendingRequestId() }, e); } } -- cgit v1.2.3