本文整理汇总了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)
);
}
示例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);
}
示例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);
}
示例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());
}
示例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());
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例12: getPublicKeyFactory
import uk.gov.ida.common.shared.security.PublicKeyFactory; //导入依赖的package包/类
@Provides
@Singleton
public PublicKeyFactory getPublicKeyFactory(X509CertificateFactory x509CertificateFactory) {
return new PublicKeyFactory(x509CertificateFactory);
}