本文整理匯總了Java中uk.gov.ida.saml.core.test.builders.AssertionBuilder類的典型用法代碼示例。如果您正苦於以下問題:Java AssertionBuilder類的具體用法?Java AssertionBuilder怎麽用?Java AssertionBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AssertionBuilder類屬於uk.gov.ida.saml.core.test.builders包,在下文中一共展示了AssertionBuilder類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: build
import uk.gov.ida.saml.core.test.builders.AssertionBuilder; //導入依賴的package包/類
public AttributeQueryRequestDto build(String persistentIdName, String matchingDatasetAssertionId, String
authnStatementAssertionId, String requestId) {
XmlObjectToBase64EncodedStringTransformer<XMLObject> toBase64EncodedStringTransformer = new XmlObjectToBase64EncodedStringTransformer<>();
final PersistentId persistentId = aPersistentId().withNameId(persistentIdName).build();
Assertion authnStatementAssertion = AssertionBuilder.anAssertion().withId(authnStatementAssertionId).buildUnencrypted();
String authnStatementAssertionString = toBase64EncodedStringTransformer.apply(authnStatementAssertion);
EncryptedAssertion encryptedMdsAssertion = AssertionBuilder.anAssertion().withId(matchingDatasetAssertionId).build();
String encryptedMdsAssertionString = toBase64EncodedStringTransformer.apply(encryptedMdsAssertion);
return aHubMatchingServiceRequestDto()
.withId(requestId)
.withMatchingServiceEntityId(TestEntityIds.TEST_RP_MS)
.withPersistentId(persistentId)
.withEncryptedMatchingDatasetAssertion(encryptedMdsAssertionString)
.withAuthnStatementAssertion(authnStatementAssertionString)
.build();
}
示例2: aDefaultAssertion
import uk.gov.ida.saml.core.test.builders.AssertionBuilder; //導入依賴的package包/類
private AssertionBuilder aDefaultAssertion() {
return
anAssertion()
.withSubject(aSubject()
.withNameId(aNameId().withValue("some-pid").build())
.build())
.withConditions(aConditions()
.withoutDefaultAudienceRestriction()
.addAudienceRestriction(anAudienceRestriction()
.withAudienceId(VERIFY_SERVICE_PROVIDER_ENTITY_ID)
.build())
.build())
.addAuthnStatement(anAuthnStatement()
.withAuthnContext(anAuthnContext()
.withAuthnContextClassRef(anAuthnContextClassRef()
.withAuthnContextClasRefValue(IdaAuthnContext.LEVEL_2_AUTHN_CTX)
.build())
.build())
.build());
}
示例3: beforeClass
import uk.gov.ida.saml.core.test.builders.AssertionBuilder; //導入依賴的package包/類
@BeforeClass
public static void beforeClass() throws Exception {
IdaSamlBootstrap.bootstrap();
JerseyClientConfiguration jerseyClientConfiguration = JerseyClientConfigurationBuilder.aJerseyClientConfiguration().withTimeout(Duration.seconds(10)).build();
client = new JerseyClientBuilder(policy.getEnvironment())
.using(jerseyClientConfiguration)
.build(EidasSessionResourceContractTest.class.getSimpleName());
sessionId = SessionId.createNewSessionId();
samlAuthnResponseContainerDto = createAuthnResponseSignedByKeyPair(sessionId, TestCertificateStrings.STUB_IDP_PUBLIC_PRIMARY_CERT, TestCertificateStrings.STUB_IDP_PUBLIC_PRIMARY_PRIVATE_KEY);
encryptedIdentityAssertion = AssertionBuilder.anAssertion().withId(UUID.randomUUID().toString()).build();
encryptedIdentityAssertionString = XML_OBJECT_XML_OBJECT_TO_BASE_64_ENCODED_STRING_TRANSFORMER.apply(encryptedIdentityAssertion);
}
示例4: build
import uk.gov.ida.saml.core.test.builders.AssertionBuilder; //導入依賴的package包/類
public EidasAttributeQueryRequestDto build() {
XmlObjectToBase64EncodedStringTransformer<XMLObject> toBase64EncodedStringTransformer = new XmlObjectToBase64EncodedStringTransformer<>();
EncryptedAssertion encryptedIdentityAssertion = AssertionBuilder.anAssertion().withId(UUID.randomUUID().toString()).build();
String encryptedIdentityAssertionString = toBase64EncodedStringTransformer.apply(encryptedIdentityAssertion);
return anEidasAttributeQueryRequestDto().withEncryptedIdentityAssertion(encryptedIdentityAssertionString).build();
}
示例5: aSignedAssertion
import uk.gov.ida.saml.core.test.builders.AssertionBuilder; //導入依賴的package包/類
private AssertionBuilder aSignedAssertion() {
return anAssertion()
.withSubject(aValidSubject().build())
.withConditions(aValidConditions().build())
.withSignature(aSignature()
.withSigningCredential(testRpMsaSigningCredential)
.build());
}
示例6: anAssertionWith
import uk.gov.ida.saml.core.test.builders.AssertionBuilder; //導入依賴的package包/類
private AssertionBuilder anAssertionWith(String pid, String levelOfAssurance) {
return aSignedAssertion()
.withSubject(aValidSubject().withPersistentId(pid).build())
.withConditions(aValidConditions().build())
.addAuthnStatement(anAuthnStatement()
.withAuthnContext(anAuthnContext()
.withAuthnContextClassRef(anAuthnContextClassRef()
.withAuthnContextClasRefValue(levelOfAssurance).build())
.build())
.build());
}
示例7: aResponseFromIdpBuilder
import uk.gov.ida.saml.core.test.builders.AssertionBuilder; //導入依賴的package包/類
public ResponseBuilder aResponseFromIdpBuilder(String idpEntityId,
String ipAddressSeenByIdp,
String requestId,
DateTime issueInstant,
String authnStatementAssertionId,
String authnAssertionSubjectPid,
String authnAssertionIssuer,
String authnAssertionInResponseTo,
String mdsStatementAssertionId,
String mdsAssertionSubjectPid,
String mdsAssertionIssuer,
String mdsAssertionInResponseTo,
Optional<BasicCredential> basicCredential) throws Exception {
TestCredentialFactory idpSigningCredentialFactory =
new TestCredentialFactory(publicSigningCerts.get(idpEntityId), privateSigningKeys.get(idpEntityId));
final Subject mdsAssertionSubject = SubjectBuilder.aSubject()
.withPersistentId(mdsAssertionSubjectPid)
.withSubjectConfirmation(SubjectConfirmationBuilder.aSubjectConfirmation()
.withSubjectConfirmationData(SubjectConfirmationDataBuilder.aSubjectConfirmationData()
.withInResponseTo(mdsAssertionInResponseTo)
.build())
.build())
.build();
final Subject authnAssertionSubject = SubjectBuilder.aSubject()
.withNameId(buildNameID(authnAssertionSubjectPid))
.withSubjectConfirmation(SubjectConfirmationBuilder.aSubjectConfirmation()
.withSubjectConfirmationData(SubjectConfirmationDataBuilder.aSubjectConfirmationData()
.withInResponseTo(authnAssertionInResponseTo)
.build())
.build())
.build();
final AttributeStatement matchingDatasetAttributeStatement = MatchingDatasetAttributeStatementBuilder_1_1.aMatchingDatasetAttributeStatement_1_1().build();
final Credential encryptingCredential;
if(basicCredential.isPresent()) {
encryptingCredential = basicCredential.get();
} else {
encryptingCredential = hubEncryptionCredentialFactory.getEncryptingCredential();
}
final Credential signingCredential = idpSigningCredentialFactory.getSigningCredential();
final AssertionBuilder mdsAssertion = AssertionBuilder.anAssertion().withId(generateId())
.withIssuer(IssuerBuilder.anIssuer().withIssuerId(mdsAssertionIssuer).build())
.withSubject(mdsAssertionSubject)
.withId(mdsStatementAssertionId)
.addAttributeStatement(matchingDatasetAttributeStatement);
final AssertionBuilder authnAssertion = AssertionBuilder.anAssertion().withId(generateId())
.addAttributeStatement(anAttributeStatement().addAttribute(anIPAddress().withValue(ipAddressSeenByIdp).build()).build())
.withIssuer(IssuerBuilder.anIssuer().withIssuerId(authnAssertionIssuer).build())
.withSubject(authnAssertionSubject)
.withId(authnStatementAssertionId)
.withIssueInstant(issueInstant)
.addAuthnStatement(AuthnStatementBuilder.anAuthnStatement().build());
ResponseBuilder responseBuilder = ResponseBuilder.aResponse().withId(generateId())
.withIssuer(IssuerBuilder.anIssuer().withIssuerId(idpEntityId).build())
.withSigningCredential(signingCredential)
.withInResponseTo(requestId)
.addEncryptedAssertion(mdsAssertion
.withSignature(SignatureBuilder.aSignature().withSigningCredential(signingCredential).build())
.buildWithEncrypterCredential(encryptingCredential))
.addEncryptedAssertion(authnAssertion
.withSignature(SignatureBuilder.aSignature().withSigningCredential(signingCredential).build())
.buildWithEncrypterCredential(encryptingCredential));
return responseBuilder;
}
示例8: aFraudResponseFromIdpBuilder
import uk.gov.ida.saml.core.test.builders.AssertionBuilder; //導入依賴的package包/類
public ResponseBuilder aFraudResponseFromIdpBuilder(String idpEntityId, String persistentId) throws Exception {
TestCredentialFactory idpSigningCredentialFactory =
new TestCredentialFactory(publicSigningCerts.get(idpEntityId), privateSigningKeys.get(idpEntityId));
String requestId = generateId();
final Subject mdsAssertionSubject = SubjectBuilder.aSubject()
.withPersistentId(persistentId)
.withSubjectConfirmation(SubjectConfirmationBuilder.aSubjectConfirmation()
.withSubjectConfirmationData(SubjectConfirmationDataBuilder.aSubjectConfirmationData()
.withInResponseTo(requestId)
.build())
.build())
.build();
final Subject authnAssertionSubject = SubjectBuilder.aSubject()
.withNameId(buildNameID(persistentId))
.withSubjectConfirmation(SubjectConfirmationBuilder.aSubjectConfirmation()
.withSubjectConfirmationData(SubjectConfirmationDataBuilder.aSubjectConfirmationData()
.withInResponseTo(requestId)
.build())
.build())
.build();
final AttributeStatement matchingDatasetAttributeStatement = MatchingDatasetAttributeStatementBuilder_1_1.aMatchingDatasetAttributeStatement_1_1().build();
final Credential encryptingCredential = hubEncryptionCredentialFactory.getEncryptingCredential();
final Credential signingCredential = idpSigningCredentialFactory.getSigningCredential();
final AssertionBuilder mdsAssertion = AssertionBuilder.anAssertion().withId(generateId())
.withIssuer(IssuerBuilder.anIssuer().withIssuerId(idpEntityId).build())
.withSubject(mdsAssertionSubject)
.addAttributeStatement(matchingDatasetAttributeStatement);
final AssertionBuilder authnAssertion = AssertionBuilder.anAssertion().withId(generateId())
.addAttributeStatement(anAttributeStatement()
.addAttribute(IdpFraudEventIdAttributeBuilder.anIdpFraudEventIdAttribute().withValue("a-fraud-event").build())
.addAttribute(Gpg45StatusAttributeBuilder.aGpg45StatusAttribute().withValue("IT01").build())
.addAttribute(anIPAddress().build())
.build())
.withIssuer(IssuerBuilder.anIssuer().withIssuerId(idpEntityId).build())
.withSubject(authnAssertionSubject)
.addAuthnStatement(AuthnStatementBuilder.anAuthnStatement()
.withAuthnContext(AuthnContextBuilder.anAuthnContext()
.withAuthnContextClassRef(AuthnContextClassRefBuilder.anAuthnContextClassRef()
.withAuthnContextClasRefValue(IdaAuthnContext.LEVEL_X_AUTHN_CTX)
.build())
.build())
.build());
ResponseBuilder responseBuilder = ResponseBuilder.aResponse().withId(generateId())
.withIssuer(IssuerBuilder.anIssuer().withIssuerId(idpEntityId).build())
.withInResponseTo(requestId)
.addEncryptedAssertion(mdsAssertion
.withSignature(SignatureBuilder.aSignature().withSigningCredential(signingCredential).build())
.buildWithEncrypterCredential(encryptingCredential))
.addEncryptedAssertion(authnAssertion
.withSignature(SignatureBuilder.aSignature().withSigningCredential(signingCredential).build())
.buildWithEncrypterCredential(encryptingCredential));
return responseBuilder;
}
示例9: setup
import uk.gov.ida.saml.core.test.builders.AssertionBuilder; //導入依賴的package包/類
@Before
public void setup() {
IdaSamlBootstrap.bootstrap();
final String idpEntityId = TestEntityIds.STUB_IDP_ONE;
final String assertionId1 = randomUUID().toString();
final String assertionId2 = randomUUID().toString();
final String requestId = randomUUID().toString();
final SignatureAlgorithm signatureAlgorithm = new SignatureRSASHA1();
final DigestAlgorithm digestAlgorithm = new DigestSHA256();
final Subject mdsAssertionSubject = aSubject().withSubjectConfirmation(aSubjectConfirmation().withSubjectConfirmationData(aSubjectConfirmationData().withInResponseTo(requestId).build()).build()).build();
final AttributeStatement matchingDatasetAttributeStatement = MatchingDatasetAttributeStatementBuilder_1_1.aMatchingDatasetAttributeStatement_1_1().build();
final Subject authnAssertionSubject = aSubject().withSubjectConfirmation(aSubjectConfirmation().withSubjectConfirmationData(aSubjectConfirmationData().withInResponseTo(requestId).build()).build()).build();
final AttributeStatement ipAddress = anAttributeStatement().addAttribute(IPAddressAttributeBuilder.anIPAddress().build()).build();
final Optional<Signature> signature = of(SignatureBuilder.aSignature().build());
final SignatureImpl signatureImpl = ((SignatureImpl) signature.get());
signatureImpl.setXMLSignature(BuilderHelper.createXMLSignature(signatureAlgorithm, digestAlgorithm));
authnStatementAssertion = AssertionBuilder.anAssertion()
.withId(assertionId1)
.withIssuer(IssuerBuilder.anIssuer().withIssuerId(idpEntityId).build())
.withSubject(authnAssertionSubject)
.addAttributeStatement(ipAddress)
.addAuthnStatement(AuthnStatementBuilder.anAuthnStatement().build())
.withSignature(SignatureBuilder.aSignature()
.withSignatureAlgorithm(signatureAlgorithm)
.withDigestAlgorithm(assertionId1, digestAlgorithm).build())
.buildUnencrypted();
matchingDatasetAssertion = AssertionBuilder.anAssertion().withId(assertionId2)
.withIssuer(IssuerBuilder.anIssuer().withIssuerId(idpEntityId).build())
.withSubject(mdsAssertionSubject)
.addAttributeStatement(matchingDatasetAttributeStatement)
.withSignature(SignatureBuilder.aSignature()
.withSignatureAlgorithm(signatureAlgorithm)
.withDigestAlgorithm(assertionId2, digestAlgorithm).build())
.buildUnencrypted();
when(responseContainer.getSamlResponse()).thenReturn(saml);
when(stringToOpenSamlResponseTransformer.apply(saml)).thenReturn(samlResponse);
when(samlResponseToIdaResponseIssuedByIdpTransformer.apply(samlResponse)).thenReturn(responseFromIdp);
when(authStatementAssertion.getUnderlyingAssertionBlob()).thenReturn(authStatementUnderlyingAssertionBlob);
when(authStatementAssertion.getAuthnContext()).thenReturn(com.google.common.base.Optional.absent());
when(authStatementAssertion.getFraudDetectedDetails()).thenReturn(com.google.common.base.Optional.absent());
when(authStatementAssertion.getPrincipalIpAddressAsSeenByIdp()).thenReturn(com.google.common.base.Optional.of(principalIpAddressSeenByIdp));
when(authnStatementPersistentId.getNameId()).thenReturn("a name id");
when(authnStatementPersistentId.getNameId()).thenReturn(persistentIdName);
when(authStatementAssertion.getPersistentId()).thenReturn(authnStatementPersistentId);
when(responseFromIdp.getIssuer()).thenReturn(responseIssuer);
when(responseFromIdp.getStatus()).thenReturn(status);
when(responseFromIdp.getMatchingDatasetAssertion()).thenReturn(empty());
when(responseFromIdp.getAuthnStatementAssertion()).thenReturn(empty());
when(responseFromIdp.getSignature()).thenReturn(signature);;
when(samlResponse.getIssuer()).thenReturn(issuer);
when(stringToAssertionTransformer.apply(authStatementUnderlyingAssertionBlob)).thenReturn(authnStatementAssertion);
when(stringToAssertionTransformer.apply(matchingDatasetUnderlyingAssertionBlob)).thenReturn(matchingDatasetAssertion);
InboundResponseFromIdpDataGenerator inboundResponseFromIdpDataGenerator = new InboundResponseFromIdpDataGenerator(assertionBlobEncrypter);
service = new IdpAuthnResponseTranslatorService(
stringToOpenSamlResponseTransformer,
stringToAssertionTransformer,
samlResponseToIdaResponseIssuedByIdpTransformer,
inboundResponseFromIdpDataGenerator,
idpAssertionMetricsCollector);
}
示例10: shouldReturnCurrentAttributesWhenPassedFullMatchingDataset
import uk.gov.ida.saml.core.test.builders.AssertionBuilder; //導入依賴的package包/類
@Test
public void shouldReturnCurrentAttributesWhenPassedFullMatchingDataset() throws Exception {
List<Attribute> requiredAttributes = Stream.of(FIRST_NAME, FIRST_NAME_VERIFIED, MIDDLE_NAME, MIDDLE_NAME_VERIFIED, SURNAME, SURNAME_VERIFIED, CURRENT_ADDRESS, CURRENT_ADDRESS_VERIFIED, ADDRESS_HISTORY, CYCLE_3)
.map(userAccountCreationAttribute -> new AttributeQueryAttributeFactory(new OpenSamlXmlObjectFactory()).createAttribute(userAccountCreationAttribute))
.collect(toList());
AttributeQuery attributeQuery = anAttributeQuery()
.withId(REQUEST_ID)
.withAttributes(requiredAttributes)
.withIssuer(anIssuer().withIssuerId(applicationRule.getConfiguration().getHubEntityId()).build())
.withSubject(aSubjectWithAssertions(asList(
anAuthnStatementAssertion(),
aCompleteMatchingDatasetAssertion(),
AssertionBuilder.aCycle3DatasetAssertion("cycle3Name", "cycle3Value")), REQUEST_ID, HUB_ENTITY_ID))
.build();
Response response = makeAttributeQueryRequest(UNKNOWN_USER_URI, attributeQuery, signatureAlgorithmForHub, digestAlgorithmForHub, HUB_ENTITY_ID);
List<Assertion> decryptedAssertions = assertionDecrypter.decryptAssertions(response::getEncryptedAssertions);
assertThat(response.getStatus().getStatusCode().getValue()).isEqualTo(SUCCESS);
assertThat(response.getStatus().getStatusCode().getStatusCode().getValue()).isEqualTo(CREATED);
OpenSamlXmlObjectFactory openSamlXmlObjectFactory = new OpenSamlXmlObjectFactory();
assertThatResponseContainsExpectedUserCreationAttributes(decryptedAssertions.get(0).getAttributeStatements(), ImmutableList.of(
userAccountCreationAttributeFor(aPersonNameValue().withValue("CurrentSurname").build(), SURNAME),
userAccountCreationAttributeFor(aVerifiedValue().withValue(true).build(), SURNAME_VERIFIED),
userAccountCreationAttributeFor(aPersonNameValue().withValue("FirstName").build(), FIRST_NAME),
userAccountCreationAttributeFor(aVerifiedValue().withValue(false).build(), FIRST_NAME_VERIFIED),
userAccountCreationAttributeFor(anAddressAttributeValue().addLines(ImmutableList.of("address line 1")).withVerified(false).build(), CURRENT_ADDRESS),
userAccountCreationAttributeFor(aVerifiedValue().withValue(false).build(), CURRENT_ADDRESS_VERIFIED),
userAccountCreationAttributeFor(
Arrays.asList(
anAddressAttributeValue().addLines(ImmutableList.of("address line 1")).withVerified(false).build(),
anAddressAttributeValue().addLines(ImmutableList.of("address line 2")).withVerified(true).build()
),
ADDRESS_HISTORY),
userAccountCreationAttributeFor(openSamlXmlObjectFactory.createSimpleMdsAttributeValue("cycle3Value"), CYCLE_3)
));
Assertions.assertThat(response.getInResponseTo()).isEqualTo(REQUEST_ID);
Assertions.assertThat(response.getIssuer().getValue()).isEqualTo(TEST_RP_MS);
assertThat(response).is(signedBy(TEST_RP_MS_PUBLIC_SIGNING_CERT, TEST_RP_MS_PRIVATE_SIGNING_KEY));
}
開發者ID:alphagov,項目名稱:verify-matching-service-adapter,代碼行數:43,代碼來源:UserAccountCreationAppRuleTest.java