本文整理汇总了Java中org.opensaml.xmlsec.algorithm.descriptors.DigestSHA256类的典型用法代码示例。如果您正苦于以下问题:Java DigestSHA256类的具体用法?Java DigestSHA256怎么用?Java DigestSHA256使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DigestSHA256类属于org.opensaml.xmlsec.algorithm.descriptors包,在下文中一共展示了DigestSHA256类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
import org.opensaml.xmlsec.algorithm.descriptors.DigestSHA256; //导入依赖的package包/类
@Override
protected void configure() {
bind(EncryptionKeyStore.class).to(HubEncryptionKeyStore.class).asEagerSingleton();
bind(SigningKeyStore.class).annotatedWith(Names.named("authnRequestKeyStore")).to(AuthnRequestKeyStore.class).asEagerSingleton();
bind(SigningKeyStore.class).annotatedWith(Names.named("samlResponseFromMatchingServiceKeyStore")).to(SamlResponseFromMatchingServiceKeyStore.class).asEagerSingleton();
bind(X509CertificateFactory.class).toInstance(new X509CertificateFactory());
bind(CertificateChainValidator.class);
bind(PKIXParametersProvider.class).toInstance(new PKIXParametersProvider());
bind(CertificatesConfigProxy.class);
bind(TrustStoreForCertificateProvider.class);
bind(EncryptionCredentialFactory.class);
bind(KeyStoreCache.class);
bind(KeyStoreLoader.class).toInstance(new KeyStoreLoader());
bind(SignatureFactory.class);
bind(IdaKeyStoreCredentialRetriever.class);
bind(SamlResponseAssertionEncrypter.class);
bind(AssertionBlobEncrypter.class);
bind(EncrypterFactory.class).toInstance(new EncrypterFactory());
bind(SignatureAlgorithm.class).toInstance(new SignatureRSASHA1());
bind(DigestAlgorithm.class).toInstance(new DigestSHA256());
}
示例2: getResponseToElementTransformer
import org.opensaml.xmlsec.algorithm.descriptors.DigestSHA256; //导入依赖的package包/类
public ResponseToElementTransformer getResponseToElementTransformer(
EncryptionKeyStore encryptionKeyStore,
IdaKeyStore keyStore,
EntityToEncryptForLocator entityToEnryptForLocator,
MatchingServiceAdapterConfiguration configuration
) {
SignatureFactory signatureFactory = new SignatureFactory(
new IdaKeyStoreCredentialRetriever(keyStore),
new SignatureRSASHA1(),
new DigestSHA256()
);
SamlResponseAssertionEncrypter assertionEncrypter = new SamlResponseAssertionEncrypter(
new EncryptionCredentialFactory(encryptionKeyStore),
new EncrypterFactory(),
entityToEnryptForLocator);
return new ResponseToElementTransformer(
new XmlObjectToElementTransformer<>(),
new SamlSignatureSigner<>(),
assertionEncrypter,
new ResponseAssertionSigner(signatureFactory),
new ResponseSignatureCreator(signatureFactory)
);
}
示例3: createSignature
import org.opensaml.xmlsec.algorithm.descriptors.DigestSHA256; //导入依赖的package包/类
private Signature createSignature() {
KeyPair signingKeyPair = new KeyPair(publicKeyFromPrivateKey(signingKey), signingKey);
IdaKeyStore keyStore = new IdaKeyStore(signingKeyPair, Collections.emptyList());
IdaKeyStoreCredentialRetriever keyStoreCredentialRetriever = new IdaKeyStoreCredentialRetriever(keyStore);
SignatureRSASHA256 signatureAlgorithm = new SignatureRSASHA256();
DigestSHA256 digestAlgorithm = new DigestSHA256();
SignatureFactory signatureFactory = new SignatureFactory(keyStoreCredentialRetriever, signatureAlgorithm, digestAlgorithm);
return signatureFactory.createSignature();
}
示例4: setup
import org.opensaml.xmlsec.algorithm.descriptors.DigestSHA256; //导入依赖的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);
}
示例5: shouldTranslateSamlAuthnRequest
import org.opensaml.xmlsec.algorithm.descriptors.DigestSHA256; //导入依赖的package包/类
@Test
public void shouldTranslateSamlAuthnRequest() throws Exception {
RpAuthnRequestTranslatorService service = new RpAuthnRequestTranslatorService(stringToAuthnRequestTransformer, samlAuthnRequestToAuthnRequestFromRelyingPartyTransformer);
boolean forceAuthentication = true;
String id = UUID.randomUUID().toString();
String issuer = UUID.randomUUID().toString();
URI assertionConsumerServiceUrl = URI.create("http://someassertionuri");
int assertionConsumerServiceIndex = 1;
Signature signature = aSignature().withSignatureAlgorithm(SIGNATURE_ALGORITHM).build();
((SignatureImpl) signature).setXMLSignature(BuilderHelper.createXMLSignature(SIGNATURE_ALGORITHM, new DigestSHA256()));
SamlRequestWithAuthnRequestInformationDto samlRequestWithAuthnRequestInformationDto = SamlAuthnRequestDtoBuilder.aSamlAuthnRequest()
.withId(id)
.withIssuer(issuer)
.withForceAuthentication(forceAuthentication)
.withAssertionConsumerIndex(assertionConsumerServiceIndex)
.withPublicCert(TEST_RP_PUBLIC_SIGNING_CERT)
.withPrivateKey(TEST_RP_PRIVATE_SIGNING_KEY)
.build();
AuthnRequest authnRequest = AuthnRequestBuilder.anAuthnRequest().build();
TranslatedAuthnRequestDto expected = TranslatedAuthnRequestDtoBuilder.aTranslatedAuthnRequest()
.withId(id)
.withIssuer(issuer)
.withForceAuthentication(forceAuthentication)
.withAssertionConsumerServiceUrl(assertionConsumerServiceUrl)
.withAssertionConsumerServiceIndex(assertionConsumerServiceIndex)
.build();
AuthnRequestFromRelyingParty intermediateBlah = anAuthnRequestFromRelyingParty()
.withId(id)
.withIssuer(issuer)
.withForceAuthentication(forceAuthentication)
.withAssertionConsumerServiceUrl(assertionConsumerServiceUrl)
.withAssertionConsumerServiceIndex(assertionConsumerServiceIndex)
.withSignature(signature)
.build();
stub(stringToAuthnRequestTransformer.apply(samlRequestWithAuthnRequestInformationDto.getSamlMessage())).toReturn(authnRequest);
stub(samlAuthnRequestToAuthnRequestFromRelyingPartyTransformer.apply(authnRequest)).toReturn(intermediateBlah);
TranslatedAuthnRequestDto actual = service.translate(samlRequestWithAuthnRequestInformationDto);
assertThat(actual).isEqualToComparingFieldByField(expected);
}