本文整理了Java中org.opensaml.Configuration
类的一些代码示例,展示了Configuration
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration
类的具体详情如下:
包路径:org.opensaml.Configuration
类名称:Configuration
[英]OpenSAML configuration singleton. The library must be initialized with a set of configurations prior to usage. This is often done by invoking DefaultBootstrap#bootstrap() but may done in any manner so long as all the needed object providers and artifact factory are created and registered with the configuration.
[中]OpenSAML配置单例。在使用之前,必须使用一组配置对库进行初始化。这通常通过调用DefaultBootstrap#bootstrap()来完成,但也可以通过任何方式完成,只要所有需要的对象提供程序和工件工厂都已创建并注册到配置中。
代码示例来源:origin: cloudfoundry/uaa
private XMLObject unmarshallObject(String xmlString) throws UnmarshallingException, XMLParserException, UnsupportedEncodingException {
BasicParserPool parser = new BasicParserPool();
parser.setNamespaceAware(true);
/* Base64URL encoded */
byte bytes[] = xmlString.getBytes("utf-8");
if (bytes == null || bytes.length == 0)
throw new InsufficientAuthenticationException("Invalid assertion encoding");
Reader reader = new InputStreamReader(new ByteArrayInputStream(bytes));
Document doc = parser.parse(reader);
Element samlElement = doc.getDocumentElement();
UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(samlElement);
if (unmarshaller == null) {
throw new InsufficientAuthenticationException("Unsuccessful to unmarshal assertion string");
}
return unmarshaller.unmarshall(samlElement);
}
代码示例来源:origin: cloudfoundry/uaa
/**
* Default constructor.
*/
public IdpMetadataGenerator() {
this.builderFactory = Configuration.getBuilderFactory();
}
代码示例来源:origin: cloudfoundry/uaa
private void signAssertion(Assertion assertion, Credential credential)
throws SecurityException, MarshallingException, SignatureException {
SignatureBuilder signatureBuilder = (SignatureBuilder) builderFactory
.getBuilder(Signature.DEFAULT_ELEMENT_NAME);
Signature signature = signatureBuilder.buildObject();
signature.setSigningCredential(credential);
SecurityHelper.prepareSignatureParams(signature, credential, null, null);
assertion.setSignature(signature);
Marshaller marshaller = Configuration.getMarshallerFactory().getMarshaller(assertion);
marshaller.marshall(assertion);
Signer.signObject(signature);
}
代码示例来源:origin: org.opensaml/opensaml
Credential signingCredential = messageContext.getOuboundSAMLMessageSigningCredential();
XMLObjectBuilder<Signature> signatureBuilder = Configuration.getBuilderFactory().getBuilder(
Signature.DEFAULT_ELEMENT_NAME);
Signature signature = signatureBuilder.buildObject(Signature.DEFAULT_ELEMENT_NAME);
Marshaller marshaller = Configuration.getMarshallerFactory().getMarshaller(signableMessage);
marshaller.marshall(signableMessage);
Signer.signObject(signature);
代码示例来源:origin: OpenConext/Mujina
public static void signAssertion(SignableXMLObject signableXMLObject, Credential signingCredential) throws MarshallingException, SignatureException {
Signature signature = buildSAMLObject(Signature.class, Signature.DEFAULT_ELEMENT_NAME);
signature.setSigningCredential(signingCredential);
signature.setSignatureAlgorithm(Configuration.getGlobalSecurityConfiguration().getSignatureAlgorithmURI(signingCredential));
signature.setCanonicalizationAlgorithm(SignatureConstants.ALGO_ID_C14N_EXCL_OMIT_COMMENTS);
signableXMLObject.setSignature(signature);
Configuration.getMarshallerFactory().getMarshaller(signableXMLObject).marshall(signableXMLObject);
Signer.signObject(signature);
}
代码示例来源:origin: cloudfoundry/uaa
@BeforeClass
public static void bootstrap() throws Exception {
Security.addProvider(new BouncyCastleProvider());
DefaultBootstrap.bootstrap();
NamedKeyInfoGeneratorManager keyInfoGeneratorManager = Configuration.getGlobalSecurityConfiguration().getKeyInfoGeneratorManager();
keyInfoGeneratorManager.getManager(SAML_METADATA_KEY_INFO_GENERATOR);
}
代码示例来源:origin: org.apache.ws.security/wss4j
protected static void initializeParserPool() throws ConfigurationException {
StaticBasicParserPool pp = new StaticBasicParserPool();
pp.setMaxPoolSize(50);
Map<String, Boolean> features = new HashMap<String, Boolean>();
features.put(XMLConstants.FEATURE_SECURE_PROCESSING, true);
features.put("http://apache.org/xml/features/disallow-doctype-decl", true);
pp.setBuilderFeatures(features);
pp.setExpandEntityReferences(false);
try {
pp.initialize();
} catch (XMLParserException e) {
throw new ConfigurationException("Error initializing parser pool", e);
}
Configuration.setParserPool(pp);
}
}
代码示例来源:origin: lastpass/saml-sdk-java
throws SAMLException
XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
Element elem = Configuration.getMarshallerFactory()
.getMarshaller(request)
.marshall(request);
代码示例来源:origin: cloudfoundry/uaa
@BeforeClass
public static void bootstrap() throws Exception {
Security.addProvider(new BouncyCastleProvider());
DefaultBootstrap.bootstrap();
NamedKeyInfoGeneratorManager keyInfoGeneratorManager = Configuration.getGlobalSecurityConfiguration().getKeyInfoGeneratorManager();
keyInfoGeneratorManager.getManager(SAMLConstants.SAML_METADATA_KEY_INFO_GENERATOR);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.wss4j
protected static void initializeParserPool() throws ConfigurationException {
StaticBasicParserPool pp = new StaticBasicParserPool();
pp.setMaxPoolSize(50);
Map<String, Boolean> features = new HashMap<String, Boolean>();
features.put(XMLConstants.FEATURE_SECURE_PROCESSING, true);
features.put("http://apache.org/xml/features/disallow-doctype-decl", true);
pp.setBuilderFeatures(features);
pp.setExpandEntityReferences(false);
try {
pp.initialize();
} catch (XMLParserException e) {
throw new ConfigurationException("Error initializing parser pool", e);
}
Configuration.setParserPool(pp);
}
}
代码示例来源:origin: cloudfoundry/uaa
public void initializeSimple() throws ConfigurationException {
builderFactory = Configuration.getBuilderFactory();
}
代码示例来源:origin: apache/cloudstack
public static Response decodeSAMLResponse(String responseMessage)
throws ConfigurationException, ParserConfigurationException,
SAXException, IOException, UnmarshallingException {
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
byte[] base64DecodedResponse = Base64.decode(responseMessage);
Document document = docBuilder.parse(new ByteArrayInputStream(base64DecodedResponse));
Element element = document.getDocumentElement();
UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element);
return (Response) unmarshaller.unmarshall(element);
}
代码示例来源:origin: org.opensaml/opensaml
SignableSAMLObject signableMessage = (SignableSAMLObject) outboundSAML;
XMLObjectBuilder<Signature> signatureBuilder = Configuration.getBuilderFactory().getBuilder(
Signature.DEFAULT_ELEMENT_NAME);
Signature signature = signatureBuilder.buildObject(Signature.DEFAULT_ELEMENT_NAME);
Marshaller marshaller = Configuration.getMarshallerFactory().getMarshaller(signableMessage);
if (marshaller == null) {
throw new MessageEncodingException("No marshaller registered for "
代码示例来源:origin: cloudfoundry/uaa
SecurityHelper.prepareSignatureParams(signature, defaultCredential, null, null);
assertion.setSignature(signature);
Marshaller marshaller = Configuration.getMarshallerFactory().getMarshaller(assertion);
marshaller.marshall(assertion);
Signer.signObject(signature);
代码示例来源:origin: org.opensaml/opensaml
/**
* Constructor.
*
* @param metadataProvider provider of the metadata
*
* @throws IllegalArgumentException thrown if the supplied provider is null
*/
public MetadataCredentialResolver(MetadataProvider metadataProvider) {
super();
if (metadataProvider == null) {
throw new IllegalArgumentException("Metadata provider may not be null");
}
metadata = metadataProvider;
cache = new HashMap<MetadataCacheKey, SoftReference<Collection<Credential>>>();
keyInfoCredentialResolver = Configuration.getGlobalSecurityConfiguration()
.getDefaultKeyInfoCredentialResolver();
rwlock = new ReentrantReadWriteLock();
if (metadata instanceof ObservableMetadataProvider) {
ObservableMetadataProvider observable = (ObservableMetadataProvider) metadataProvider;
observable.getObservers().add(new MetadataProviderObserver());
}
}
代码示例来源:origin: org.apache.rampart/rampart-trust
protected static void initializeParserPool() throws ConfigurationException {
AxiomParserPool pp = new AxiomParserPool();
pp.setMaxPoolSize(50);
try {
pp.initialize();
} catch (XMLParserException e) {
throw new ConfigurationException("Error initializing axiom based parser pool", e);
}
Configuration.setParserPool(pp);
}
}
代码示例来源:origin: cloudfoundry/uaa
protected KeyDescriptor getKeyDescriptor(UsageType type, KeyInfo key) {
@SuppressWarnings("unchecked")
SAMLObjectBuilder<KeyDescriptor> builder = (SAMLObjectBuilder<KeyDescriptor>) Configuration.getBuilderFactory()
.getBuilder(KeyDescriptor.DEFAULT_ELEMENT_NAME);
KeyDescriptor descriptor = builder.buildObject();
descriptor.setUse(type);
descriptor.setKeyInfo(key);
return descriptor;
}
代码示例来源:origin: org.adeptnet.auth/auth-saml
private Response parseResponse(String authnResponse) throws SAMLException {
try {
final Document doc = parsers.getBuilder()
.parse(new InputSource(new StringReader(authnResponse)));
final Element root = doc.getDocumentElement();
return (Response) Configuration.getUnmarshallerFactory()
.getUnmarshaller(root)
.unmarshall(root);
} catch (org.opensaml.xml.parse.XMLParserException | org.opensaml.xml.io.UnmarshallingException | org.xml.sax.SAXException | java.io.IOException e) {
throw new SAMLException(e);
}
}
代码示例来源:origin: apache/cloudstack
public static String encodeSAMLRequest(XMLObject authnRequest)
throws MarshallingException, IOException {
Marshaller marshaller = Configuration.getMarshallerFactory()
.getMarshaller(authnRequest);
Element authDOM = marshaller.marshall(authnRequest);
StringWriter requestWriter = new StringWriter();
XMLHelper.writeNode(authDOM, requestWriter);
String requestMessage = requestWriter.toString();
Deflater deflater = new Deflater(Deflater.DEFLATED, true);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(byteArrayOutputStream, deflater);
deflaterOutputStream.write(requestMessage.getBytes(Charset.forName("UTF-8")));
deflaterOutputStream.close();
String encodedRequestMessage = Base64.encodeBytes(byteArrayOutputStream.toByteArray(), Base64.DONT_BREAK_LINES);
encodedRequestMessage = URLEncoder.encode(encodedRequestMessage, HttpUtils.UTF_8).trim();
return encodedRequestMessage;
}
代码示例来源:origin: OpenConext/Mujina
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
super.postProcessBeanFactory(beanFactory);
BasicSecurityConfiguration config = (BasicSecurityConfiguration) Configuration.getGlobalSecurityConfiguration();
config.registerSignatureAlgorithmURI("RSA", SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256);
config.setSignatureReferenceDigestMethod(SignatureConstants.ALGO_ID_DIGEST_SHA256);
}
}
内容来源于网络,如有侵权,请联系作者删除!