/** Constructor. */ public WSSecurityContext() { super(); tokens = new LazyList<>(); }
/** * Constructor. * * @param newSignableObject the SAMLObject this reference refers to */ public SAMLObjectContentReference(@Nonnull final SignableSAMLObject newSignableObject) { signableObject = newSignableObject; transforms = new LazyList<>(); // Set defaults digestAlgorithm = SignatureConstants.ALGO_ID_DIGEST_SHA256; transforms.add(SignatureConstants.TRANSFORM_ENVELOPED_SIGNATURE); transforms.add(SignatureConstants.TRANSFORM_C14N_EXCL_OMIT_COMMENTS); }
/** * Resolve the SAML 2.0 Assertions token from the SOAP envelope. * * @param messageContext the current message context * * @return the list of resolved Assertions, or an empty list */ @Nonnull protected List<Assertion> resolveAssertions(@Nonnull final MessageContext messageContext) { List<XMLObject> securityHeaders = SOAPMessagingSupport.getInboundHeaderBlock(messageContext, Security.ELEMENT_NAME); if (securityHeaders == null || securityHeaders.isEmpty()) { log.debug("No WS-Security Security header found in inbound SOAP message. Skipping further processing."); return Collections.emptyList(); } LazyList<Assertion> assertions = new LazyList<>(); // There could be multiple Security headers targeted to this node, so process all of them for (XMLObject header : securityHeaders) { Security securityHeader = (Security) header; List<XMLObject> xmlObjects = securityHeader.getUnknownXMLObjects(Assertion.DEFAULT_ELEMENT_NAME); if (xmlObjects != null && !xmlObjects.isEmpty()) { for (XMLObject xmlObject : xmlObjects) { assertions.add((Assertion) xmlObject); } } } return assertions; }
/** * Check for the existence of an index for the specified QName and create it * if it doesn't exist. * * @param index the index to check */ protected void checkAndCreateIndex(@Nonnull final QName index) { if (!objectIndex.containsKey(index)) { objectIndex.put(index, new LazyList<ElementType>()); } }
/** * Get a header block from the SOAP 1.1 envelope. * * @param envelope the SOAP 1.1 envelope to process * @param headerName the name of the header block to return * @param targetNodes the explicitly specified SOAP node actors for which the header is desired * @param isFinalDestination true specifies that headers targeted for message final destination should be returned, * false specifies they should not be returned * @return the list of matching header blocks */ @Nonnull public static List<XMLObject> getSOAP11HeaderBlock(@Nonnull final Envelope envelope, @Nonnull final QName headerName, @Nullable final Set<String> targetNodes, boolean isFinalDestination) { Constraint.isNotNull(envelope, "Envelope cannot be null"); Constraint.isNotNull(headerName, "Header name cannot be null"); Header envelopeHeader = envelope.getHeader(); if (envelopeHeader == null) { return Collections.emptyList(); } LazyList<XMLObject> headers = new LazyList<>(); for (XMLObject header : envelopeHeader.getUnknownXMLObjects(headerName)) { if (isSOAP11HeaderTargetedToNode(header, targetNodes, isFinalDestination)) { headers.add(header); } } return headers; }
/** * Check for the existence of an index for the specified QName and create it * if it doesn't exist. * * @param index the index to check */ protected void checkAndCreateIndex(@Nonnull final QName index) { if (!objectIndex.containsKey(index)) { objectIndex.put(index, new LazyList<ElementType>()); } }
/** Constructor. */ public ItemCollectionWithMetadata() { delegate = new LazyList<>(); metadata = new ClassToInstanceMultiMap<>(true); }
/** * Constructs an empty list with all added XMLObjects being assigned the given parent XMLObject. * * @param newParent the parent for all the added XMLObjects */ public XMLObjectChildrenList(@Nonnull final XMLObject newParent) { Constraint.isNotNull(newParent, "Parent cannot be null"); parent = newParent; elements = new LazyList<>(); }
/** * Constructs an empty list with all added XMLObjects being assigned the given parent XMLObject. * * @param newParent the parent for all the added XMLObjects */ public XMLObjectChildrenList(@Nonnull final XMLObject newParent) { Constraint.isNotNull(newParent, "Parent cannot be null"); parent = newParent; elements = new LazyList<>(); }
/** {@inheritDoc} */ @Override @Nonnull protected List<X509Certificate> getCertificates() { final List<X509Certificate> certs = new LazyList<>(); for (final String cert : certificates) { try { certs.add(X509Support.decodeCertificate(cert.trim())); } catch (final CertificateException e) { log.error("{}: Could not decode provided Certificate", getConfigDescription(), e); throw new FatalBeanException("Could not decode provided Certificate", e); } } return certs; }
/** * Pluck the languages from the browser. * * @return the two letter language */ @Nonnull @NonnullElements protected List<String> getBrowserLanguages() { final Enumeration<Locale> locales = getHttpServletRequest().getLocales(); final List<String> languages = new LazyList<>(); while (locales.hasMoreElements()) { final Locale locale = locales.nextElement(); if (null != locale.getLanguage()) { languages.add(locale.getLanguage()); } } return languages; }
/** * Pluck the languages from the browser. * * @return the two letter language */ @Nonnull @NonnullElements private List<String> getBrowserLanguages() { final Enumeration<Locale> locales = getHttpServletRequest().getLocales(); final List<String> languages = new LazyList<>(); while (locales.hasMoreElements()) { final Locale locale = locales.nextElement(); if (null != locale.getLanguage()) { languages.add(locale.getLanguage()); } } return languages; }
/** * Extracts the {@link KeyInfo}s from the given subject confirmation data. * * @param confirmation subject confirmation data * @param assertion assertion bearing the subject to be confirmed * @param context current message processing context * * @return list of key informations available in the subject confirmation data, never null * * @throws AssertionValidationException if there is a problem processing the SubjectConfirmation * */ @Nonnull protected List<KeyInfo> getSubjectConfirmationKeyInformation( @Nonnull final SubjectConfirmation confirmation, @Nonnull final Assertion assertion, @Nonnull final ValidationContext context) throws AssertionValidationException { SubjectConfirmationData confirmationData = confirmation.getSubjectConfirmationData(); List<KeyInfo> keyInfos = new LazyList<>(); for (XMLObject object : confirmationData.getUnknownXMLObjects(KeyInfo.DEFAULT_ELEMENT_NAME)) { if (object != null) { keyInfos.add((KeyInfo) object); } } log.debug("Found '{}' KeyInfo children of SubjectConfirmationData", keyInfos.size()); return keyInfos; }
/** {@inheritDoc} */ @Override @Nullable protected List<X509CRL> getCRLs() { if (null == crls) { return null; } final List<X509CRL> result = new LazyList<>(); for (final String crl : crls) { try { result.add(X509Support.decodeCRL(crl)); } catch (final CRLException | CertificateException e) { log.error("{}: Could not decode provided CRL", getConfigDescription(), e); throw new FatalBeanException("Could not decode provided CRL", e); } } return result; } }
/** * Constructs a list containing the elements in the specified collection, in the order they are returned by the * collection's iterator, with each added XMLObject assigned the given parent XMLObject. * * <p>An IllegalArgumentException is thrown if any of the XMLObjects in the given collection already have a parent * other than the given parent * * @param newParent the parent for all the added XMLObjects * @param newElements the elements to be added */ public XMLObjectChildrenList(@Nonnull final XMLObject newParent, @Nonnull final Collection<ElementType> newElements) { Constraint.isNotNull(newParent, "Parent cannot be null"); Constraint.isNotNull(newElements, "Initial collection cannot be null"); parent = newParent; elements = new LazyList<>(); // This does call our add, which handles the null case properly, but // I didn't want to depend on that implementation. Keeping the fail silently // behavior means not using an Immutable collection copy. addAll(Collections2.filter(newElements, Predicates.notNull())); }
/** * Gets the {@link ItemMetadata} to be added to each {@link Item}'s item metadata. * * @param metadata the {@link ItemMetadata} to be added to each {@link Item}'s item metadata */ public void setAdditionalItemMetadata(@Nonnull final Collection<ItemMetadata> metadata) { ComponentSupport.ifDestroyedThrowDestroyedComponentException(this); ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); Constraint.isNotNull(metadata, "additional metadata collection must not be null"); additionalItemMetadata = new LazyList<>(); CollectionSupport.addIf(additionalItemMetadata, metadata, Predicates.notNull()); }
/** * Constructs a list containing the elements in the specified collection, in the order they are returned by the * collection's iterator, with each added XMLObject assigned the given parent XMLObject. * * <p>An IllegalArgumentException is thrown if any of the XMLObjects in the given collection already have a parent * other than the given parent * * @param newParent the parent for all the added XMLObjects * @param newElements the elements to be added */ public XMLObjectChildrenList(@Nonnull final XMLObject newParent, @Nonnull final Collection<ElementType> newElements) { Constraint.isNotNull(newParent, "Parent cannot be null"); Constraint.isNotNull(newElements, "Initial collection cannot be null"); parent = newParent; elements = new LazyList<>(); // This does call our add, which handles the null case properly, but // I didn't want to depend on that implementation. Keeping the fail silently // behavior means not using an Immutable collection copy. addAll(Collections2.filter(newElements, Predicates.notNull())); }