Java Code Examples for org.apache.wss4j.common.saml.SAMLCallback#setSignatureAlgorithm()
The following examples show how to use
org.apache.wss4j.common.saml.SAMLCallback#setSignatureAlgorithm() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SamlCallbackHandler.java From cxf with Apache License 2.0 | 4 votes |
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 (saml2) { callback.setSamlVersion(Version.SAML_20); } else { callback.setSamlVersion(Version.SAML_11); } if (conditions != null) { callback.setConditions(conditions); } callback.setIssuer("sts"); String subjectName = "uid=sts-client,o=mock-sts.com"; String subjectQualifier = "www.mock-sts.com"; if (!saml2 && SAML2Constants.CONF_SENDER_VOUCHES.equals(confirmationMethod)) { confirmationMethod = SAML1Constants.CONF_SENDER_VOUCHES; } SubjectBean subjectBean = new SubjectBean( subjectName, subjectQualifier, confirmationMethod ); if (SAML2Constants.CONF_HOLDER_KEY.equals(confirmationMethod) || SAML1Constants.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); AttributeStatementBean attrBean = new AttributeStatementBean(); attrBean.setSubject(subjectBean); AttributeBean attributeBean = new AttributeBean(); if (saml2) { attributeBean.setQualifiedName("subject-role"); } else { attributeBean.setSimpleName("subject-role"); attributeBean.setQualifiedName("http://custom-ns"); } attributeBean.addAttributeValue("system-user"); attrBean.setSamlAttributes(Collections.singletonList(attributeBean)); callback.setAttributeStatementData(Collections.singletonList(attrBean)); callback.setSignatureAlgorithm(signatureAlgorithm); callback.setSignatureDigestAlgorithm(digestAlgorithm); try { Crypto crypto = CryptoFactory.getInstance(cryptoPropertiesFile); callback.setIssuerCrypto(crypto); callback.setIssuerKeyName(cryptoAlias); callback.setIssuerKeyPassword(cryptoPassword); callback.setSignAssertion(signAssertion); } catch (WSSecurityException e) { throw new IOException(e); } } } }
Example 2
Source File: SamlCallbackHandler.java From cxf with Apache License 2.0 | 4 votes |
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 (saml2) { callback.setSamlVersion(Version.SAML_20); } else { callback.setSamlVersion(Version.SAML_11); } if (conditions != null) { callback.setConditions(conditions); } callback.setIssuer("sts"); String subjectName = "uid=sts-client,o=mock-sts.com"; String subjectQualifier = "www.mock-sts.com"; if (!saml2 && SAML2Constants.CONF_SENDER_VOUCHES.equals(confirmationMethod)) { confirmationMethod = SAML1Constants.CONF_SENDER_VOUCHES; } SubjectBean subjectBean = new SubjectBean( subjectName, subjectQualifier, confirmationMethod ); if (SAML2Constants.CONF_HOLDER_KEY.equals(confirmationMethod) || SAML1Constants.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); AttributeStatementBean attrBean = new AttributeStatementBean(); attrBean.setSubject(subjectBean); AttributeBean attributeBean = new AttributeBean(); if (saml2) { attributeBean.setQualifiedName("subject-role"); } else { attributeBean.setSimpleName("subject-role"); attributeBean.setQualifiedName("http://custom-ns"); } attributeBean.addAttributeValue("system-user"); attrBean.setSamlAttributes(Collections.singletonList(attributeBean)); callback.setAttributeStatementData(Collections.singletonList(attrBean)); callback.setSignatureAlgorithm(signatureAlgorithm); callback.setSignatureDigestAlgorithm(digestAlgorithm); try { Crypto crypto = CryptoFactory.getInstance(cryptoPropertiesFile); callback.setIssuerCrypto(crypto); callback.setIssuerKeyName(cryptoAlias); callback.setIssuerKeyPassword(cryptoPassword); callback.setSignAssertion(signAssertion); } catch (WSSecurityException e) { throw new IOException(e); } } } }