/* * 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.protocols.pvp2x.config; import java.util.Arrays; import java.util.List; import org.opensaml.saml2.core.Attribute; import org.opensaml.saml2.core.NameIDType; import org.opensaml.saml2.metadata.ContactPerson; import org.opensaml.saml2.metadata.Organization; import org.opensaml.saml2.metadata.RequestedAttribute; import org.opensaml.xml.security.credential.Credential; import at.gv.egiz.eaaf.modules.pvp2.PVPConstants; import at.gv.egiz.eaaf.modules.pvp2.api.metadata.IPVPMetadataBuilderConfiguration; import at.gv.egiz.eaaf.modules.pvp2.exception.CredentialsNotAvailableException; import at.gv.egiz.eaaf.modules.pvp2.impl.builder.PVPAttributeBuilder; import at.gv.egiz.eaaf.modules.pvp2.impl.utils.AbstractCredentialProvider; import at.gv.egovernment.moa.id.commons.api.exceptions.ConfigurationException; import at.gv.egovernment.moa.logging.Logger; /** * @author tlenz * */ public class IDPPVPMetadataConfiguration implements IPVPMetadataBuilderConfiguration { private static final int VALIDUNTIL_IN_HOURS = 24; private String authURL; private AbstractCredentialProvider credentialProvider; private PVPConfiguration pvpBasicConfiguration; public IDPPVPMetadataConfiguration(String authURL, AbstractCredentialProvider pvpIDPCredentials, PVPConfiguration pvpBasicConfiguration) { this.authURL = authURL; this.credentialProvider = pvpIDPCredentials; this.pvpBasicConfiguration = pvpBasicConfiguration; } public String getDefaultActionName() { return (PVPConstants.METADATA); } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.builder.AbstractPVPMetadataBuilder#getMetadataValidUntil() */ @Override public int getMetadataValidUntil() { return VALIDUNTIL_IN_HOURS; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.builder.AbstractPVPMetadataBuilder#buildEntitiesDescriptorAsRootElement() */ @Override public boolean buildEntitiesDescriptorAsRootElement() { return true; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.builder.AbstractPVPMetadataBuilder#buildIDPSSODescriptor() */ @Override public boolean buildIDPSSODescriptor() { return true; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.builder.AbstractPVPMetadataBuilder#buildSPSSODescriptor() */ @Override public boolean buildSPSSODescriptor() { return false; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.builder.AbstractPVPMetadataBuilder#getEntityID() */ @Override public String getEntityID() { try { return pvpBasicConfiguration.getIDPSSOMetadataService(authURL); } catch (ConfigurationException e) { Logger.error("Can not load Metadata entry: EntityID", e); return null; } } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.builder.AbstractPVPMetadataBuilder#getEntityFriendlyName() */ @Override public String getEntityFriendlyName() { try { return pvpBasicConfiguration.getIDPIssuerName(); } catch (ConfigurationException e) { Logger.error("Can not load Metadata entry: EntityID friendlyName.", e); return null; } } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.builder.AbstractPVPMetadataBuilder#getContactPersonInformation() */ @Override public List getContactPersonInformation() { try { return pvpBasicConfiguration.getIDPContacts(); } catch (ConfigurationException e) { Logger.warn("Can not load Metadata entry: Contect Person", e); return null; } } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.builder.AbstractPVPMetadataBuilder#getOrgansiationInformation() */ @Override public Organization getOrgansiationInformation() { try { return pvpBasicConfiguration.getIDPOrganisation(); } catch (ConfigurationException e) { Logger.warn("Can not load Metadata entry: Organisation", e); return null; } } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.builder.AbstractPVPMetadataBuilder#getMetadataSigningCredentials() */ @Override public Credential getMetadataSigningCredentials() throws CredentialsNotAvailableException { return credentialProvider.getIDPMetaDataSigningCredential(); } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.builder.AbstractPVPMetadataBuilder#getRequestorResponseSigningCredentials() */ @Override public Credential getRequestorResponseSigningCredentials() throws CredentialsNotAvailableException { return credentialProvider.getIDPAssertionSigningCredential(); } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.builder.AbstractPVPMetadataBuilder#getEncryptionCredentials() */ @Override public Credential getEncryptionCredentials() throws CredentialsNotAvailableException { return credentialProvider.getIDPAssertionEncryptionCredential(); } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.builder.AbstractPVPMetadataBuilder#getIDPWebSSOPostBindingURL() */ @Override public String getIDPWebSSOPostBindingURL() { return authURL + PVPConfiguration.PVP2_IDP_POST; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.builder.AbstractPVPMetadataBuilder#getIDPWebSSORedirectBindingURL() */ @Override public String getIDPWebSSORedirectBindingURL() { return authURL + PVPConfiguration.PVP2_IDP_REDIRECT; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.builder.AbstractPVPMetadataBuilder#getIDPSLOPostBindingURL() */ @Override public String getIDPSLOPostBindingURL() { return authURL + PVPConfiguration.PVP2_IDP_POST; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.builder.AbstractPVPMetadataBuilder#getIDPSLORedirectBindingURL() */ @Override public String getIDPSLORedirectBindingURL() { return authURL + PVPConfiguration.PVP2_IDP_REDIRECT; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.builder.AbstractPVPMetadataBuilder#getSPAssertionConsumerServicePostBindingURL() */ @Override public String getSPAssertionConsumerServicePostBindingURL() { return null; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.builder.AbstractPVPMetadataBuilder#getSPAssertionConsumerServiceRedirectBindingURL() */ @Override public String getSPAssertionConsumerServiceRedirectBindingURL() { return null; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.builder.AbstractPVPMetadataBuilder#getSPSLOPostBindingURL() */ @Override public String getSPSLOPostBindingURL() { return null; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.builder.AbstractPVPMetadataBuilder#getSPSLORedirectBindingURL() */ @Override public String getSPSLORedirectBindingURL() { return null; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.builder.AbstractPVPMetadataBuilder#getSPSLOSOAPBindingURL() */ @Override public String getSPSLOSOAPBindingURL() { return null; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.builder.AbstractPVPMetadataBuilder#getIDPPossibleAttributes() */ @Override public List getIDPPossibleAttributes() { return PVPAttributeBuilder.buildSupportedEmptyAttributes(); } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.builder.AbstractPVPMetadataBuilder#getIDPPossibleNameITTypes() */ @Override public List getIDPPossibleNameITTypes() { return Arrays.asList(NameIDType.PERSISTENT, NameIDType.TRANSIENT, NameIDType.UNSPECIFIED); } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.builder.AbstractPVPMetadataBuilder#getSPRequiredAttributes() */ @Override public List getSPRequiredAttributes() { return null; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.builder.AbstractPVPMetadataBuilder#getSPAllowedNameITTypes() */ @Override public List getSPAllowedNameITTypes() { return null; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.config.IPVPMetadataBuilderConfiguration#getSPNameForLogging() */ @Override public String getSPNameForLogging() { return "MOA-ID-Auth"; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.config.IPVPMetadataBuilderConfiguration#wantAssertionSigned() */ @Override public boolean wantAssertionSigned() { return false; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.pvp2x.config.IPVPMetadataBuilderConfiguration#wantAuthnRequestSigned() */ @Override public boolean wantAuthnRequestSigned() { return true; } }