当前位置: 首页>>代码示例>>Java>>正文


Java Configuration.getGlobalSecurityConfiguration方法代码示例

本文整理汇总了Java中org.opensaml.Configuration.getGlobalSecurityConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Java Configuration.getGlobalSecurityConfiguration方法的具体用法?Java Configuration.getGlobalSecurityConfiguration怎么用?Java Configuration.getGlobalSecurityConfiguration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.opensaml.Configuration的用法示例。


在下文中一共展示了Configuration.getGlobalSecurityConfiguration方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: postProcessBeanFactory

import org.opensaml.Configuration; //导入方法依赖的package包/类
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    super.postProcessBeanFactory(beanFactory);
    BasicSecurityConfiguration config = (BasicSecurityConfiguration) Configuration.getGlobalSecurityConfiguration();
    config.registerSignatureAlgorithmURI(signatureAlgorithmName, signatureAlgorithmURI);
    config.setSignatureReferenceDigestMethod(digestAlgorithmURI);
}
 
开发者ID:choonchernlim,项目名称:spring-security-adfs-saml2,代码行数:8,代码来源:DefaultSAMLBootstrap.java

示例2: setUp

import org.opensaml.Configuration; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void setUp() throws Exception {
    super.setUp();
    idpRSAPubKey = SecurityTestHelper.buildJavaRSAPublicKey(idpRSAPubKeyBase64);
    idpDSACert = SecurityTestHelper.buildJavaX509Cert(idpDSACertBase64);
    idpRSACert = SecurityTestHelper.buildJavaX509Cert(idpRSACertBase64);
    keyAuthorityCert = SecurityTestHelper.buildJavaX509Cert(keyAuthorityCertBase64);
    
    Document mdDoc = parser.parse(MetadataCredentialResolverTest.class.getResourceAsStream(mdFileName));
    
    mdProvider = new DOMMetadataProvider(mdDoc.getDocumentElement());
    mdProvider.initialize();
    
    //For testing, use default KeyInfo resolver from global security config, per metadata resolver constructor
    origGlobalSecurityConfig = Configuration.getGlobalSecurityConfiguration();
    BasicSecurityConfiguration newSecConfig = new BasicSecurityConfiguration();
    newSecConfig.setDefaultKeyInfoCredentialResolver( SecurityTestHelper.buildBasicInlineKeyInfoResolver() );
    Configuration.setGlobalSecurityConfiguration(newSecConfig);
    
    mdResolver = new MetadataCredentialResolver(mdProvider);
    
    entityCriteria = new EntityIDCriteria(idpEntityID);
    // by default set protocol to null
    mdCriteria = new MetadataCriteria(idpRole, null);
    
    criteriaSet = new CriteriaSet();
    criteriaSet.add(entityCriteria);
    criteriaSet.add(mdCriteria);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:30,代码来源:MetadataCredentialResolverTest.java

示例3: generateSAMLAssertion

import org.opensaml.Configuration; //导入方法依赖的package包/类
public static Element generateSAMLAssertion(PrivateKey privateKey, X509Certificate certificate, String issuerName,
		String subjectName, byte[] document)
		throws MarshallingException, SecurityException, SignatureException, NoSuchAlgorithmException {
	Assertion assertion = buildXMLObject(Assertion.class, Assertion.DEFAULT_ELEMENT_NAME);
	assertion.setVersion(SAMLVersion.VERSION_20);
	String assertionId = "assertion-" + UUID.randomUUID().toString();
	assertion.setID(assertionId);
	DateTime issueInstant = new DateTime();
	assertion.setIssueInstant(issueInstant);

	Issuer issuer = buildXMLObject(Issuer.class, Issuer.DEFAULT_ELEMENT_NAME);
	assertion.setIssuer(issuer);
	issuer.setValue(issuerName);

	Subject subject = buildXMLObject(Subject.class, Subject.DEFAULT_ELEMENT_NAME);
	assertion.setSubject(subject);
	NameID subjectNameId = buildXMLObject(NameID.class, NameID.DEFAULT_ELEMENT_NAME);
	subject.setNameID(subjectNameId);
	subjectNameId.setValue(subjectName);
	SubjectConfirmation subjectConfirmation = buildXMLObject(SubjectConfirmation.class,
			SubjectConfirmation.DEFAULT_ELEMENT_NAME);
	subject.getSubjectConfirmations().add(subjectConfirmation);
	subjectConfirmation.setMethod(SubjectConfirmation.METHOD_BEARER);

	if (null != document) {
		MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
		messageDigest.update(document);
		byte[] documentDigest = messageDigest.digest();
		String encodedDocumentDigest = new String(Hex.encodeHex(documentDigest));
		String resourceUri = DigitalSignatureServiceConstants.DOCUMENT_AUTHORIZATION_RESOURCE_SHA256_URI
				+ encodedDocumentDigest;

		AuthzDecisionStatement authzDecisionStatement = buildXMLObject(AuthzDecisionStatement.class,
				AuthzDecisionStatement.DEFAULT_ELEMENT_NAME);
		assertion.getAuthzDecisionStatements().add(authzDecisionStatement);
		authzDecisionStatement.setDecision(DecisionTypeEnumeration.PERMIT);
		authzDecisionStatement.setResource(resourceUri);
		Action action = buildXMLObject(Action.class, Action.DEFAULT_ELEMENT_NAME);
		action.setNamespace(DigitalSignatureServiceConstants.DOCUMENT_AUTHORIZATION_ACTION_NAMESPACE);
		action.setAction(DigitalSignatureServiceConstants.DOCUMENT_AUTHORIZATION_ACTION_ACTION_SIGN);
		authzDecisionStatement.getActions().add(action);
	}

	BasicX509Credential credential = new BasicX509Credential();
	credential.setPrivateKey(privateKey);
	credential.setEntityCertificate(certificate);

	Signature signature = (Signature) Configuration.getBuilderFactory().getBuilder(Signature.DEFAULT_ELEMENT_NAME)
			.buildObject(Signature.DEFAULT_ELEMENT_NAME);
	signature.setSigningCredential(credential);
	SecurityConfiguration secConfig = Configuration.getGlobalSecurityConfiguration();
	SecurityHelper.prepareSignatureParams(signature, credential, secConfig, null);

	assertion.setSignature(signature);

	Element element = Configuration.getMarshallerFactory().getMarshaller(assertion).marshall(assertion);

	Signer.signObject(signature);

	return element;
}
 
开发者ID:e-Contract,项目名称:dssp,代码行数:62,代码来源:TestUtils.java

示例4: generateHOKSAMLAssertion

import org.opensaml.Configuration; //导入方法依赖的package包/类
public static Element generateHOKSAMLAssertion(PrivateKey issuerPrivateKey, X509Certificate issuerCertificate,
		String issuerName, String subjectName, PublicKey hokPublicKey)
		throws MarshallingException, SecurityException, SignatureException {
	Assertion assertion = buildXMLObject(Assertion.class, Assertion.DEFAULT_ELEMENT_NAME);
	assertion.setVersion(SAMLVersion.VERSION_20);
	String assertionId = "assertion-" + UUID.randomUUID().toString();
	assertion.setID(assertionId);
	DateTime issueInstant = new DateTime();
	assertion.setIssueInstant(issueInstant);

	Issuer issuer = buildXMLObject(Issuer.class, Issuer.DEFAULT_ELEMENT_NAME);
	assertion.setIssuer(issuer);
	issuer.setValue(issuerName);

	Subject subject = buildXMLObject(Subject.class, Subject.DEFAULT_ELEMENT_NAME);
	assertion.setSubject(subject);
	NameID subjectNameId = buildXMLObject(NameID.class, NameID.DEFAULT_ELEMENT_NAME);
	subject.setNameID(subjectNameId);
	subjectNameId.setValue(subjectName);
	SubjectConfirmation subjectConfirmation = buildXMLObject(SubjectConfirmation.class,
			SubjectConfirmation.DEFAULT_ELEMENT_NAME);
	subject.getSubjectConfirmations().add(subjectConfirmation);
	subjectConfirmation.setMethod(SubjectConfirmation.METHOD_HOLDER_OF_KEY);
	KeyInfoConfirmationDataType keyInfoConfirmationData = new KeyInfoConfirmationDataTypeBuilder()
			.buildObject(KeyInfoConfirmationDataType.DEFAULT_ELEMENT_NAME, KeyInfoConfirmationDataType.TYPE_NAME);
	subjectConfirmation.setSubjectConfirmationData(keyInfoConfirmationData);
	BasicKeyInfoGeneratorFactory keyInfoGeneratorFactory = new BasicKeyInfoGeneratorFactory();
	keyInfoGeneratorFactory.setEmitPublicKeyValue(true);
	BasicX509Credential keyInfoCredential = new BasicX509Credential();
	keyInfoCredential.setPublicKey(hokPublicKey);
	KeyInfo keyInfo = keyInfoGeneratorFactory.newInstance().generate(keyInfoCredential);
	keyInfoConfirmationData.getKeyInfos().add(keyInfo);

	BasicX509Credential credential = new BasicX509Credential();
	credential.setPrivateKey(issuerPrivateKey);
	credential.setEntityCertificate(issuerCertificate);

	Signature signature = (Signature) Configuration.getBuilderFactory().getBuilder(Signature.DEFAULT_ELEMENT_NAME)
			.buildObject(Signature.DEFAULT_ELEMENT_NAME);
	signature.setSigningCredential(credential);
	SecurityConfiguration secConfig = Configuration.getGlobalSecurityConfiguration();
	SecurityHelper.prepareSignatureParams(signature, credential, secConfig, null);

	assertion.setSignature(signature);

	Element element = Configuration.getMarshallerFactory().getMarshaller(assertion).marshall(assertion);

	Signer.signObject(signature);

	return element;
}
 
开发者ID:e-Contract,项目名称:dssp,代码行数:52,代码来源:TestUtils.java


注:本文中的org.opensaml.Configuration.getGlobalSecurityConfiguration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。