/** * Validates that the given subject confirmation has a confirmation method. * * @param subjectConfirmation subject confirmation to validate * * @throws ValidationException thrown if the given confirmation does not have a confirmation method */ protected void validateSubjectConfirmationMethods(SubjectConfirmation subjectConfirmation) throws ValidationException { if (subjectConfirmation.getConfirmationMethods().size() == 0) { throw new ValidationException("At least Confirmation Method should be present"); } } }
/** {@inheritDoc} */ protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject) throws UnmarshallingException { SubjectConfirmation subjectConfirmation = (SubjectConfirmation) parentSAMLObject; if (childSAMLObject instanceof ConfirmationMethod) { subjectConfirmation.getConfirmationMethods().add((ConfirmationMethod) childSAMLObject); } else if(childSAMLObject instanceof KeyInfo) { subjectConfirmation.setKeyInfo((KeyInfo)childSAMLObject); } else { subjectConfirmation.setSubjectConfirmationData(childSAMLObject); } } }
/** * Creates opensaml SubjectConfirmation representation. The relevant XML would looks as follows, * <pre> <saml:SubjectConfirmation> * <saml:ConfirmationMethod> * urn:oasis:names:tc:SAML:1.0:cm:sender-vouches * </saml:ConfirmationMethod> * </saml:SubjectConfirmation></pre> * @param confirmationMethod The subject confirmation method. Bearer, Sender-Vouches or Holder-Of-Key. * @param keyInfoContent The KeyInfo content. According to SPEC (SAML 1.1) this could be null. * @return OpenSAML representation of SubjectConfirmation. * @throws TrustException If unable to find any of the XML builders. */ public static SubjectConfirmation createSubjectConfirmation(final String confirmationMethod, KeyInfo keyInfoContent) throws TrustException { SubjectConfirmation subjectConfirmation = (SubjectConfirmation)CommonUtil.buildXMLObject(SubjectConfirmation.DEFAULT_ELEMENT_NAME); ConfirmationMethod method = SAMLUtils.createSubjectConfirmationMethod(confirmationMethod); subjectConfirmation.getConfirmationMethods().add(method); if (keyInfoContent != null) { subjectConfirmation.setKeyInfo(keyInfoContent); } return subjectConfirmation; }
/** * 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; }
confirmation.getConfirmationMethods(); for (ConfirmationMethod confirmationMethod : confirmationMethods) { methods.add(confirmationMethod.getConfirmationMethod());
confirmation.getConfirmationMethods(); for (ConfirmationMethod confirmationMethod : confirmationMethods) { methods.add(confirmationMethod.getConfirmationMethod());
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; }
ConfirmationMethod confMethod = (ConfirmationMethod) buildXMLObject(ConfirmationMethod.DEFAULT_ELEMENT_NAME); confMethod.setConfirmationMethod(CONF_KEY); subjectConf.getConfirmationMethods().add(confMethod); subject.setSubjectConfirmation(subjectConf);
ConfirmationMethod confMethod = (ConfirmationMethod) buildXMLObject(ConfirmationMethod.DEFAULT_ELEMENT_NAME); confMethod.setConfirmationMethod(CONF_KEY); subjectConf.getConfirmationMethods().add(confMethod); subject.setSubjectConfirmation(subjectConf);
List<ConfirmationMethod> confirmationMethods = subjectConfirmation.getConfirmationMethods(); for (ConfirmationMethod confirmationMethod : confirmationMethods) { if (OAuthConstants.OAUTH_SAML1_BEARER_METHOD.equals(confirmationMethod.getConfirmationMethod())) {
List<ConfirmationMethod> confirmationMethods = subjectConfirmation.getConfirmationMethods(); for (ConfirmationMethod confirmationMethod : confirmationMethods) { if (OAuthConstants.OAUTH_SAML1_BEARER_METHOD.equals(confirmationMethod.getConfirmationMethod())) {
subjectConfirmation.getConfirmationMethods().add(confirmationMethod); if (subjectBean.getKeyInfo() != null) { KeyInfo keyInfo = createKeyInfo(subjectBean.getKeyInfo());
subjectConfirmation.getConfirmationMethods().add(confirmationMethod); if (subjectBean.getKeyInfo() != null) { KeyInfo keyInfo = createKeyInfo(subjectBean.getKeyInfo());