continue; final SubjectConfirmationData data = subjectConfirmation.getSubjectConfirmationData(); if (data == null) { continue;
/** * Checks to see whether the schema type of the subject confirmation data, if present, is the required * {@link KeyInfoConfirmationDataType#TYPE_NAME}. * * @param confirmation subject confirmation bearing the confirmation data to be checked * * @return true if the confirmation data's schema type is correct, false otherwise * * @throws AssertionValidationException thrown if there is a problem validating the confirmation data type */ protected boolean isValidConfirmationDataType(@Nonnull final SubjectConfirmation confirmation) throws AssertionValidationException { QName confirmationDataSchemaType = confirmation.getSubjectConfirmationData().getSchemaType(); if (confirmationDataSchemaType != null && !confirmationDataSchemaType.equals(KeyInfoConfirmationDataType.TYPE_NAME)) { log.debug("SubjectConfirmationData xsi:type was non-null and did not match {}", KeyInfoConfirmationDataType.TYPE_NAME); return false; } log.debug("SubjectConfirmationData xsi:type was either null or matched {}", KeyInfoConfirmationDataType.TYPE_NAME); return true; }
/** * 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; }
/** * Validates the <code>NotBefore</code> condition of the {@link SubjectConfirmationData}, if any is present. * * @param confirmation confirmation method, with {@link SubjectConfirmationData}, being validated * @param assertion assertion bearing the confirmation method * @param context current validation context * * @return the result of the validation evaluation * * @throws AssertionValidationException thrown if there is a problem determining the validity of the NotBefore */ @Nonnull protected ValidationResult validateNotBefore(@Nonnull final SubjectConfirmation confirmation, @Nonnull final Assertion assertion, @Nonnull final ValidationContext context) throws AssertionValidationException { DateTime skewedNow = new DateTime(ISOChronology.getInstanceUTC()).plus(SAML20AssertionValidator .getClockSkew(context)); DateTime notBefore = confirmation.getSubjectConfirmationData().getNotBefore(); log.debug("Evaluating SubjectConfirmationData NotBefore '{}' against 'skewed now' time '{}'", notBefore, skewedNow); if (notBefore != null && notBefore.isAfter(skewedNow)) { context.setValidationFailureMessage(String.format( "Subject confirmation, in assertion '%s', with NotBefore condition of '%s' is not yet valid", assertion.getID(), notBefore)); return ValidationResult.INVALID; } return ValidationResult.VALID; }
/** * Validates the <code>NotOnOrAfter</code> condition of the {@link SubjectConfirmationData}, if any is present. * * @param confirmation confirmation method, with {@link SubjectConfirmationData}, being validated * @param assertion assertion bearing the confirmation method * @param context current validation context * * @return the result of the validation evaluation * * @throws AssertionValidationException thrown if there is a problem determining the validity of the NotOnOrAFter */ @Nonnull protected ValidationResult validateNotOnOrAfter(@Nonnull final SubjectConfirmation confirmation, @Nonnull final Assertion assertion, @Nonnull final ValidationContext context) throws AssertionValidationException { DateTime skewedNow = new DateTime(ISOChronology.getInstanceUTC()).minus(SAML20AssertionValidator .getClockSkew(context)); DateTime notOnOrAfter = confirmation.getSubjectConfirmationData().getNotOnOrAfter(); log.debug("Evaluating SubjectConfirmationData NotOnOrAfter '{}' against 'skewed now' time '{}'", notOnOrAfter, skewedNow); if (notOnOrAfter != null && notOnOrAfter.isBefore(skewedNow)) { context.setValidationFailureMessage(String.format( "Subject confirmation, in assertion '%s', with NotOnOrAfter condition of '%s' is no longer valid", assertion.getID(), notOnOrAfter)); return ValidationResult.INVALID; } return ValidationResult.VALID; }
private boolean validateAuthenticationSubject(Message m, Conditions cs, org.opensaml.saml.saml2.core.Subject subject) { // We need to find a Bearer Subject Confirmation method boolean bearerSubjectConfFound = false; if (subject.getSubjectConfirmations() != null) { for (SubjectConfirmation subjectConf : subject.getSubjectConfirmations()) { if (SAML2Constants.CONF_BEARER.equals(subjectConf.getMethod())) { validateSubjectConfirmation(m, cs, subjectConf.getSubjectConfirmationData()); bearerSubjectConfFound = true; } } } return bearerSubjectConfFound; }
/** {@inheritDoc} */ @Nonnull public ValidationResult validate(@Nonnull final SubjectConfirmation confirmation, @Nonnull final Assertion assertion, @Nonnull final ValidationContext context) throws AssertionValidationException { if (confirmation.getSubjectConfirmationData() != null) { ValidationResult result = validateNotBefore(confirmation, assertion, context); if (result != ValidationResult.VALID) { return result; } result = validateNotOnOrAfter(confirmation, assertion, context); if (result != ValidationResult.VALID) { return result; } result = validateRecipient(confirmation, assertion, context); if (result != ValidationResult.VALID) { return result; } result = validateAddress(confirmation, assertion, context); if (result != ValidationResult.VALID) { return result; } } return doValidate(confirmation, assertion, context); }
@Nonnull final Assertion assertion, @Nonnull final ValidationContext context) throws AssertionValidationException { String recipient = StringSupport.trimOrNull(confirmation.getSubjectConfirmationData().getRecipient()); if (recipient == null) { return ValidationResult.VALID;
private boolean validateAuthenticationSubject(Message m, Conditions cs, org.opensaml.saml.saml2.core.Subject subject) { // We need to find a Bearer Subject Confirmation method boolean bearerSubjectConfFound = false; if (subject.getSubjectConfirmations() != null) { for (SubjectConfirmation subjectConf : subject.getSubjectConfirmations()) { if (SAML2Constants.CONF_BEARER.equals(subjectConf.getMethod())) { validateSubjectConfirmation(m, cs, subjectConf.getSubjectConfirmationData()); bearerSubjectConfFound = true; } } } return bearerSubjectConfFound; }
/** * Validate the Subject (of an Authentication Statement). */ private org.opensaml.saml.saml2.core.SubjectConfirmation validateAuthenticationSubject( org.opensaml.saml.saml2.core.Subject subject, String id, boolean postBinding ) throws WSSecurityException { if (subject.getSubjectConfirmations() == null) { return null; } org.opensaml.saml.saml2.core.SubjectConfirmation validSubjectConf = null; // We need to find a Bearer Subject Confirmation method for (org.opensaml.saml.saml2.core.SubjectConfirmation subjectConf : subject.getSubjectConfirmations()) { if (SAML2Constants.CONF_BEARER.equals(subjectConf.getMethod())) { validateSubjectConfirmation(subjectConf.getSubjectConfirmationData(), id, postBinding); validSubjectConf = subjectConf; } } return validSubjectConf; }
@Nonnull final Assertion assertion, @Nonnull final ValidationContext context) throws AssertionValidationException { String address = StringSupport.trimOrNull(confirmation.getSubjectConfirmationData().getAddress()); if (address == null) { return ValidationResult.VALID;
protected List<SubjectConfirmation> getConfirmations( List<org.opensaml.saml.saml2.core .SubjectConfirmation> subjectConfirmations, List<SimpleKey> localKeys ) { List<SubjectConfirmation> result = new LinkedList<>(); for (org.opensaml.saml.saml2.core.SubjectConfirmation s : subjectConfirmations) { NameID nameID = getNameID(s.getNameID(), s.getEncryptedID(), localKeys); result.add( new SubjectConfirmation() .setNameId(nameID != null ? nameID.getValue() : null) .setFormat(nameID != null ? NameId.fromUrn(nameID.getFormat()) : null) .setMethod(SubjectConfirmationMethod.fromUrn(s.getMethod())) .setConfirmationData( new SubjectConfirmationData() .setRecipient(s.getSubjectConfirmationData().getRecipient()) .setNotOnOrAfter(s.getSubjectConfirmationData().getNotOnOrAfter()) .setNotBefore(s.getSubjectConfirmationData().getNotBefore()) .setInResponseTo(s.getSubjectConfirmationData().getInResponseTo()) ) ); } return result; }
for (org.opensaml.saml.saml2.core.SubjectConfirmation subjectConfirmation : subjectConfList) { SubjectConfirmationData subjConfData = subjectConfirmation.getSubjectConfirmationData(); if (subjConfData != null) { Element sub = subjConfData.getDOM();
Instant.ofEpochMilli(subjectConf.getSubjectConfirmationData() .getNotOnOrAfter().toDate().getTime());
/** * Create an efficient field-wise copy of a {@link SubjectConfirmation}. * * @param confirmation the object to clone * * @return the copy */ @Nonnull private SubjectConfirmation cloneConfirmation(@Nonnull final SubjectConfirmation confirmation) { final SubjectConfirmation clone = confirmationBuilder.buildObject(); clone.setMethod(confirmation.getMethod()); final SubjectConfirmationData data = confirmation.getSubjectConfirmationData(); if (data != null) { final SubjectConfirmationData cloneData = confirmationDataBuilder.buildObject(); cloneData.setAddress(data.getAddress()); cloneData.setInResponseTo(data.getInResponseTo()); cloneData.setRecipient(data.getRecipient()); cloneData.setNotBefore(data.getNotBefore()); cloneData.setNotOnOrAfter(data.getNotOnOrAfter()); clone.setSubjectConfirmationData(cloneData); } return clone; }
continue; final SubjectConfirmationData data = subjectConfirmation.getSubjectConfirmationData(); if (data == null) { continue;
isValidBearerSubjectConfirmationData(confirmation.getSubjectConfirmationData(), context)) { NameID nameIDFromConfirmation = confirmation.getNameID(); final BaseID baseIDFromConfirmation = confirmation.getBaseID();