/* * Copyright 2014 Federal Chancellery Austria * MOA-ID has been developed in a cooperation between BRZ, the Federal * Chancellery Austria - ICT staff unit, and Graz University of Technology. * * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by * the European Commission - subsequent versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the Licence. * You may obtain a copy of the Licence at: * http://www.osor.eu/eupl/ * * Unless required by applicable law or agreed to in writing, software * distributed under the Licence is distributed on an "AS IS" basis, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the Licence for the specific language governing permissions and * limitations under the Licence. * * This product combines work with different licenses. See the "NOTICE" text * file for details on the various modules and licenses. * The "NOTICE" text file is part of the distribution. Any derivative works * that you distribute must include a readable copy of the "NOTICE" text file. */ package at.gv.egovernment.moa.id.configuration.data.oa; import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletRequest; import org.apache.log4j.Logger; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.InterfederationIDPType; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; import at.gv.egovernment.moa.id.commons.validation.ValidationHelper; import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; import at.gv.egovernment.moa.id.configuration.helper.LanguageHelper; import at.gv.egovernment.moa.util.MiscUtil; /** * @author tlenz * */ public class OAMOAIDPInterfederationConfig implements IOnlineApplicationData { private static final Logger log = Logger.getLogger(OAMOAIDPInterfederationConfig.class); private String queryURL; private Boolean inboundSSO = true; private Boolean outboundSSO = true; private Boolean storeSSOSession = true; private Boolean passiveRequest = true; private Boolean localAuthOnError = true; /* (non-Javadoc) * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName() */ @Override public String getName() { return "MOAIDPInterfederation"; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#parse(at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) */ @Override public List parse(OnlineApplication dbOA, AuthenticatedUser authUser, HttpServletRequest request) { InterfederationIDPType moaIDP = dbOA.getInterfederationIDP(); if (moaIDP != null) { this.queryURL = moaIDP.getAttributeQueryURL(); this.inboundSSO = moaIDP.isInboundSSO(); this.outboundSSO = moaIDP.isOutboundSSO(); this.storeSSOSession = moaIDP.isStoreSSOSession(); this.localAuthOnError = moaIDP.isPerformLocalAuthenticationOnError(); this.passiveRequest = moaIDP.isPerformPassivRequest(); } return null; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store(at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) */ @Override public String store(OnlineApplication dbOA, AuthenticatedUser authUser, HttpServletRequest request) { if (authUser.isAdmin()) { dbOA.setIsInterfederationIDP(true); InterfederationIDPType moaIDP = dbOA.getInterfederationIDP(); if (moaIDP == null) { moaIDP = new InterfederationIDPType(); dbOA.setInterfederationIDP(moaIDP); } moaIDP.setAttributeQueryURL(queryURL); moaIDP.setInboundSSO(inboundSSO); moaIDP.setOutboundSSO(outboundSSO); moaIDP.setStoreSSOSession(storeSSOSession); moaIDP.setPerformLocalAuthenticationOnError(localAuthOnError); moaIDP.setPerformPassivRequest(passiveRequest); } return null; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) */ @Override public List validate(OAGeneralConfig general, AuthenticatedUser authUser, HttpServletRequest request) { List errors = new ArrayList(); if (MiscUtil.isNotEmpty(queryURL)) { if (!ValidationHelper.validateURL(queryURL)) { log.info("AttributeQuery URL is not valid"); errors.add(LanguageHelper.getErrorString("validation.interfederation.moaidp.queryurl.valid", request)); } } // if (inboundSSO && MiscUtil.isEmpty(queryURL)) { // log.info("Inbound Single Sign-On requires AttributQueryURL configuration."); // errors.add(LanguageHelper.getErrorString("validation.interfederation.moaidp.queryurl.empty", request)); // } return errors; } /** * @return the queryURL */ public String getQueryURL() { return queryURL; } /** * @param queryURL the queryURL to set */ public void setQueryURL(String queryURL) { this.queryURL = queryURL; } /** * @return the inboundSSO */ public boolean isInboundSSO() { return inboundSSO.booleanValue(); } /** * @param inboundSSO the inboundSSO to set */ public void setInboundSSO(boolean inboundSSO) { this.inboundSSO = inboundSSO; } /** * @return the outboundSSO */ public boolean isOutboundSSO() { return outboundSSO.booleanValue(); } /** * @param outboundSSO the outboundSSO to set */ public void setOutboundSSO(boolean outboundSSO) { this.outboundSSO = outboundSSO; } /** * @return the storeSSOSession */ public boolean isStoreSSOSession() { return storeSSOSession.booleanValue(); } /** * @param storeSSOSession the storeSSOSession to set */ public void setStoreSSOSession(boolean storeSSOSession) { this.storeSSOSession = storeSSOSession; } /** * @return the passiveRequest */ public boolean isPassiveRequest() { return passiveRequest.booleanValue(); } /** * @param passiveRequest the passiveRequest to set */ public void setPassiveRequest(boolean passiveRequest) { this.passiveRequest = passiveRequest; } /** * @return the localAuthOnError */ public boolean isLocalAuthOnError() { return localAuthOnError.booleanValue(); } /** * @param localAuthOnError the localAuthOnError to set */ public void setLocalAuthOnError(boolean localAuthOnError) { this.localAuthOnError = localAuthOnError; } }