HOKSAMLAssertionBuilder extends SAMLAssertionBuilder { protected Subject createSubject(final CallbackProperties properties, final X509Certificate certificate, final PublicKey publicKey) throws SAMLComponentBuilderException { String x509Name = properties.getUsername(); x509Name = NhinUtils.getInstance().getSAMLSubjectNameDN(certificate, x509Name); Subject subject = componentBuilder.createSubject(x509Name, publicKey); List<SAMLSubjectConfirmation> subjectConfirmations = properties.getSubjectConfirmations(); if (CollectionUtils.isNotEmpty(subjectConfirmations)) { for (SAMLSubjectConfirmation confirmation : subjectConfirmations) { SubjectConfirmation subjectConfirmation = componentBuilder.createSubjectConfirmation(confirmation); if (subjectConfirmation != null) { subject.getSubjectConfirmations().add(subjectConfirmation); } } } return subject; } HOKSAMLAssertionBuilder();   HOKSAMLAssertionBuilder(final CertificateManager certificateManager); @Override Element build(final CallbackProperties properties, String certificateAlias); List<Statement> createAttributeStatements(final CallbackProperties properties, final Subject subject); void addOptionalStatement(List<Statement> statements, Statement statement); void addOptionalAttributeStatements(List<Statement> statements, List<AttributeStatement> statementList); AuthnStatement createAuthenicationStatements(final CallbackProperties properties); AuthzDecisionStatement createAuthorizationDecisionStatement(final CallbackProperties properties,
        final Subject subject); Evidence createEvidence(final CallbackProperties properties, final Subject subject); Evidence buildEvidence(CallbackProperties properties, List<AttributeStatement> statements, Subject subject); AttributeStatement createSubjectIdAttributeStatement(final CallbackProperties properties); static String appendPrefixHomeCommunityID(final String homeCommunityId); static String checkPrefixBeforeAppend(final String checkValue, final String checkPrefix); static List<Object> checkHcidPrefixInList(final List<Object> valueList);  }
@Test public void testCreateMultipleSubjectConfirmation() throws SAMLComponentBuilderException { final HOKSAMLAssertionBuilder builder = new HOKSAMLAssertionBuilder(); final CallbackProperties callbackProps = mock(CallbackProperties.class); X509Certificate certificate = mock(X509Certificate.class); List<SAMLSubjectConfirmation> samlSubjectConfirmations = new ArrayList<>(); samlSubjectConfirmations.add(createSubjectConfirmationBean(SubjectConfirmation.METHOD_BEARER)); samlSubjectConfirmations.add(createSubjectConfirmationBean(SubjectConfirmation.METHOD_SENDER_VOUCHES)); when(callbackProps.getUsername()).thenReturn("junittest"); when(callbackProps.getSubjectConfirmations()).thenReturn(samlSubjectConfirmations); Subject subject = builder.createSubject(callbackProps, certificate, publicKey); List<SubjectConfirmation> subjectConfirmations = subject.getSubjectConfirmations(); assertTrue(subjectConfirmations.size() == 3); }