本文整理汇总了Java中org.opensaml.security.credential.BasicCredential类的典型用法代码示例。如果您正苦于以下问题:Java BasicCredential类的具体用法?Java BasicCredential怎么用?Java BasicCredential使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BasicCredential类属于org.opensaml.security.credential包,在下文中一共展示了BasicCredential类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: buildCredentialForMetadataSignatureValidation
import org.opensaml.security.credential.BasicCredential; //导入依赖的package包/类
/**
* Build credential for metadata signature validation basic credential.
*
* @param resource the resource
* @return the basic credential
* @throws Exception the exception
*/
public static BasicCredential buildCredentialForMetadataSignatureValidation(final Resource resource) throws Exception {
try {
final BasicX509CredentialFactoryBean x509FactoryBean = new BasicX509CredentialFactoryBean();
x509FactoryBean.setCertificateResource(resource);
x509FactoryBean.afterPropertiesSet();
return x509FactoryBean.getObject();
} catch (final Exception e) {
LOGGER.trace(e.getMessage(), e);
LOGGER.debug("Credential cannot be extracted from [{}] via X.509. Treating it as a public key to locate credential...",
resource);
final BasicResourceCredentialFactoryBean credentialFactoryBean = new BasicResourceCredentialFactoryBean();
credentialFactoryBean.setPublicKeyInfo(resource);
credentialFactoryBean.afterPropertiesSet();
return credentialFactoryBean.getObject();
}
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:25,代码来源:SamlUtils.java
示例2: setUp
import org.opensaml.security.credential.BasicCredential; //导入依赖的package包/类
@Before
public void setUp() {
IdaSamlBootstrap.bootstrap();
reset(manifestReader);
final BasicCredential basicCredential = createBasicCredential();
encrypter = new uk.gov.ida.saml.security.EncrypterFactory().createEncrypter(basicCredential);
decrypter = new DecrypterFactory().createDecrypter(ImmutableList.of(basicCredential));
when(encrypterFactory.createEncrypter()).thenReturn(encrypter);
factory = new AuthnRequestFactory(
DESTINATION,
new PrivateKeyStoreFactory().create(TestEntityIds.TEST_RP).getSigningPrivateKey(),
manifestReader,
encrypterFactory
);
}
开发者ID:alphagov,项目名称:verify-service-provider,代码行数:17,代码来源:AuthnRequestFactoryTest.java
示例3: buildSignatureValidationFilter
import org.opensaml.security.credential.BasicCredential; //导入依赖的package包/类
/**
* Build signature validation filter if needed.
*
* @param signatureResourceLocation the signature resource location
* @return the metadata filter
* @throws Exception the exception
*/
public static SignatureValidationFilter buildSignatureValidationFilter(final Resource signatureResourceLocation) throws Exception {
if (!ResourceUtils.doesResourceExist(signatureResourceLocation)) {
LOGGER.warn("Resource [{}] cannot be located", signatureResourceLocation);
return null;
}
final List<KeyInfoProvider> keyInfoProviderList = new ArrayList<>();
keyInfoProviderList.add(new RSAKeyValueProvider());
keyInfoProviderList.add(new DSAKeyValueProvider());
keyInfoProviderList.add(new DEREncodedKeyValueProvider());
keyInfoProviderList.add(new InlineX509DataProvider());
LOGGER.debug("Attempting to resolve credentials from [{}]", signatureResourceLocation);
final BasicCredential credential = buildCredentialForMetadataSignatureValidation(signatureResourceLocation);
LOGGER.info("Successfully resolved credentials from [{}]", signatureResourceLocation);
LOGGER.debug("Configuring credential resolver for key signature trust engine @ [{}]", credential.getCredentialType().getSimpleName());
final StaticCredentialResolver resolver = new StaticCredentialResolver(credential);
final BasicProviderKeyInfoCredentialResolver keyInfoResolver = new BasicProviderKeyInfoCredentialResolver(keyInfoProviderList);
final ExplicitKeySignatureTrustEngine trustEngine = new ExplicitKeySignatureTrustEngine(resolver, keyInfoResolver);
LOGGER.debug("Adding signature validation filter based on the configured trust engine");
final SignatureValidationFilter signatureValidationFilter = new SignatureValidationFilter(trustEngine);
signatureValidationFilter.setRequireSignedRoot(false);
LOGGER.debug("Added metadata SignatureValidationFilter with signature from [{}]", signatureResourceLocation);
return signatureValidationFilter;
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:35,代码来源:SamlUtils.java
示例4: decrypt
import org.opensaml.security.credential.BasicCredential; //导入依赖的package包/类
private Assertion decrypt(EncryptedAssertion encryptedAssertion) {
Decrypter decrypter = new DecrypterFactory().createDecrypter(ImmutableList.of(new BasicCredential(publicKey, privateKey)));
decrypter.setRootInNewDocument(true);
try {
return decrypter.decrypt(encryptedAssertion);
} catch (DecryptionException e) {
throw new RuntimeException(e);
}
}
开发者ID:alphagov,项目名称:verify-hub,代码行数:10,代码来源:AssertionDecrypter.java
示例5: handleResponseFromIdp_shouldNotDecryptAssertionEncryptedWithIncorrectEncryptionCertificates
import org.opensaml.security.credential.BasicCredential; //导入依赖的package包/类
@Test
public void handleResponseFromIdp_shouldNotDecryptAssertionEncryptedWithIncorrectEncryptionCertificates() throws Exception {
BasicCredential incorrectEncryptionKey = new BasicCredential(new HardCodedKeyStore(HUB_ENTITY_ID).getPrimaryEncryptionKeyForEntity(TEST_RP));
SamlAuthnResponseTranslatorDto samlResponseDto = getSuccessSamlAuthnResponseTranslatorDto(incorrectEncryptionKey);
Response clientResponse = postToSamlEngine(samlResponseDto);
assertThat(clientResponse.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
ErrorStatusDto errorStatusDto = clientResponse.readEntity(ErrorStatusDto.class);
assertThat(errorStatusDto.getExceptionType()).isEqualTo(ExceptionType.INVALID_SAML_FAILED_TO_DECRYPT);
}
开发者ID:alphagov,项目名称:verify-hub,代码行数:13,代码来源:IdpAuthnResponseTranslatorResourceTest.java
示例6: aResponseFromIdpBuilder
import org.opensaml.security.credential.BasicCredential; //导入依赖的package包/类
public ResponseBuilder aResponseFromIdpBuilder(String idpEntityId,
String ipAddressSeenByIdp,
DateTime issueInstant,
String authnStatementAssertionId,
String mdsStatementAssertionId,
Optional<BasicCredential> basicCredential) throws Exception {
String subjectPersistentIdentifier = generateId();
return aResponseFromIdpBuilder(idpEntityId, ipAddressSeenByIdp, issueInstant, authnStatementAssertionId, subjectPersistentIdentifier, mdsStatementAssertionId, subjectPersistentIdentifier, basicCredential);
}
开发者ID:alphagov,项目名称:verify-hub,代码行数:10,代码来源:AuthnResponseFactory.java
示例7: getSimpleCredential
import org.opensaml.security.credential.BasicCredential; //导入依赖的package包/类
/**
* Get a simple, minimal credential containing a secret (symmetric) key.
*
* @param secretKey the symmetric key to wrap
* @return a credential containing the secret key specified
*/
private static BasicCredential getSimpleCredential(SecretKey secretKey) {
if (secretKey == null) {
throw new IllegalArgumentException("A secret key is required");
}
return new BasicCredential(secretKey);
}
开发者ID:wso2-extensions,项目名称:tomcat-extension-samlsso,代码行数:13,代码来源:SSOUtils.java
示例8: getSuccessSamlAuthnResponseTranslatorDto
import org.opensaml.security.credential.BasicCredential; //导入依赖的package包/类
private SamlAuthnResponseTranslatorDto getSuccessSamlAuthnResponseTranslatorDto(BasicCredential basicCredential) throws Exception {
return getSuccessSamlAuthnResponseTranslatorDto(basicCredential, TEST_RP_MS);
}
开发者ID:alphagov,项目名称:verify-hub,代码行数:4,代码来源:IdpAuthnResponseTranslatorResourceTest.java
示例9: aResponseFromIdpBuilderWithIssuers
import org.opensaml.security.credential.BasicCredential; //导入依赖的package包/类
public ResponseBuilder aResponseFromIdpBuilderWithIssuers(String idpEntityId, String authnAssertionIssuer, String mdsAssertionIssuer) throws Exception {
String subjectPersistentIdentifier = generateId();
return aResponseFromIdpBuilder(idpEntityId, "ipAddressSeenByIdp", DateTime.now(), UUID.randomUUID().toString(), subjectPersistentIdentifier, authnAssertionIssuer, UUID.randomUUID().toString(), subjectPersistentIdentifier, mdsAssertionIssuer, Optional.<BasicCredential>absent());
}
开发者ID:alphagov,项目名称:verify-hub,代码行数:5,代码来源:AuthnResponseFactory.java
示例10: aResponseFromIdpBuilderWithInResponseToValues
import org.opensaml.security.credential.BasicCredential; //导入依赖的package包/类
public ResponseBuilder aResponseFromIdpBuilderWithInResponseToValues(String idpEntityId, String requestId, String authnAssertionInResponseTo, String mdsAssertionInResponseTo) throws Exception {
String subjectPersistentIdentifier = generateId();
return aResponseFromIdpBuilder(idpEntityId, "ipAddressSeenByIdp", requestId, DateTime.now(), UUID.randomUUID().toString(), subjectPersistentIdentifier, idpEntityId, authnAssertionInResponseTo, UUID.randomUUID().toString(), subjectPersistentIdentifier, idpEntityId, mdsAssertionInResponseTo, Optional.<BasicCredential>absent());
}
开发者ID:alphagov,项目名称:verify-hub,代码行数:5,代码来源:AuthnResponseFactory.java
示例11: createEncrypter
import org.opensaml.security.credential.BasicCredential; //导入依赖的package包/类
public Encrypter createEncrypter() {
BasicCredential credential = new BasicCredential(metadataPublicKeyExtractor.getEncryptionPublicKey());
return super.createEncrypter(credential);
}
开发者ID:alphagov,项目名称:verify-service-provider,代码行数:5,代码来源:EncrypterFactory.java
示例12: createBasicCredential
import org.opensaml.security.credential.BasicCredential; //导入依赖的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
示例13: handleResponseFromIdp_shouldDecryptAssertionEncryptedWithPrimaryEncryptionCertificates
import org.opensaml.security.credential.BasicCredential; //导入依赖的package包/类
@Test
public void handleResponseFromIdp_shouldDecryptAssertionEncryptedWithPrimaryEncryptionCertificates() throws Exception {
BasicCredential primaryEncryptionKey = new BasicCredential(new HardCodedKeyStore(HUB_ENTITY_ID).getPrimaryEncryptionKeyForEntity(HUB_ENTITY_ID));
SamlAuthnResponseTranslatorDto samlResponseDto = getSuccessSamlAuthnResponseTranslatorDto(primaryEncryptionKey);
Response clientResponse = postToSamlEngine(samlResponseDto);
assertThat(clientResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
}
开发者ID:alphagov,项目名称:verify-hub,代码行数:11,代码来源:IdpAuthnResponseTranslatorResourceTest.java
示例14: handleResponseFromIdp_shouldDecryptAssertionEncryptedWithSecondaryEncryptionCertificates
import org.opensaml.security.credential.BasicCredential; //导入依赖的package包/类
@Test
public void handleResponseFromIdp_shouldDecryptAssertionEncryptedWithSecondaryEncryptionCertificates() throws Exception {
BasicCredential secondaryEncryptionKey = new BasicCredential(new HardCodedKeyStore(HUB_ENTITY_ID).getSecondaryEncryptionKeyForEntity(HUB_ENTITY_ID));
SamlAuthnResponseTranslatorDto samlResponseDto = getSuccessSamlAuthnResponseTranslatorDto(secondaryEncryptionKey);
Response clientResponse = postToSamlEngine(samlResponseDto);
assertThat(clientResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
}
开发者ID:alphagov,项目名称:verify-hub,代码行数:11,代码来源:IdpAuthnResponseTranslatorResourceTest.java
示例15: shouldEncryptTheMatchingDatasetAssertionWhenGivenMatchingServiceEntityId
import org.opensaml.security.credential.BasicCredential; //导入依赖的package包/类
@Test
public void shouldEncryptTheMatchingDatasetAssertionWhenGivenMatchingServiceEntityId() throws Exception {
BasicCredential primaryEncryptionKey = new BasicCredential(new HardCodedKeyStore(HUB_ENTITY_ID).getPrimaryEncryptionKeyForEntity(HUB_ENTITY_ID));
SamlAuthnResponseTranslatorDto samlResponseDto = getSuccessSamlAuthnResponseTranslatorDto(primaryEncryptionKey);
Response clientResponse = postToSamlEngine(samlResponseDto);
assertThat(clientResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
InboundResponseFromIdpDto inboundResponseFromIdpDto = clientResponse.readEntity(InboundResponseFromIdpDto.class);
assertThat(inboundResponseFromIdpDto.getEncryptedMatchingDatasetAssertion().isPresent()).isTrue();
}
开发者ID:alphagov,项目名称:verify-hub,代码行数:14,代码来源:IdpAuthnResponseTranslatorResourceTest.java
注:本文中的org.opensaml.security.credential.BasicCredential类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论