本文整理汇总了Java中org.apache.ws.security.saml.ext.bean.KeyInfoBean类的典型用法代码示例。如果您正苦于以下问题:Java KeyInfoBean类的具体用法?Java KeyInfoBean怎么用?Java KeyInfoBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KeyInfoBean类属于org.apache.ws.security.saml.ext.bean包,在下文中一共展示了KeyInfoBean类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createKeyInfo
import org.apache.ws.security.saml.ext.bean.KeyInfoBean; //导入依赖的package包/类
protected KeyInfoBean createKeyInfo() throws Exception
{
InputStream is = Thread.currentThread().getContextClassLoader().getResource("META-INF/alice.properties").openStream();
Properties props = new Properties();
try
{
props.load(is);
}
finally
{
is.close();
}
Crypto crypto = CryptoFactory.getInstance(props);
CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);
cryptoType.setAlias("alice");
X509Certificate[] certs = crypto.getX509Certificates(cryptoType);
KeyInfoBean keyInfo = new KeyInfoBean();
keyInfo.setCertificate(certs[0]);
keyInfo.setCertIdentifer(CERT_IDENTIFIER.X509_CERT);
return keyInfo;
}
示例2: handle
import org.apache.ws.security.saml.ext.bean.KeyInfoBean; //导入依赖的package包/类
public void handle(Callback[] callbacks)
throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof SAMLCallback) {
SAMLCallback callback = (SAMLCallback) callbacks[i];
callback.setSamlVersion(SAMLVersion.VERSION_20);
callback.setIssuer(issuer);
SubjectBean subjectBean =
new SubjectBean(
subjectName, subjectQualifier, confirmationMethod
);
if (SAML2Constants.CONF_HOLDER_KEY.equals(confirmationMethod)) {
try {
KeyInfoBean keyInfo = createKeyInfo();
subjectBean.setKeyInfo(keyInfo);
} catch (Exception ex) {
throw new IOException("Problem creating KeyInfo: " + ex.getMessage());
}
}
callback.setSubject(subjectBean);
createAndSetStatement(null, callback);
} else {
throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
}
}
}
示例3: createKeyInfo
import org.apache.ws.security.saml.ext.bean.KeyInfoBean; //导入依赖的package包/类
protected KeyInfoBean createKeyInfo() throws Exception
{
InputStream is = Thread.currentThread().getContextClassLoader().getResource("META-INF/alice.properties").openStream();
Properties props = new Properties();
try
{
props.load(is);
}
finally
{
is.close();
}
Crypto crypto = CryptoFactory.getInstance(props);
CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);
cryptoType.setAlias("alice");
X509Certificate[] certs = crypto.getX509Certificates(cryptoType);
KeyInfoBean keyInfo = new KeyInfoBean();
keyInfo.setCertificate(certs[0]);
keyInfo.setCertIdentifer(CERT_IDENTIFIER.X509_CERT);
return keyInfo;
}
示例4: createKeyInfo
import org.apache.ws.security.saml.ext.bean.KeyInfoBean; //导入依赖的package包/类
protected KeyInfoBean createKeyInfo() throws Exception {
KeyInfoBean keyInfo = new KeyInfoBean();
if (statement == Statement.AUTHN) {
keyInfo.setCertificate(certs[0]);
keyInfo.setCertIdentifer(certIdentifier);
} else if (statement == Statement.ATTR) {
// Build a new Document
DocumentBuilderFactory docBuilderFactory =
DocumentBuilderFactory.newInstance();
docBuilderFactory.setNamespaceAware(true);
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
// Create an Encrypted Key
WSSecEncryptedKey encrKey = new WSSecEncryptedKey();
encrKey.setKeyIdentifierType(WSConstants.X509_KEY_IDENTIFIER);
encrKey.setUseThisCert(certs[0]);
encrKey.prepare(doc, null);
ephemeralKey = encrKey.getEphemeralKey();
Element encryptedKeyElement = encrKey.getEncryptedKeyElement();
// Append the EncryptedKey to a KeyInfo element
Element keyInfoElement =
doc.createElementNS(
WSConstants.SIG_NS, WSConstants.SIG_PREFIX + ":" + WSConstants.KEYINFO_LN
);
keyInfoElement.setAttributeNS(
WSConstants.XMLNS_NS, "xmlns:" + WSConstants.SIG_PREFIX, WSConstants.SIG_NS
);
keyInfoElement.appendChild(encryptedKeyElement);
keyInfo.setElement(keyInfoElement);
}
return keyInfo;
}
示例5: handle
import org.apache.ws.security.saml.ext.bean.KeyInfoBean; //导入依赖的package包/类
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
for (int i = 0; i < callbacks.length; i++)
{
if (callbacks[i] instanceof SAMLCallback)
{
SAMLCallback callback = (SAMLCallback) callbacks[i];
if (this.saml2)
{
callback.setSamlVersion(SAMLVersion.VERSION_20);
}
callback.setIssuer("sts");
String subjectName = "uid=sts-client,o=jbws-cxf-sts.com";
String subjectQualifier = "www.jbws-cxf-sts.org";
SubjectBean subjectBean = new SubjectBean(subjectName, subjectQualifier, this.confirmationMethod);
if (SAML2Constants.CONF_HOLDER_KEY.equals(this.confirmationMethod)
|| SAML1Constants.CONF_HOLDER_KEY.equals(this.confirmationMethod))
{
try
{
KeyInfoBean keyInfo = createKeyInfo();
subjectBean.setKeyInfo(keyInfo);
}
catch (Exception ex)
{
throw new IOException("Problem creating KeyInfo: " + ex.getMessage());
}
}
callback.setSubject(subjectBean);
AttributeStatementBean attrBean = new AttributeStatementBean();
attrBean.setSubject(subjectBean);
AttributeBean attributeBean = new AttributeBean();
if (this.saml2)
{
attributeBean.setQualifiedName("subject-role");
}
else
{
attributeBean.setSimpleName("subject-role");
attributeBean.setQualifiedName("http://custom-ns");
}
attributeBean.setAttributeValues(Collections.singletonList("system-user"));
attrBean.setSamlAttributes(Collections.singletonList(attributeBean));
callback.setAttributeStatementData(Collections.singletonList(attrBean));
}
}
}
示例6: handle
import org.apache.ws.security.saml.ext.bean.KeyInfoBean; //导入依赖的package包/类
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
for (int i = 0; i < callbacks.length; i++)
{
if (callbacks[i] instanceof SAMLCallback)
{
SAMLCallback callback = (SAMLCallback) callbacks[i];
if (this.saml2)
{
callback.setSamlVersion(SAMLVersion.VERSION_20);
}
callback.setIssuer("sts");
String subjectName = "uid=sts-client,o=jbws-cxf-sts.com";
String subjectQualifier = "www.jbws-cxf-sts.org";
SubjectBean subjectBean = new SubjectBean(subjectName, subjectQualifier, this.confirmationMethod);
if (SAML2Constants.CONF_HOLDER_KEY.equals(this.confirmationMethod)
|| SAML1Constants.CONF_HOLDER_KEY.equals(this.confirmationMethod))
{
try
{
KeyInfoBean keyInfo = createKeyInfo();
subjectBean.setKeyInfo(keyInfo);
}
catch (Exception ex)
{
throw new IOException("Problem creating KeyInfo: " + ex.getMessage());
}
}
callback.setSubject(subjectBean);
AttributeStatementBean attrBean = new AttributeStatementBean();
attrBean.setSubject(subjectBean);
AttributeBean attributeBean = new AttributeBean();
if (this.saml2)
{
attributeBean.setQualifiedName("subject-role");
}
else
{
attributeBean.setSimpleName("subject-role");
attributeBean.setQualifiedName("http://custom-ns");
}
attributeBean.setAttributeValues(Collections.singletonList("system-user"));
attrBean.setSamlAttributes(Collections.singletonList(attributeBean));
callback.setAttributeStatementData(Collections.singletonList(attrBean));
}
}
}