/******************************************************************************* * 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. ******************************************************************************/ /* * Copyright 2003 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.config.auth; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import at.gv.egovernment.moa.id.commons.db.dao.config.AttributeProviderPlugin; import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentOA; import at.gv.egovernment.moa.id.commons.db.dao.config.BKUSelectionCustomizationType; import at.gv.egovernment.moa.id.commons.db.dao.config.BKUURLS; import at.gv.egovernment.moa.id.commons.db.dao.config.IdentificationNumber; import at.gv.egovernment.moa.id.commons.db.dao.config.Mandates; import at.gv.egovernment.moa.id.commons.db.dao.config.OAPVP2; import at.gv.egovernment.moa.id.commons.db.dao.config.OASAML1; import at.gv.egovernment.moa.id.commons.db.dao.config.OASSO; import at.gv.egovernment.moa.id.commons.db.dao.config.OAStorkAttribute; import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; import at.gv.egovernment.moa.id.commons.db.dao.config.TemplateType; import at.gv.egovernment.moa.id.commons.db.dao.config.TemplatesType; import at.gv.egovernment.moa.id.commons.db.dao.config.TransformsInfoType; import at.gv.egovernment.moa.id.config.ConfigurationUtils; import at.gv.egovernment.moa.id.config.OAParameter; import at.gv.egovernment.moa.id.util.FormBuildUtils; import at.gv.egovernment.moa.logging.Logger; import at.gv.egovernment.moa.util.MiscUtil; /** * Configuration parameters belonging to an online application, * to use with the MOA ID Auth component. * * @author Stefan Knirsch * @version $Id$ */ /** * * * @author Harald Bratko */ public class OAAuthParameter extends OAParameter { public static final String ONLINEBKU = "online"; public static final String HANDYBKU = "handy"; public static final String LOCALBKU = "local"; private AuthComponentOA oa_auth; public OAAuthParameter(OnlineApplication oa) { super(oa); this.oa_auth = oa.getAuthComponentOA(); this.keyBoxIdentifier = oa.getKeyBoxIdentifier().value(); } private String keyBoxIdentifier; /** * @return the identityLinkDomainIdentifier */ public String getIdentityLinkDomainIdentifier() { IdentificationNumber idnumber = oa_auth.getIdentificationNumber(); if (idnumber != null) return idnumber.getValue(); return null; } /** * @return the keyBoxIdentifier */ public String getKeyBoxIdentifier() { return keyBoxIdentifier; } /** * @return the transformsInfos */ public List getTransformsInfos() { List transformations = oa_auth.getTransformsInfo(); return ConfigurationUtils.getTransformInfos(transformations); } public OASAML1 getSAML1Parameter() { return oa_auth.getOASAML1(); } public OAPVP2 getPVP2Parameter() { return oa_auth.getOAPVP2(); } /** * @return the templateURL */ public List getTemplateURL() { TemplatesType templates = oa_auth.getTemplates(); if (templates != null) { if (templates.getTemplate() != null) { return templates.getTemplate(); } } return null; } public String getAditionalAuthBlockText() { TemplatesType templates = oa_auth.getTemplates(); if (templates != null) { return templates.getAditionalAuthBlockText(); } return null; } public String getBKUURL(String bkutype) { BKUURLS bkuurls = oa_auth.getBKUURLS(); if (bkuurls != null) { if (bkutype.equals(ONLINEBKU)) return bkuurls.getOnlineBKU(); else if (bkutype.equals(HANDYBKU)) return bkuurls.getHandyBKU(); else if (bkutype.equals(LOCALBKU)) return bkuurls.getLocalBKU(); } Logger.warn("BKU Type does not match: " + ONLINEBKU + " or " + HANDYBKU + " or " + LOCALBKU); return null; } public List getBKUURL() { BKUURLS bkuurls = oa_auth.getBKUURLS(); List list = new ArrayList(); if (bkuurls == null) { Logger.warn("BKU Type does not match: " + ONLINEBKU + " or " + HANDYBKU + " or " + LOCALBKU); } else { list.add(bkuurls.getOnlineBKU()); list.add(bkuurls.getHandyBKU()); list.add(bkuurls.getLocalBKU()); } return list; } public boolean useSSO() { OASSO sso = oa_auth.getOASSO(); if (sso != null) return sso.isUseSSO(); else return false; } public boolean useSSOQuestion() { OASSO sso = oa_auth.getOASSO(); if (sso != null) return sso.isAuthDataFrame(); else return true; } public String getSingleLogOutURL() { OASSO sso = oa_auth.getOASSO(); if (sso != null) return sso.getSingleLogOutURL(); else return null; } /** * @return the mandateProfiles */ public String getMandateProfiles() { Mandates mandates = oa_auth.getMandates(); if (mandates != null) return mandates.getProfiles(); else return null; } /** * @return the identityLinkDomainIdentifierType */ public String getIdentityLinkDomainIdentifierType() { IdentificationNumber idnumber = oa_auth.getIdentificationNumber(); if (idnumber != null) return idnumber.getType(); return null; } public boolean isShowMandateCheckBox() { TemplatesType templates = oa_auth.getTemplates(); if (templates != null) { BKUSelectionCustomizationType bkuselection = templates.getBKUSelectionCustomization(); if (bkuselection != null) { if (bkuselection.isMandateLoginButton() != null) return bkuselection.isMandateLoginButton(); } } return true; } public boolean isOnlyMandateAllowed() { TemplatesType templates = oa_auth.getTemplates(); if (templates != null) { BKUSelectionCustomizationType bkuselection = templates.getBKUSelectionCustomization(); if (bkuselection != null) { if (bkuselection.isOnlyMandateLoginAllowed() != null) return bkuselection.isOnlyMandateLoginAllowed(); } } return false; } /** * Shall we show the stork login in the bku selection frontend? * * @return true, if is we should show stork login */ public boolean isShowStorkLogin() { try { return oa_auth.getOASTORK().isStorkLogonEnabled(); } catch (NullPointerException e) { return false; } } public Map getFormCustomizaten() { TemplatesType templates = oa_auth.getTemplates(); Map map = new HashMap(); map.putAll(FormBuildUtils.getDefaultMap()); if (templates != null) { BKUSelectionCustomizationType bkuselection = templates.getBKUSelectionCustomization(); if (bkuselection != null) { if (MiscUtil.isNotEmpty(bkuselection.getBackGroundColor())) map.put(FormBuildUtils.MAIN_BACKGROUNDCOLOR, bkuselection.getBackGroundColor()); if (MiscUtil.isNotEmpty(bkuselection.getButtonBackGroundColor())) map.put(FormBuildUtils.BUTTON_BACKGROUNDCOLOR, bkuselection.getButtonBackGroundColor()); if (MiscUtil.isNotEmpty(bkuselection.getButtonBackGroundColorFocus())) map.put(FormBuildUtils.BUTTON_BACKGROUNDCOLOR_FOCUS, bkuselection.getButtonBackGroundColorFocus()); if (MiscUtil.isNotEmpty(bkuselection.getButtonFontColor())) map.put(FormBuildUtils.BUTTON_COLOR, bkuselection.getButtonFontColor()); if (MiscUtil.isNotEmpty(bkuselection.getFontType())) map.put(FormBuildUtils.FONTFAMILY, bkuselection.getFontType()); if (MiscUtil.isNotEmpty(bkuselection.getFrontColor())) map.put(FormBuildUtils.MAIN_COLOR, bkuselection.getFrontColor()); if (MiscUtil.isNotEmpty(bkuselection.getHeaderBackGroundColor())) map.put(FormBuildUtils.HEADER_BACKGROUNDCOLOR, bkuselection.getHeaderBackGroundColor()); if (MiscUtil.isNotEmpty(bkuselection.getHeaderFrontColor())) map.put(FormBuildUtils.HEADER_COLOR, bkuselection.getHeaderFrontColor()); if (MiscUtil.isNotEmpty(bkuselection.getHeaderText())) map.put(FormBuildUtils.HEADER_TEXT, bkuselection.getHeaderText()); if (MiscUtil.isNotEmpty(bkuselection.getAppletRedirectTarget())) map.put(FormBuildUtils.REDIRECTTARGET, bkuselection.getAppletRedirectTarget()); if (MiscUtil.isNotEmpty(bkuselection.getAppletHeight())) map.put(FormBuildUtils.APPLET_HEIGHT, bkuselection.getAppletHeight()); if (MiscUtil.isNotEmpty(bkuselection.getAppletWidth())) map.put(FormBuildUtils.APPLET_WIDTH, bkuselection.getAppletWidth()); } } return map; } public Integer getQaaLevel() { if (oa_auth.getOASTORK() != null && oa_auth.getOASTORK().getQaa() != null) return oa_auth.getOASTORK().getQaa(); else return 4; } /** * @return the requestedAttributes */ public List getRequestedAttributes() { return oa_auth.getOASTORK().getOAAttributes(); } public boolean isRequireConsentForStorkAttributes() { return oa_auth.getOASTORK().isRequireConsent(); } public List getStorkAPs() { return oa_auth.getOASTORK().getAttributeProviders(); } public byte[] getBKUSelectionTemplate() { TemplatesType templates = oa_auth.getTemplates(); if (templates != null && templates.getBKUSelectionTemplate() != null) { return templates.getBKUSelectionTemplate().getTransformation(); } return null; } public byte[] getSendAssertionTemplate() { TemplatesType templates = oa_auth.getTemplates(); if (templates != null && templates.getSendAssertionTemplate() != null) { return templates.getSendAssertionTemplate().getTransformation(); } return null; } }