/** {@inheritDoc} */ protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject) throws UnmarshallingException { Subject subject = (Subject) parentSAMLObject; if (childSAMLObject instanceof NameIdentifier) { subject.setNameIdentifier((NameIdentifier) childSAMLObject); } else if (childSAMLObject instanceof SubjectConfirmation) { subject.setSubjectConfirmation((SubjectConfirmation) childSAMLObject); } else { super.processChildElement(parentSAMLObject, childSAMLObject); } } }
/** * Validates that the subject has either a name identifier or subject confirmation * * @param subject subject to validate * * @throws ValidationException thrown if the subject has neither a name identifier or subject confirmation */ protected void validateNameIdentifierSubjectConfirmation(Subject subject) throws ValidationException { if (subject.getNameIdentifier() == null && subject.getSubjectConfirmation() == null) { throw new ValidationException("Either a NameIdentifier or SubjectConfirmation should be present"); } } }
/** * Get subject confirmation method of the given SAML 1.1 Assertion. * This is used in rampart-core. * @param assertion SAML 1.1 Assertion * @return subject confirmation method */ public static String getSAML11SubjectConfirmationMethod(Assertion assertion) { String subjectConfirmationMethod = RahasConstants.SAML11_SUBJECT_CONFIRMATION_HOK; // iterate the statements and get the subject confirmation method. List<Statement> statements = assertion.getStatements(); // TODO check whether there is an efficient method of doing this if (!statements.isEmpty()) { SubjectStatement subjectStatement = (SubjectStatement) statements.get(0); Subject subject = subjectStatement.getSubject(); if (subject != null) { SubjectConfirmation subjectConfirmation = subject.getSubjectConfirmation(); if (subjectConfirmation != null) { List<ConfirmationMethod> confirmationMethods = subjectConfirmation.getConfirmationMethods(); if (!confirmationMethods.isEmpty()) { subjectConfirmationMethod = confirmationMethods.get(0).getConfirmationMethod(); } } } } return subjectConfirmationMethod; }
if (data.getClaimDialect() != null && data.getClaimElem() != null) { Statement attrStatement = createSAMLAttributeStatement( SAMLUtils.createSubject(subject.getNameIdentifier(), confirmationMethod, keyInfo), data, config); statements.add(attrStatement);
confMethod.setConfirmationMethod(CONF_KEY); subjectConf.getConfirmationMethods().add(confMethod); subject.setSubjectConfirmation(subjectConf);
Subject subject = subjectStatement.getSubject(); if (subject != null) { SubjectConfirmation confirmation = subject.getSubjectConfirmation(); if (confirmation != null) { XMLObject data = confirmation.getSubjectConfirmationData();
if (samlSubject != null && samlSubject.getNameIdentifier() != null) { name = samlSubject.getNameIdentifier().getNameIdentifier();
confMethod.setConfirmationMethod(CONF_KEY); subjectConf.getConfirmationMethods().add(confMethod); subject.setSubjectConfirmation(subjectConf);
subject.setNameIdentifier(nameIdentifier); subject.setSubjectConfirmation(subjectConfirmation);
subject = authenticationStatement.getSubject(); if (subject != null) { String resourceOwnerUserName = subject.getNameIdentifier().getNameIdentifier(); if (resourceOwnerUserName == null || resourceOwnerUserName.equals("")) { if (log.isDebugEnabled()) { SubjectConfirmation subjectConfirmation = subject.getSubjectConfirmation(); List<ConfirmationMethod> confirmationMethods = subjectConfirmation.getConfirmationMethods(); for (ConfirmationMethod confirmationMethod : confirmationMethods) { log.debug("Cannot find Method attribute in SubjectConfirmation " + subject.getSubjectConfirmation()); XMLObject confirmationData = subject.getSubjectConfirmation().getSubjectConfirmationData(); if (confirmationData == null) { log.warn("Subject confirmation data is missing.");
Subject subject = subjectStatement.getSubject(); if (subject != null) { SubjectConfirmation confirmation = subject.getSubjectConfirmation(); if (confirmation != null) { XMLObject data = confirmation.getSubjectConfirmationData();
if (samlSubject != null && samlSubject.getNameIdentifier() != null) { name = samlSubject.getNameIdentifier().getNameIdentifier();
private Subject newSubject(final String identifier) { final SubjectConfirmation confirmation = newSamlObject(SubjectConfirmation.class); final ConfirmationMethod method = newSamlObject(ConfirmationMethod.class); method.setConfirmationMethod(CONFIRMATION_METHOD); confirmation.getConfirmationMethods().add(method); final NameIdentifier nameIdentifier = newSamlObject(NameIdentifier.class); nameIdentifier.setNameIdentifier(identifier); final Subject subject = newSamlObject(Subject.class); subject.setNameIdentifier(nameIdentifier); subject.setSubjectConfirmation(confirmation); return subject; }
subject = authenticationStatement.getSubject(); if (subject != null) { String resourceOwnerUserName = subject.getNameIdentifier().getNameIdentifier(); if (resourceOwnerUserName == null || resourceOwnerUserName.equals("")) { if (log.isDebugEnabled()) { SubjectConfirmation subjectConfirmation = subject.getSubjectConfirmation(); List<ConfirmationMethod> confirmationMethods = subjectConfirmation.getConfirmationMethods(); for (ConfirmationMethod confirmationMethod : confirmationMethods) { log.debug("Cannot find Method attribute in SubjectConfirmation " + subject.getSubjectConfirmation()); XMLObject confirmationData = subject.getSubjectConfirmation().getSubjectConfirmationData(); if (confirmationData == null) { log.warn("Subject confirmation data is missing.");
Element sub = samlSubject.getSubjectConfirmation().getDOM(); Element keyInfoElement = WSSecurityUtil.getDirectChildElement(sub, "KeyInfo", WSConstants.SIG_NS);
subjectConfirmation.setKeyInfo(keyInfo); subject.setNameIdentifier(nameIdentifier); subject.setSubjectConfirmation(subjectConfirmation);
Element sub = samlSubject.getSubjectConfirmation().getDOM(); Element keyInfoElement = WSSecurityUtil.getDirectChildElement(sub, "KeyInfo", WSConstants.SIG_NS);
subjectConfirmation.setKeyInfo(keyInfo); subject.setNameIdentifier(nameIdentifier); subject.setSubjectConfirmation(subjectConfirmation);