/** * 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 all namespaces which are in scope within the subtree rooted * at the owning XMLObject. * * @return set of all namespaces in scope for the owning object */ @Nonnull public Set<Namespace> getAllNamespacesInSubtreeScope() { LazySet<Namespace> namespaces = new LazySet<>(); // Collect namespaces for the subtree rooted at each child List<XMLObject> children = getOwner().getOrderedChildren(); if (children != null) { for(XMLObject child : children) { if (child != null) { Set<Namespace> childNamespaces = child.getNamespaceManager().getAllNamespacesInSubtreeScope(); if (!childNamespaces.isEmpty()) { namespaces.addAll(childNamespaces); } } } } // Collect this node's namespaces. for (Namespace myNS : getNamespaces()) { namespaces.add(myNS); } return namespaces; }
LazySet<Namespace> nonVisibleCandidates = new LazySet<>(); Set<Namespace> childNonVisibleNamespaces = child.getNamespaceManager().getNonVisibleNamespaces(); if (!childNonVisibleNamespaces.isEmpty()) { nonVisibleCandidates.addAll(childNonVisibleNamespaces); nonVisibleCandidates.addAll(getNonVisibleNamespaceCandidates()); nonVisibleCandidates.removeAll(getVisibleNamespaces()); nonVisibleCandidates.remove(XML_NAMESPACE);
/** * 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()); } }
/** * 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<>(); }
/** * Get the set of all namespaces which are in scope within the subtree rooted * at the owning XMLObject. * * @return set of all namespaces in scope for the owning object */ @Nonnull public Set<Namespace> getAllNamespacesInSubtreeScope() { LazySet<Namespace> namespaces = new LazySet<>(); // Collect namespaces for the subtree rooted at each child List<XMLObject> children = getOwner().getOrderedChildren(); if (children != null) { for(XMLObject child : children) { if (child != null) { Set<Namespace> childNamespaces = child.getNamespaceManager().getAllNamespacesInSubtreeScope(); if (!childNamespaces.isEmpty()) { namespaces.addAll(childNamespaces); } } } } // Collect this node's namespaces. for (Namespace myNS : getNamespaces()) { namespaces.add(myNS); } return namespaces; }
LazySet<Namespace> nonVisibleCandidates = new LazySet<>(); Set<Namespace> childNonVisibleNamespaces = child.getNamespaceManager().getNonVisibleNamespaces(); if (!childNonVisibleNamespaces.isEmpty()) { nonVisibleCandidates.addAll(childNonVisibleNamespaces); nonVisibleCandidates.addAll(getNonVisibleNamespaceCandidates()); nonVisibleCandidates.removeAll(getVisibleNamespaces()); nonVisibleCandidates.remove(XML_NAMESPACE);
/** * 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; }
/** * 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<>(); }
/** * 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; }
/** * 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<>(); }
LazySet<InetAddress> validAddresses = new LazySet<>(); InetAddress[] addresses = null; String attesterIPAddress = getAttesterIPAddress(input); if (attesterIPAddress != null) { addresses = InetAddress.getAllByName(attesterIPAddress); validAddresses.addAll(Arrays.asList(addresses)); log.debug("Resolved valid subject confirmation InetAddress set: {}", validAddresses); return validAddresses;
/** * 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; }
/** * 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<>(); }
/** * 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; }
/** * 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; }