Examples of SAMLAssertion


Examples of org.opensaml.SAMLAssertion

            SAMLAttributeStatement attrStmt = new SAMLAttributeStatement(
            subject, Arrays.asList(attrs ));

            SAMLStatement[] statements = { attrStmt };

            SAMLAssertion assertion = new SAMLAssertion(config.issuerName,
                    notBefore, notAfter, null, null, Arrays.asList(statements));

            // sign the assertion
            X509Certificate[] issuerCerts = crypto
                    .getCertificates(config.issuerKeyAlias);

            String sigAlgo = XMLSignature.ALGO_ID_SIGNATURE_RSA;
            String pubKeyAlgo = issuerCerts[0].getPublicKey().getAlgorithm();
            if (pubKeyAlgo.equalsIgnoreCase("DSA")) {
                sigAlgo = XMLSignature.ALGO_ID_SIGNATURE_DSA;
            }
            java.security.Key issuerPK = crypto.getPrivateKey(
                    config.issuerKeyAlias, config.issuerKeyPassword);
            assertion.sign(sigAlgo, issuerPK, Arrays.asList(issuerCerts));

            return assertion;
        } catch (Exception e) {
            throw new TrustException("samlAssertionCreationError", e);
        }
View Full Code Here

Examples of org.opensaml.SAMLAssertion

                    subject,
                    SAMLAuthenticationStatement.AuthenticationMethod_Password,
                    notBefore, null, null, null);
            SAMLStatement[] statements = { authStmt };

            SAMLAssertion assertion = new SAMLAssertion(config.issuerName,
                    notBefore, notAfter, null, null, Arrays.asList(statements));

            // sign the assertion
            X509Certificate[] issuerCerts = crypto
                    .getCertificates(config.issuerKeyAlias);

            String sigAlgo = XMLSignature.ALGO_ID_SIGNATURE_RSA;
            String pubKeyAlgo = issuerCerts[0].getPublicKey().getAlgorithm();
            if (pubKeyAlgo.equalsIgnoreCase("DSA")) {
                sigAlgo = XMLSignature.ALGO_ID_SIGNATURE_DSA;
            }
            java.security.Key issuerPK = crypto.getPrivateKey(
                    config.issuerKeyAlias, config.issuerKeyPassword);
            assertion.sign(sigAlgo, issuerPK, Arrays.asList(issuerCerts));

            return assertion;
        } catch (Exception e) {
            throw new TrustException("samlAssertionCreationError", e);
        }
View Full Code Here

Examples of org.opensaml.SAMLAssertion

     */
    public void testSAMLUnsignedSenderVouches() throws Exception {
        SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
        SAMLIssuer saml = SAMLIssuerFactory.getInstance("saml.properties");

        SAMLAssertion assertion = saml.newAssertion();

        WSSecSAMLToken wsSign = new WSSecSAMLToken();

        Document doc = unsignedEnvelope.getAsDocument();
        WSSecHeader secHeader = new WSSecHeader();
View Full Code Here

Examples of org.opensaml.SAMLAssertion

     */
    public void testSAMLSignedSenderVouches() throws Exception {
        SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
        SAMLIssuer saml = SAMLIssuerFactory.getInstance("saml.properties");

        SAMLAssertion assertion = saml.newAssertion();

        String issuerKeyName = saml.getIssuerKeyName();
        String issuerKeyPW = saml.getIssuerKeyPassword();
        Crypto issuerCrypto = saml.getIssuerCrypto();
        WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
View Full Code Here

Examples of org.opensaml.SAMLAssertion

     */
    public void testDefaultIssuerClass() throws Exception {
        SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
        SAMLIssuer saml = SAMLIssuerFactory.getInstance("saml3.properties");

        SAMLAssertion assertion = saml.newAssertion();

        String issuerKeyName = saml.getIssuerKeyName();
        String issuerKeyPW = saml.getIssuerKeyPassword();
        Crypto issuerCrypto = saml.getIssuerCrypto();
        WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
View Full Code Here

Examples of org.opensaml.SAMLAssertion

     */
    public void testWSS62() throws Exception {
        SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
        SAMLIssuer saml = SAMLIssuerFactory.getInstance("saml.properties");

        SAMLAssertion assertion = saml.newAssertion();

        String issuerKeyName = saml.getIssuerKeyName();
        String issuerKeyPW = saml.getIssuerKeyPassword();
        Crypto issuerCrypto = saml.getIssuerCrypto();
        WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
View Full Code Here

Examples of org.opensaml.SAMLAssertion

        // Provide info to SAML issuer that it can construct a Holder-of-key
        // SAML token.
        saml.setInstanceDoc(doc);
        saml.setUserCrypto(crypto);
        saml.setUsername("16c73ab6-b892-458f-abf5-2f875f74882e");
        SAMLAssertion assertion = saml.newAssertion();

        WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
        wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
        wsSign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
View Full Code Here

Examples of org.opensaml.SAMLAssertion

    protected void performSTAction(int actionToDo, boolean mu, Document doc, RequestData reqData)
            throws WSSecurityException {
        WSSAddSAMLToken builder = new WSSAddSAMLToken(reqData.getActor(), mu);
        SAMLIssuer saml = loadSamlIssuer(reqData);
        saml.setUsername(reqData.getUsername());
        SAMLAssertion assertion = saml.newAssertion();

        // add the SAMLAssertion Token to the SOAP Enevelope
        builder.build(doc, assertion);
    }
View Full Code Here

Examples of org.opensaml.SAMLAssertion

        SAMLIssuer saml = loadSamlIssuer(reqData);
        saml.setUsername(reqData.getUsername());
        saml.setUserCrypto(crypto);
        saml.setInstanceDoc(doc);

        SAMLAssertion assertion = saml.newAssertion();
        if (assertion == null) {
            throw new WSSecurityException("WSHandler: Signed SAML: no SAML token received");
        }
        String issuerKeyName = null;
        String issuerKeyPW = null;
View Full Code Here

Examples of org.opensaml.SAMLAssertion

                    transforms.addTransform(STRTransform.implementedTransformURI,
                            ctx);
                    sig.addDocument("#" + strUri, transforms);
                } else if (elemName.equals("Assertion")) { // Assertion
                // Make the AssertionID the wsu:Id and the signature reference the same
                SAMLAssertion assertion;
               
                Element assertionElement =
                                    (Element) WSSecurityUtil.findElement(envelope,
                                            elemName,
                                            nmSpace);
               
                try {
              assertion = new SAMLAssertion(assertionElement);
                }
                catch (Exception e1) {
              log.error(e1);
              throw new WSSecurityException(WSSecurityException.FAILED_SIGNATURE,
                          "noXMLSig", null, e1);
                }

                           Element body =
                                    (Element) WSSecurityUtil.findElement(envelope,
                                            elemName,
                                            nmSpace);
                            if (body == null) {
                                throw new WSSecurityException(WSSecurityException.FAILURE,
                                        "noEncElement",
                                        new Object[]{nmSpace + ", " + elemName});
                            }
                            transforms = new Transforms(doc);
                            transforms.addTransform(
                                    Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
                            if (wssConfig.isWsiBSPCompliant()) {
                                transforms.item(0).getElement().appendChild(
                                        new InclusiveNamespaces(
                                                doc, getInclusivePrefixes(body)).getElement());
                            }
                String prefix =
                                WSSecurityUtil.setNamespace(body,
                        wssConfig.getWsuNS(),
                        WSConstants.WSU_PREFIX);
                body.setAttributeNS(wssConfig.getWsuNS(), prefix + ":Id", assertion.getId());
                            sig.addDocument("#" + assertion.getId(), transforms);


                } else {
                    Element body =
                            (Element) WSSecurityUtil.findElement(envelope,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.