/******************************************************************************* * 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.math.BigInteger; import java.util.List; import javax.servlet.http.HttpServletRequest; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AuthComponentOA; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OASAML1; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; import at.gv.egovernment.moa.id.configuration.validation.oa.OASAML1ConfigValidation; public class OASAML1Config implements IOnlineApplicationData{ private Boolean isActive = false; private Boolean provideStammZahl = false; private Boolean provideAuthBlock = false; private Boolean provideIdentityLink = false; private Boolean provideCertificate = false; private Boolean provideFullMandateData = false; private Boolean useCondition = false; private Boolean provideAllErrors = true; private int conditionLength = -1; public OASAML1Config() { } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName() */ @Override public String getName() { return "OASAML1"; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#parse(at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, javax.servlet.http.HttpServletRequest) */ @Override public List parse(OnlineApplication dbOA, AuthenticatedUser authUser, HttpServletRequest request) { AuthComponentOA authdata = dbOA.getAuthComponentOA(); if (authdata != null) { OASAML1 saml1 = authdata.getOASAML1(); if (saml1 != null) { provideAuthBlock = saml1.isProvideAUTHBlock(); provideCertificate = saml1.isProvideCertificate(); provideFullMandateData = saml1.isProvideFullMandatorData(); provideIdentityLink = saml1.isProvideIdentityLink(); provideStammZahl = saml1.isProvideStammzahl(); if (saml1.isProvideAllErrors() != null) provideAllErrors = saml1.isProvideAllErrors(); if (saml1.isUseCondition() != null) useCondition = saml1.isUseCondition(); if (saml1.getConditionLength() != null) conditionLength = saml1.getConditionLength().intValue(); if (saml1.isIsActive() != null) isActive = saml1.isIsActive(); } } 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) { return new OASAML1ConfigValidation().validate(this, general, request); } /* (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) { AuthComponentOA authoa = dbOA.getAuthComponentOA(); if (authoa == null) { authoa = new AuthComponentOA(); dbOA.setAuthComponentOA(authoa); } OASAML1 saml1 = authoa.getOASAML1(); if (saml1 == null) { saml1 = new OASAML1(); authoa.setOASAML1(saml1); saml1.setIsActive(false); } if (authUser.isAdmin()) { saml1.setIsActive(isActive()); } if (saml1.isIsActive() != null && saml1.isIsActive()) { saml1.setProvideAUTHBlock(isProvideAuthBlock()); saml1.setProvideCertificate(isProvideCertificate()); saml1.setProvideFullMandatorData(isProvideFullMandateData()); saml1.setProvideIdentityLink(isProvideIdentityLink()); saml1.setProvideStammzahl(isProvideStammZahl()); saml1.setUseCondition(isUseCondition()); saml1.setProvideAllErrors(provideAllErrors); saml1.setConditionLength(BigInteger.valueOf(getConditionLength())); // TODO: set sourceID // saml1.setSourceID(""); } return null; } public boolean isProvideStammZahl() { return provideStammZahl; } public void setProvideStammZahl(boolean provideStammZahl) { this.provideStammZahl = provideStammZahl; } public boolean isProvideAuthBlock() { return provideAuthBlock; } public void setProvideAuthBlock(boolean provideAuthBlock) { this.provideAuthBlock = provideAuthBlock; } public boolean isProvideIdentityLink() { return provideIdentityLink; } public void setProvideIdentityLink(boolean provideIdentityLink) { this.provideIdentityLink = provideIdentityLink; } public boolean isProvideCertificate() { return provideCertificate; } public void setProvideCertificate(boolean provideCertificate) { this.provideCertificate = provideCertificate; } public boolean isProvideFullMandateData() { return provideFullMandateData; } public void setProvideFullMandateData(boolean provideFullMandateData) { this.provideFullMandateData = provideFullMandateData; } public boolean isUseCondition() { return useCondition; } public void setUseCondition(boolean useCondition) { this.useCondition = useCondition; } public int getConditionLength() { return conditionLength; } public void setConditionLength(int conditionLength) { this.conditionLength = conditionLength; } /** * @return the isActive */ public boolean isActive() { return isActive; } /** * @param isActive the isActive to set */ public void setActive(boolean isActive) { this.isActive = isActive; } /** * @return the provideAllErrors */ public Boolean getProvideAllErrors() { return provideAllErrors; } /** * @param provideAllErrors the provideAllErrors to set */ public void setProvideAllErrors(Boolean provideAllErrors) { this.provideAllErrors = provideAllErrors; } }