• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PublicKeyFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中uk.gov.ida.common.shared.security.PublicKeyFactory的典型用法代码示例。如果您正苦于以下问题:Java PublicKeyFactory类的具体用法?Java PublicKeyFactory怎么用?Java PublicKeyFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PublicKeyFactory类属于uk.gov.ida.common.shared.security包,在下文中一共展示了PublicKeyFactory类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getAttributeQueryToElementTransformer

import uk.gov.ida.common.shared.security.PublicKeyFactory; //导入依赖的package包/类
public static AttributeQueryToElementTransformer getAttributeQueryToElementTransformer(SignatureAlgorithm signatureAlgorithm, DigestAlgorithm digestAlgorithm, String hubEntityId) {
    PublicKeyFactory publicKeyFactory = new PublicKeyFactory(new X509CertificateFactory());
    PrivateKey privateKey = new PrivateKeyFactory().createPrivateKey(Base64.decodeBase64(TestCertificateStrings.PRIVATE_SIGNING_KEYS.get(TestEntityIds.HUB_ENTITY_ID)));
    PublicKey publicKey = publicKeyFactory.createPublicKey(TestCertificateStrings.getPrimaryPublicEncryptionCert(TestEntityIds.HUB_ENTITY_ID));

    PrivateKey privateEncryptionKey = new PrivateKeyFactory().createPrivateKey(Base64.decodeBase64(TestCertificateStrings.HUB_TEST_PRIVATE_ENCRYPTION_KEY));
    PublicKey publicEncryptionKey = publicKeyFactory.createPublicKey(TestCertificateStrings.HUB_TEST_PUBLIC_ENCRYPTION_CERT);

    KeyPair encryptionKeyPair = new KeyPair(publicEncryptionKey, privateEncryptionKey);

    KeyPair signingKeyPair = new KeyPair(publicKey, privateKey);
    IdaKeyStore keyStore = new IdaKeyStore(signingKeyPair, Collections.singletonList(encryptionKeyPair));

    IdaKeyStoreCredentialRetriever privateCredentialFactory = new IdaKeyStoreCredentialRetriever(keyStore);
    return new AttributeQueryToElementTransformer(
            new SigningRequestAbstractTypeSignatureCreator<>(new SignatureFactory(privateCredentialFactory, signatureAlgorithm, digestAlgorithm)),
            new SamlAttributeQueryAssertionSignatureSigner(privateCredentialFactory, new OpenSamlXmlObjectFactory(), hubEntityId),
            new SamlSignatureSigner<>(),
            new XmlObjectToElementTransformer<>(),
            new SamlAttributeQueryAssertionEncrypter(new EncryptionCredentialFactory(new HardCodedKeyStore(hubEntityId)), new EncrypterFactory(), requestId -> TEST_RP_MS)
    );
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:23,代码来源:RequestHelper.java


示例2: setup

import uk.gov.ida.common.shared.security.PublicKeyFactory; //导入依赖的package包/类
@Before
public void setup() throws Exception {
    PublicKeyFactory publicKeyFactory = new PublicKeyFactory(new X509CertificateFactory());
    PrivateKey privateKey = new PrivateKeyFactory().createPrivateKey(Base64.decodeBase64(TestCertificateStrings.PRIVATE_SIGNING_KEYS.get(HUB_ENTITY_ID)));
    PublicKey publicKey = publicKeyFactory.createPublicKey(TestCertificateStrings.getPrimaryPublicEncryptionCert(HUB_ENTITY_ID));

    PrivateKey privateEncryptionKey = new PrivateKeyFactory().createPrivateKey(Base64.decodeBase64(TestCertificateStrings.HUB_TEST_PRIVATE_ENCRYPTION_KEY));
    PublicKey publicEncryptionKey = publicKeyFactory.createPublicKey(TestCertificateStrings.HUB_TEST_PUBLIC_ENCRYPTION_CERT);

    KeyPair encryptionKeyPair = new KeyPair(publicEncryptionKey, privateEncryptionKey);

    KeyPair signingKeyPair = new KeyPair(publicKey, privateKey);
    IdaKeyStore keyStore = new IdaKeyStore(signingKeyPair, Collections.singletonList(encryptionKeyPair));

    assertionDecrypter = new AssertionDecrypter(new IdaKeyStoreCredentialRetriever(
            keyStore),
            new EncryptionAlgorithmValidator(),
            new DecrypterFactory());
    setUpMatchingService();
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:21,代码来源:UserAccountCreationAppRuleTest.java


示例3: createResponse_shouldReturnValidSamlResponse

import uk.gov.ida.common.shared.security.PublicKeyFactory; //导入依赖的package包/类
@Test
public void createResponse_shouldReturnValidSamlResponse() throws Exception {
    PublicKeyFactory publicKeyFactory = new PublicKeyFactory(new X509CertificateFactory());
    PrivateKey privateKey = new PrivateKeyFactory().createPrivateKey(Base64.decodeBase64(TestCertificateStrings.PRIVATE_SIGNING_KEYS.get(TestEntityIds.STUB_IDP_ONE)));
    PublicKey publicKey = publicKeyFactory.createPublicKey(TestCertificateStrings.getPrimaryPublicEncryptionCert(TestEntityIds.HUB_ENTITY_ID));

    PrivateKey privateEncryptionKey = new PrivateKeyFactory().createPrivateKey(Base64.decodeBase64(TestCertificateStrings.HUB_TEST_PRIVATE_ENCRYPTION_KEY));
    PublicKey publicEncryptionKey = publicKeyFactory.createPublicKey(TestCertificateStrings.HUB_TEST_PUBLIC_ENCRYPTION_CERT);

    KeyPair encryptionKeyPair = new KeyPair(publicEncryptionKey, privateEncryptionKey);

    KeyPair signingKeyPair = new KeyPair(publicKey, privateKey);
    IdaKeyStore keyStore = new IdaKeyStore(signingKeyPair, Arrays.asList(encryptionKeyPair));
    ExceptionResponseFactory exceptionResponseFactory = new ExceptionResponseFactory(new OpenSamlXmlObjectFactory(), new IdaKeyStoreCredentialRetriever(keyStore), new IdGenerator());

    String errorMessage = "some message";
    String requestId = UUID.randomUUID().toString();
    Element element = exceptionResponseFactory.createResponse(requestId, TEST_ENTITY_ID, errorMessage);

    Response attributeQueryResponse = (Response) XMLObjectProviderRegistrySupport.getUnmarshallerFactory().getUnmarshaller(element).unmarshall(element);

    assertThat(attributeQueryResponse.getStatus().getStatusCode().getValue()).isEqualTo(StatusCode.REQUESTER);
    assertThat(attributeQueryResponse.getStatus().getStatusMessage().getMessage()).isEqualTo(errorMessage);
    assertThat(attributeQueryResponse.getInResponseTo()).isEqualTo(requestId);
    assertThat(attributeQueryResponse.getIssuer().getValue()).isEqualTo(TEST_ENTITY_ID);
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:27,代码来源:ExceptionResponseFactoryTest.java


示例4: getKeyStore

import uk.gov.ida.common.shared.security.PublicKeyFactory; //导入依赖的package包/类
private static IdaKeyStore getKeyStore() throws Base64DecodingException {
    List<KeyPair> encryptionKeyPairs = new ArrayList<>();
    PublicKeyFactory publicKeyFactory = new PublicKeyFactory(new X509CertificateFactory());
    PrivateKeyFactory privateKeyFactory = new PrivateKeyFactory();
    PublicKey encryptionPublicKey = publicKeyFactory.createPublicKey(HUB_TEST_PUBLIC_ENCRYPTION_CERT);
    PrivateKey encryptionPrivateKey = privateKeyFactory.createPrivateKey(Base64.getDecoder().decode(HUB_TEST_PRIVATE_ENCRYPTION_KEY.getBytes()));
    encryptionKeyPairs.add(new KeyPair(encryptionPublicKey, encryptionPrivateKey));
    PublicKey publicSigningKey = publicKeyFactory.createPublicKey(HUB_TEST_PUBLIC_SIGNING_CERT);
    PrivateKey privateSigningKey = privateKeyFactory.createPrivateKey(Base64.getDecoder().decode(HUB_TEST_PRIVATE_SIGNING_KEY.getBytes()));
    KeyPair signingKeyPair = new KeyPair(publicSigningKey, privateSigningKey);

    return new IdaKeyStore(signingKeyPair, encryptionKeyPairs);
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:14,代码来源:SamlMessageSenderApiResourceTest.java


示例5: aValidMatchResponseFromMatchingService

import uk.gov.ida.common.shared.security.PublicKeyFactory; //导入依赖的package包/类
private String aValidMatchResponseFromMatchingService(final String requestId, final Status status, DateTime notOnOrAfter) throws MarshallingException, SignatureException {
    Credential signingCredential = new TestCredentialFactory(TEST_RP_MS_PUBLIC_SIGNING_CERT, TEST_RP_MS_PRIVATE_SIGNING_KEY).getSigningCredential();
    return XmlUtils.writeToString(aResponse()
            .withStatus(status)
            .withInResponseTo(requestId)
            .withIssuer(anIssuer().withIssuerId(TEST_RP_MS).build())
            .withSigningCredential(signingCredential)
            .addEncryptedAssertion(
                    anAssertion()
                            .withSubject(
                                    aSubject()
                                            .withSubjectConfirmation(
                                                    aSubjectConfirmation()
                                                            .withSubjectConfirmationData(
                                                                    aSubjectConfirmationData()
                                                                            .withInResponseTo(requestId)
                                                                            .withNotOnOrAfter(
                                                                                    notOnOrAfter
                                                                            )
                                                                            .build()
                                                            )
                                                            .build()
                                            )
                                            .build()
                            )
                            .withIssuer(anIssuer().withIssuerId(TEST_RP_MS).build())
                            .withSignature(aSignature().withSigningCredential(signingCredential).build())
                            .addAuthnStatement(anAuthnStatement().build())
                            .buildWithEncrypterCredential(new EncryptionCredentialFactory(entityId -> {
                                PublicKeyFactory keyFactory = new PublicKeyFactory(new X509CertificateFactory());
                                return keyFactory.createPublicKey(HUB_TEST_PUBLIC_ENCRYPTION_CERT);
                            }).getEncryptingCredential(HUB_ENTITY_ID))
            ).build().getDOM());
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:35,代码来源:MatchingServiceHealthcheckResponseTranslatorResourceTest.java


示例6: aValidMatchResponseFromMatchingService

import uk.gov.ida.common.shared.security.PublicKeyFactory; //导入依赖的package包/类
private String aValidMatchResponseFromMatchingService(final String requestId, final Status status, DateTime notOnOrAfter) throws MarshallingException, SignatureException {
    return XmlUtils.writeToString(aResponse()
            .withStatus(status)
            .withInResponseTo(requestId)
            .withIssuer(anIssuer().withIssuerId(TEST_RP_MS).build())
            .withSigningCredential(msaSigningCredential)
            .addEncryptedAssertion(
                    anAssertion()
                            .withSubject(
                                    aSubject()
                                            .withSubjectConfirmation(
                                                    aSubjectConfirmation()
                                                            .withSubjectConfirmationData(
                                                                    aSubjectConfirmationData()
                                                                            .withInResponseTo(requestId)
                                                                            .withNotOnOrAfter(
                                                                                    notOnOrAfter
                                                                            )
                                                                            .build()
                                                            )
                                                            .build()
                                            )
                                            .build()
                            )
                            .withIssuer(anIssuer().withIssuerId(TEST_RP_MS).build())
                            .withSignature(
                                    aSignature().withSigningCredential(msaSigningCredential).build()
                            )
                            .addAuthnStatement(anAuthnStatement().build())
                            .buildWithEncrypterCredential(new EncryptionCredentialFactory(entityId -> {
                                PublicKeyFactory keyFactory = new PublicKeyFactory(new X509CertificateFactory());
                                return keyFactory.createPublicKey(HUB_TEST_PUBLIC_ENCRYPTION_CERT);
                            }).getEncryptingCredential(HUB_ENTITY_ID))
            ).build().getDOM());
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:36,代码来源:MatchingServiceResponseTranslatorResourceTest.java


示例7: aValidMatchResponseFromMatchingServiceWithMissingData

import uk.gov.ida.common.shared.security.PublicKeyFactory; //导入依赖的package包/类
private String aValidMatchResponseFromMatchingServiceWithMissingData(final String requestId, final Status status, String msaEntityId) throws MarshallingException, SignatureException {
    return XmlUtils.writeToString(aResponse()
            .withStatus(status)
            .withInResponseTo(requestId)
            .withIssuer(anIssuer().withIssuerId(msaEntityId).build())
            .withSigningCredential(msaSigningCredential)
            .addEncryptedAssertion(
                    anAssertion()
                            .withSubject(
                                    aSubject()
                                            .withSubjectConfirmation(
                                                    aSubjectConfirmation()
                                                            .withSubjectConfirmationData(
                                                                    aSubjectConfirmationData()
                                                                            .withInResponseTo(requestId)
                                                                            .withNotOnOrAfter(
                                                                                    DateTime.now()
                                                                                            .plusDays(5)
                                                                            )
                                                                            .build()
                                                            )
                                                            .build()
                                            )
                                            .build()
                            )
                            .withIssuer(anIssuer().withIssuerId(msaEntityId).build())
                            .withSignature(
                                    aSignature().withSigningCredential(msaSigningCredential).build()
                            )
                            .buildWithEncrypterCredential(new EncryptionCredentialFactory(entityId -> {
                                PublicKeyFactory keyFactory = new PublicKeyFactory(new X509CertificateFactory());
                                return keyFactory.createPublicKey(HUB_TEST_PUBLIC_ENCRYPTION_CERT);
                            }).getEncryptingCredential(HUB_ENTITY_ID))
            ).build().getDOM());
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:36,代码来源:MatchingServiceResponseTranslatorResourceTest.java


示例8: getKeyStore

import uk.gov.ida.common.shared.security.PublicKeyFactory; //导入依赖的package包/类
private IdaKeyStore getKeyStore() throws Base64DecodingException {
    List<KeyPair> encryptionKeyPairs = new ArrayList<>();
    PublicKeyFactory publicKeyFactory = new PublicKeyFactory(new X509CertificateFactory());
    PrivateKeyFactory privateKeyFactory = new PrivateKeyFactory();
    PublicKey encryptionPublicKey = publicKeyFactory.createPublicKey(HUB_TEST_PUBLIC_ENCRYPTION_CERT);
    PrivateKey encryptionPrivateKey = privateKeyFactory.createPrivateKey(Base64.getDecoder().decode(HUB_TEST_PRIVATE_ENCRYPTION_KEY.getBytes()));
    encryptionKeyPairs.add(new KeyPair(encryptionPublicKey, encryptionPrivateKey));
    PublicKey publicSigningKey = publicKeyFactory.createPublicKey(HUB_TEST_PUBLIC_SIGNING_CERT);
    PrivateKey privateSigningKey = privateKeyFactory.createPrivateKey(Base64.getDecoder().decode(HUB_TEST_PRIVATE_SIGNING_KEY.getBytes()));
    KeyPair signingKeyPair = new KeyPair(publicSigningKey, privateSigningKey);

    return new IdaKeyStore(signingKeyPair, encryptionKeyPairs);
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:14,代码来源:MatchingServiceHealthCheckIntegrationTests.java


示例9: MetadataPublicKeyStore

import uk.gov.ida.common.shared.security.PublicKeyFactory; //导入依赖的package包/类
@Inject
public MetadataPublicKeyStore(
        MetadataCertificatesRepository metadataRepository,
        PublicKeyFactory publicKeyFactory,
        @Named("HubEntityId") String hubEntityId) {
    this.metadataRepository = metadataRepository;
    this.publicKeyFactory = publicKeyFactory;
    this.hubEntityId = hubEntityId;
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:10,代码来源:MetadataPublicKeyStore.java


示例10: AssertionDecrypter

import uk.gov.ida.common.shared.security.PublicKeyFactory; //导入依赖的package包/类
public AssertionDecrypter(String privateKey, String publicKey) {
    this.privateKey = new PrivateKeyFactory().createPrivateKey(Base64.decodeBase64(privateKey));
    this.publicKey = new PublicKeyFactory(new X509CertificateFactory()).createPublicKey(publicKey);
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:5,代码来源:AssertionDecrypter.java


示例11: createBasicCredential

import uk.gov.ida.common.shared.security.PublicKeyFactory; //导入依赖的package包/类
private BasicCredential createBasicCredential() {
    final PublicKey publicKey = new PublicKeyFactory(new X509CertificateFactory()).createPublicKey(HUB_TEST_PUBLIC_ENCRYPTION_CERT);
    PrivateKey privateKey = new PrivateKeyFactory().createPrivateKey(Base64.decodeBase64(HUB_TEST_PRIVATE_ENCRYPTION_KEY));
    return new BasicCredential(publicKey, privateKey);
}
 
开发者ID:alphagov,项目名称:verify-service-provider,代码行数:6,代码来源:AuthnRequestFactoryTest.java


示例12: getPublicKeyFactory

import uk.gov.ida.common.shared.security.PublicKeyFactory; //导入依赖的package包/类
@Provides
@Singleton
public PublicKeyFactory getPublicKeyFactory(X509CertificateFactory x509CertificateFactory) {
    return new PublicKeyFactory(x509CertificateFactory);
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:6,代码来源:MatchingServiceAdapterModule.java



注:本文中的uk.gov.ida.common.shared.security.PublicKeyFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ValidationResults类代码示例发布时间:2022-05-16
下一篇:
Java ConsumerKey类代码示例发布时间:2022-05-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap