package edu.internet2.middleware.shibboleth.artifact.provider;
import java.net.URI;
+import java.net.URISyntaxException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import org.opensaml.artifact.SAMLArtifactType0001;
import org.opensaml.artifact.SAMLArtifactType0002;
import org.opensaml.artifact.Util;
+import org.w3c.dom.Element;
import edu.internet2.middleware.shibboleth.artifact.ArtifactMapper;
import edu.internet2.middleware.shibboleth.artifact.ArtifactMapping;
public abstract class BaseArtifactMapper implements ArtifactMapper {
private static Logger log = Logger.getLogger(BaseArtifactMapper.class.getName());
- // TODO init from config
private URI type2SourceLocation;
-
private MessageDigest md;
public BaseArtifactMapper() throws ShibbolethConfigurationException {
throw new ShibbolethConfigurationException(
"The IdP Artifact Mapper requires JCE support for the SHA-1 digest algorithm.");
}
+ }
+
+ public BaseArtifactMapper(Element config) throws ShibbolethConfigurationException {
+
+ this();
+ String attribute = config.getAttribute("sourceLocation");
+ if (attribute != null && !attribute.equals("")) {
+ try {
+ type2SourceLocation = new URI(attribute);
+ log.debug("Artifact Mapper configured to issue Type 1 artifacts & Type 2 artifacts with a "
+ + "sourceLocation of (" + type2SourceLocation + ").");
+ } catch (URISyntaxException e) {
+ log.error("(sourceLocation) attribute for <ArtifactMapper/> is not a valid URI: " + e);
+ throw new ShibbolethConfigurationException("Unable to initialize Artifact mapper");
+ }
+ } else {
+ log.debug("No (sourceLocaton) attribute found for element <ArtifactMapper/>. The Artifact Mapper will "
+ + "only be able to send Type 1 artifacts.");
+ }
}
public Artifact generateArtifact(SAMLAssertion assertion, RelyingParty relyingParty) {
private boolean forceAttributeNoPush = false;
private boolean defaultToPOST = true;
private boolean wantsAssertionsSigned = false;
+ private int preferredArtifactType = 1;
public RelyingPartyImpl(Element partyConfig, IdPConfig globalConfig, Credentials credentials,
NameMapper nameMapper) throws ServiceProviderMapperException {
log.debug("No attribute push forcing is set to (" + forceAttributeNoPush + ").");
}
+ attribute = ((Element) partyConfig).getAttribute("preferredArtifactType");
+ if (attribute != null && !attribute.equals("")) {
+ log.debug("Overriding AAUrl for Relying Pary (" + name + ") with (" + attribute + ").");
+ try {
+ preferredArtifactType = Integer.parseInt(attribute);
+ } catch (NumberFormatException e) {
+ log.error("(preferredArtifactType) attribute to is not a valid integer.");
+ throw new ServiceProviderMapperException("Configuration is invalid.");
+ }
+ log.debug("Preferred artifact type: (" + preferredArtifactType + ").");
+ }
+
// Load and verify the name format that the HS should use in
// assertions for this RelyingParty
NodeList hsNameFormats = ((Element) partyConfig).getElementsByTagNameNS(IdPConfig.configNameSpace,
public int getPreferredArtifactType() {
- // TODO make configurable
- return 1;
+ return preferredArtifactType;
}
/**