/** * 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.data; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import org.w3c.dom.Element; import at.gv.egiz.eaaf.core.api.data.ILoALevelMapper; import at.gv.egiz.eaaf.core.impl.idp.AuthenticationData; import at.gv.egiz.eaaf.core.impl.utils.DOMUtils; import at.gv.egiz.eaaf.modules.pvp2.sp.exception.AssertionAttributeExtractorExeption; import at.gv.egovernment.moa.id.commons.api.data.IMISMandate; import at.gv.egovernment.moa.id.protocols.pvp2x.PVPConstants; import at.gv.egovernment.moa.id.util.LoALevelMapper; import at.gv.egovernment.moa.logging.Logger; import at.gv.egovernment.moa.util.MiscUtil; /** * @author tlenz * */ public class MOAAuthenticationData extends AuthenticationData implements IMOAAuthData, Serializable { private static final long serialVersionUID = 1L; private boolean qualifiedCertificate; private boolean publicAuthority; private String publicAuthorityCode; private String bkuURL; private byte[] signerCertificate = null; private String authBlock = null; private String QAALevel = null; private List encbPKList; //ISA 1.18 attributes private List roles = null; private String pvpAttribute_OU = null; private boolean useMandate = false; private IMISMandate mandate = null; private String mandateReferenceValue = null; private boolean interfederatedSSOSession; private String interfederatedIDP; private LoALevelMapper loaMapper; private boolean iseIDNewDemoMode = false; public MOAAuthenticationData(ILoALevelMapper loaMapper) { if (loaMapper instanceof LoALevelMapper) this.loaMapper = (LoALevelMapper) loaMapper; } /** * @return */ @Override public String getQAALevel() { if (this.QAALevel != null && this.QAALevel.startsWith(PVPConstants.EIDAS_QAA_PREFIX)) { if (loaMapper != null) { String mappedQAA = loaMapper.mapeIDASQAAToSTORKQAA(this.QAALevel); if (MiscUtil.isNotEmpty(mappedQAA)) return mappedQAA; else { Logger.error("eIDAS QAA-level:" + this.QAALevel + " can not be mapped to STORK QAA-level! Use " + PVPConstants.STORK_QAA_1_1 + " as default value."); } } else Logger.error("NO LoALevelMapper found. Use " + PVPConstants.STORK_QAA_1_1 + " as default value."); return PVPConstants.STORK_QAA_1_1; } else return this.QAALevel; } @Override public List getEncbPKList() { if (this.encbPKList == null) this.encbPKList = new ArrayList(); return this.encbPKList; } @Override public byte[] getSignerCertificate() { return signerCertificate; } /** * @param signerCertificate the signerCertificate to set */ public void setSignerCertificate(byte[] signerCertificate) { this.signerCertificate = signerCertificate; } @Override public String getAuthBlock() { return authBlock; } /** * @param authBlock the authBlock to set */ public void setAuthBlock(String authBlock) { this.authBlock = authBlock; } @Override public IMISMandate getMISMandate() { return mandate; } @Override public Element getMandate() { if (mandate == null) return null; //parse Element from mandate XML try { byte[] byteMandate = mandate.getMandate(); String stringMandate = new String(byteMandate); return DOMUtils.parseDocument(stringMandate, false, null, null).getDocumentElement(); } catch (Throwable e) { Logger.warn("Mandate content could not be generated from MISMandate."); return null; } } /** * @param mandate the mandate to set */ public void setMISMandate(IMISMandate mandate) { this.mandate = mandate; } @Override public boolean isUseMandate() { return useMandate; } public void setUseMandate(boolean useMandate) { this.useMandate = useMandate; } @Override public boolean isPublicAuthority() { return publicAuthority; } @Override public String getPublicAuthorityCode() { return publicAuthorityCode; } @Override public boolean isQualifiedCertificate() { return qualifiedCertificate; } @Override public String getBkuURL() { return bkuURL; } /** * Sets the bkuURL * @param url The BKU URL to set */ public void setBkuURL(String url) { this.bkuURL = url; } @Override public boolean isInterfederatedSSOSession() { return this.interfederatedSSOSession; } /** * @param interfederatedSSOSession the interfederatedSSOSession to set */ public void setInterfederatedSSOSession(boolean interfederatedSSOSession) { this.interfederatedSSOSession = interfederatedSSOSession; } @Override public String getInterfederatedIDP() { return this.interfederatedIDP; } /** * @param interfederatedIDP the interfederatedIDP to set */ public void setInterfederatedIDP(String interfederatedIDP) { this.interfederatedIDP = interfederatedIDP; } @Override public String getMandateReferenceValue() { return mandateReferenceValue; } /** * @param mandateReferenceValue the mandateReferenceValue to set */ public void setMandateReferenceValue(String mandateReferenceValue) { this.mandateReferenceValue = mandateReferenceValue; } @Override public List getAuthenticationRoles() { return roles; } //ISA 1.18 attributes /** * @param roles the roles to set */ public void addAuthenticationRole(AuthenticationRole role) { if (this.roles == null) this.roles = new ArrayList(); this.roles.add(role); } @Override public String getPvpAttribute_OU() { return pvpAttribute_OU; } /** * @param pvpAttribute_OU the pvpAttribute_OU to set */ public void setPvpAttribute_OU(String pvpAttribute_OU) { this.pvpAttribute_OU = pvpAttribute_OU; } /** * Store QAA level in eIDAS format to authentication Data * * @param qAALevel the qAALevel to set * @throws AssertionAttributeExtractorExeption */ public void setQAALevel(String qAALevel) { this.QAALevel = qAALevel; } /** * @param encbPKList the encbPKList to set */ public void setEncbPKList(List encbPKList) { this.encbPKList = encbPKList; } /** * Sets the publicAuthority. * @param publicAuthority The publicAuthority to set */ public void setPublicAuthority(boolean publicAuthority) { this.publicAuthority = publicAuthority; } /** * Sets the publicAuthorityCode. * @param publicAuthorityIdentification The publicAuthorityCode to set */ public void setPublicAuthorityCode(String publicAuthorityIdentification) { this.publicAuthorityCode = publicAuthorityIdentification; } /** * Sets the qualifiedCertificate. * @param qualifiedCertificate The qualifiedCertificate to set */ public void setQualifiedCertificate(boolean qualifiedCertificate) { this.qualifiedCertificate = qualifiedCertificate; } public boolean isIseIDNewDemoMode() { return iseIDNewDemoMode; } /** * Set eID demo-mode into AuthData * @param iseIDNewDemoMode true if it is in demo-mode, otherwise false */ public void setIseIDNewDemoMode(boolean iseIDNewDemoMode) { this.iseIDNewDemoMode = iseIDNewDemoMode; } }