/** * Constructor. * * @param owningObject the XMLObject whose namespace info is to be managed */ public NamespaceManager(@Nonnull final XMLObject owningObject) { owner = Constraint.isNotNull(owningObject, "Owner XMLObject cannot be null"); decls = new LazySet<>(); attrNames = new LazySet<>(); attrValues = new LazyMap<>(); }
/** * Constructor. * * @param owningObject the XMLObject whose namespace info is to be managed */ public NamespaceManager(@Nonnull final XMLObject owningObject) { owner = Constraint.isNotNull(owningObject, "Owner XMLObject cannot be null"); decls = new LazySet<>(); attrNames = new LazySet<>(); attrValues = new LazyMap<>(); }
/** * Constructor. * * @param newOwner the XMLObject that owns these attributes */ public AttributeMap(@Nonnull final XMLObject newOwner) { Constraint.isNotNull(newOwner, "Attribute owner XMLObject cannot be null"); attributeOwner = newOwner; attributes = new LazyMap<>(); idAttribNames = new LazySet<>(); qnameAttribNames = new LazySet<>(); }
/** * Constructor. * * @param newOwner the XMLObject that owns these attributes */ public AttributeMap(@Nonnull final XMLObject newOwner) { Constraint.isNotNull(newOwner, "Attribute owner XMLObject cannot be null"); attributeOwner = newOwner; attributes = new LazyMap<>(); idAttribNames = new LazySet<>(); qnameAttribNames = new LazySet<>(); }
/** * Merge 2 or more Namespace collections into a single set. * * @param namespaces list of Namespaces to merge * @return the a new set of merged Namespaces */ @Nonnull private Set<Namespace> mergeNamespaceCollections(Collection<Namespace> ... namespaces) { LazySet<Namespace> newNamespaces = new LazySet<>(); for (Collection<Namespace> nsCollection : namespaces) { for (Namespace ns : nsCollection) { if (ns != null) { addNamespace(newNamespaces, ns); } } } return newNamespaces; }
/** * Merge 2 or more Namespace collections into a single set. * * @param namespaces list of Namespaces to merge * @return the a new set of merged Namespaces */ @Nonnull private Set<Namespace> mergeNamespaceCollections(Collection<Namespace> ... namespaces) { LazySet<Namespace> newNamespaces = new LazySet<>(); for (Collection<Namespace> nsCollection : namespaces) { for (Namespace ns : nsCollection) { if (ns != null) { addNamespace(newNamespaces, ns); } } } return newNamespaces; }
/** {@inheritDoc} */ public void clear() { LazySet<QName> keys = new LazySet<>(); keys.addAll(attributes.keySet()); for (QName attributeName : keys) { remove(attributeName); } }
/** {@inheritDoc} */ public void clear() { LazySet<QName> keys = new LazySet<>(); keys.addAll(attributes.keySet()); for (QName attributeName : keys) { remove(attributeName); } }
/** * Obtain the set of namespace prefixes used in a non-visible manner on owning XMLObject * and its children. * * <p> * The primary use case for this information is to support the inclusive prefixes * information that may optionally be supplied as a part of XML exclusive canonicalization. * </p> * * @return the set of non-visibly used namespace prefixes */ @Nonnull public Set<String> getNonVisibleNamespacePrefixes() { LazySet<String> prefixes = new LazySet<>(); addPrefixes(prefixes, getNonVisibleNamespaces()); return prefixes; }
/** * Obtain the set of namespace prefixes used in a non-visible manner on owning XMLObject * and its children. * * <p> * The primary use case for this information is to support the inclusive prefixes * information that may optionally be supplied as a part of XML exclusive canonicalization. * </p> * * @return the set of non-visibly used namespace prefixes */ @Nonnull public Set<String> getNonVisibleNamespacePrefixes() { LazySet<String> prefixes = new LazySet<>(); addPrefixes(prefixes, getNonVisibleNamespaces()); return prefixes; }
/** * Get the valid audiences for attestation. * * <p> * This implementation returns a set containing the single entityID held by the message context's * {@link SAMLSelfEntityContext#getEntityId()}, if present. Otherwise an empty set is returned. * </p> * * @param input the assertion validation input * * @return set of audience URI's */ @Nonnull protected Set<String> getValidAudiences(@Nonnull final SAML20AssertionTokenValidationInput input) { LazySet<String> validAudiences = new LazySet<>(); SAMLSelfEntityContext selfContext = input.getMessageContext().getSubcontext(SAMLSelfEntityContext.class); if (selfContext != null && selfContext.getEntityId() != null) { validAudiences.add(selfContext.getEntityId()); } log.debug("Resolved valid audiences set: {}", validAudiences); return validAudiences; }
/** * Populate the inclusive namspace prefixes on the specified Apache (exclusive) transform object. * * @param signature the Apache XMLSignature object * @param transform the Apache Transform object representing an exclusive transform */ private void processExclusiveTransform(@Nonnull final XMLSignature signature, @Nonnull final Transform transform) { // Namespaces that aren't visibly used, such as those used in QName attribute values, would // be stripped out by exclusive canonicalization. Need to make sure they aren't by explicitly // telling the transformer about them. log.debug("Adding list of inclusive namespaces for signature exclusive canonicalization transform"); LazySet<String> inclusiveNamespacePrefixes = new LazySet<>(); populateNamespacePrefixes(inclusiveNamespacePrefixes, signableObject); if (inclusiveNamespacePrefixes != null && inclusiveNamespacePrefixes.size() > 0) { InclusiveNamespaces inclusiveNamespaces = new InclusiveNamespaces(signature.getDocument(), inclusiveNamespacePrefixes); transform.getElement().appendChild(inclusiveNamespaces.getElement()); } }
/** * Get the set of non-visibly used namespaces used on the owning XMLObject (only the owner, * not the owner's children). * * @return the set of non-visibly-used namespaces */ @Nonnull private Set<Namespace> getNonVisibleNamespaceCandidates() { LazySet<Namespace> namespaces = new LazySet<>(); // Add xsi:type value's prefix, if element carries an xsi:type if (getElementTypeNamespace() != null) { namespaces.add(getElementTypeNamespace()); } // Add prefixes from attribute and content values for (Namespace attribValue : attrValues.values()) { if (attribValue != null) { namespaces.add(attribValue); } } if (contentValue != null) { namespaces.add(contentValue); } return namespaces; }
/** * Get the set of non-visibly used namespaces used on the owning XMLObject (only the owner, * not the owner's children). * * @return the set of non-visibly-used namespaces */ @Nonnull private Set<Namespace> getNonVisibleNamespaceCandidates() { LazySet<Namespace> namespaces = new LazySet<>(); // Add xsi:type value's prefix, if element carries an xsi:type if (getElementTypeNamespace() != null) { namespaces.add(getElementTypeNamespace()); } // Add prefixes from attribute and content values for (Namespace attribValue : attrValues.values()) { if (attribValue != null) { namespaces.add(attribValue); } } if (contentValue != null) { namespaces.add(contentValue); } return namespaces; }
/** {@inheritDoc} */ @Override protected void initMetadataResolver() throws ComponentInitializationException { super.initMetadataResolver(); if (getSupportedContentTypes() == null) { setSupportedContentTypes(Arrays.asList(DEFAULT_CONTENT_TYPES)); } if (! getSupportedContentTypes().isEmpty()) { supportedContentTypesValue = StringSupport.listToStringValue(getSupportedContentTypes(), ", "); supportedMediaTypes = new LazySet<>(); for (String contentType : getSupportedContentTypes()) { supportedMediaTypes.add(MediaType.parse(contentType)); } } else { supportedMediaTypes = Collections.emptySet(); } log.debug("{} Supported content types are: {}", getLogPrefix(), getSupportedContentTypes()); }
LazySet<MetadataIndexKey> results = new LazySet<>();
/** {@inheritDoc} */ @Nullable public Set<MetadataIndexKey> generateKeys(@Nonnull CriteriaSet criteriaSet) { Constraint.isNotNull(criteriaSet, "CriteriaSet was null"); ArtifactCriterion artifactCrit = criteriaSet.get(ArtifactCriterion.class); if (artifactCrit != null) { LazySet<MetadataIndexKey> results = new LazySet<>(); SAMLArtifact artifact = artifactCrit.getArtifact(); if (artifact instanceof SAMLSourceIDArtifact) { results.add(new ArtifactSourceIDMetadataIndexKey(((SAMLSourceIDArtifact)artifact).getSourceID())); } if (artifact instanceof SAMLSourceLocationArtifact) { results.add(new ArtifactSourceLocationMetadataIndexKey( ((SAMLSourceLocationArtifact)artifact).getSourceLocation())); } return results; } else { return null; } }
/** * Get the set of namespaces which are currently visibly-used on the owning XMLObject (only the owner, * not its children). * * @return the set of visibly-used namespaces */ @Nonnull private Set<Namespace> getVisibleNamespaces() { LazySet<Namespace> namespaces = new LazySet<>(); // Add namespace from element name. if (getElementNameNamespace() != null) { namespaces.add(getElementNameNamespace()); } // Add xsi attribute prefix, if element carries an xsi:type. if (getElementTypeNamespace() != null) { namespaces.add(XSI_NAMESPACE); } // Add namespaces from attribute names for (Namespace attribName : attrNames) { if (attribName != null) { namespaces.add(attribName); } } return namespaces; }
/** * Get the set of namespaces which are currently visibly-used on the owning XMLObject (only the owner, * not its children). * * @return the set of visibly-used namespaces */ @Nonnull private Set<Namespace> getVisibleNamespaces() { LazySet<Namespace> namespaces = new LazySet<>(); // Add namespace from element name. if (getElementNameNamespace() != null) { namespaces.add(getElementNameNamespace()); } // Add xsi attribute prefix, if element carries an xsi:type. if (getElementTypeNamespace() != null) { namespaces.add(XSI_NAMESPACE); } // Add namespaces from attribute names for (Namespace attribName : attrNames) { if (attribName != null) { namespaces.add(attribName); } } return namespaces; }