Package demo.sts.provider.token

Examples of demo.sts.provider.token.SAMLTokenIssueOperation$KeyStoreInfo


    private String keySignAlias = "mystskey";
    private String keySignPwd = "stskpass";

    @Test
    public void testIssueDelegateNullParameter() {
        SAMLTokenIssueOperation id = new SAMLTokenIssueOperation();

        try {
            id.issue(null, null);
            fail("NullPointerException should be thrown");
        } catch (NullPointerException e) {
            // expected
        }
    }
View Full Code Here


        EasyMock.expect(context.getMessageContext()).andReturn(ctx2).anyTimes();
        UsernameToken token = new UsernameToken("joe", null, null, false, null, null);
        EasyMock.expect(ctx2.get(SecurityToken.class.getName())).andReturn(token).anyTimes();

       
        SAMLTokenIssueOperation id = new SAMLTokenIssueOperation();
        CertificateVerifierConfig certificateVerifierConfig = new CertificateVerifierConfig();
        certificateVerifierConfig.setTrustCertAliases(Arrays.asList("cacert"));
        certificateVerifierConfig.setKeySignAlias(keySignAlias);
        certificateVerifierConfig.setKeySignPwd(keySignPwd);
        certificateVerifierConfig.setStorePath(storePath);
        certificateVerifierConfig.setStorePwd(storePwd);
        id.setCertificateVerifierConfig(certificateVerifierConfig);

        JAXBElement<String> tokenType = new JAXBElement<String>(
                new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512",
                        "TokenType"), String.class,
                "urn:oasis:names:tc:SAML:1.0:assertion");

        EasyMock.expect(requestMock.getAny()).andStubReturn(
                Arrays.asList((Object) tokenType));
       
       
        EasyMock.replay(requestMock, context, ctx2);

        TokenProvider tp1 = new Saml1TokenProvider();
        TokenProvider tp2 = new Saml2TokenProvider();
        id.setTokenProviders(Arrays.asList(tp1, tp2));

        id.issue(requestMock, context);

        verify(requestMock);
    }
View Full Code Here

        verify(requestMock);
    }

    @Test
    public void testIssueDelegateWrongSignKey() {
        SAMLTokenIssueOperation id = new SAMLTokenIssueOperation();
        CertificateVerifierConfig certificateVerifierConfig = new CertificateVerifierConfig();
        certificateVerifierConfig.setTrustCertAliases(Arrays.asList("cacert"));
        certificateVerifierConfig.setKeySignAlias(keySignAlias);
        certificateVerifierConfig.setKeySignPwd("xxx");
        certificateVerifierConfig.setStorePath(storePath);
        certificateVerifierConfig.setStorePwd(storePwd);
        id.setCertificateVerifierConfig(certificateVerifierConfig);

        JAXBElement<String> tokenType = new JAXBElement<String>(new QName(
                "http://docs.oasis-open.org/ws-sx/ws-trust/200512",
                "TokenType"), String.class,
                "urn:oasis:names:tc:SAML:1.0:assertion");

        EasyMock.expect(requestMock.getAny()).andStubReturn(
                Arrays.asList((Object) tokenType));

        EasyMock.replay(requestMock);

        TokenProvider tp1 = new Saml1TokenProvider();
        TokenProvider tp2 = new Saml2TokenProvider();
        id.setTokenProviders(Arrays.asList(tp1, tp2));

        try {
            id.issue(requestMock, null);
            fail("STSException should be thrown");
        } catch (STSException e) {
            // expected
        } finally {
            verify(requestMock);
View Full Code Here

        }
    }

    @Test
    public void testIssueDelegateWrongSignAlias() {
        SAMLTokenIssueOperation id = new SAMLTokenIssueOperation();
        CertificateVerifierConfig certificateVerifierConfig = new CertificateVerifierConfig();
        certificateVerifierConfig.setTrustCertAliases(Arrays.asList("cacert"));
        certificateVerifierConfig.setKeySignAlias("xxx");
        certificateVerifierConfig.setKeySignPwd(keySignPwd);
        certificateVerifierConfig.setStorePath(storePath);
        certificateVerifierConfig.setStorePwd(storePwd);
        id.setCertificateVerifierConfig(certificateVerifierConfig);

        JAXBElement<String> tokenType = new JAXBElement<String>(new QName(
                "http://docs.oasis-open.org/ws-sx/ws-trust/200512",
                "TokenType"), String.class,
                "urn:oasis:names:tc:SAML:1.0:assertion");

        EasyMock.expect(requestMock.getAny()).andStubReturn(
                Arrays.asList((Object) tokenType));

        EasyMock.replay(requestMock);

        TokenProvider tp1 = new Saml1TokenProvider();
        TokenProvider tp2 = new Saml2TokenProvider();
        id.setTokenProviders(Arrays.asList(tp1, tp2));

        try {
            id.issue(requestMock, null);

            fail("STSException should be thrown");
        } catch (STSException e) {
            // expected
        } finally {
View Full Code Here

        }
    }

    @Test
    public void testIssueDelegateUsernameNull() {
        SAMLTokenIssueOperation id = new SAMLTokenIssueOperation();
        assertNotNull(id);

        EasyMock.expect(requestMock.getAny()).andStubReturn(Arrays.asList());
        EasyMock.replay(requestMock);

        TokenProvider tp1 = new Saml1TokenProvider();
        TokenProvider tp2 = new Saml2TokenProvider();
        id.setTokenProviders(Arrays.asList(tp1, tp2));

        try {
            id.issue(requestMock, null);
            fail("STSException should be thrown");
        } catch (STSException e) {
            //expected
        }
        verify(requestMock);
View Full Code Here

    }

    @Ignore
    @Test
    public void testIssueDelegateWithCert() throws Exception {
        SAMLTokenIssueOperation id = new SAMLTokenIssueOperation();
        assertNotNull(id);
        CertificateVerifierConfig certificateVerifierConfig = new CertificateVerifierConfig();
        certificateVerifierConfig.setTrustCertAliases(Arrays.asList("cacert"));
        certificateVerifierConfig.setKeySignAlias(keySignAlias);
        certificateVerifierConfig.setKeySignPwd(keySignPwd);
        certificateVerifierConfig.setStorePath(storePath);
        certificateVerifierConfig.setStorePwd(storePwd);
        id.setCertificateVerifierConfig(certificateVerifierConfig);
        JAXBElement<byte[]> jX509Certificate = new JAXBElement<byte[]>(
                QName.valueOf("X509Certificate"), byte[].class,
                Base64Utility.decode(CERT_DATA));

        X509DataType x509DataType = new X509DataType();
        x509DataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(
                jX509Certificate);
        JAXBElement<X509DataType> jX509DataType = new JAXBElement<X509DataType>(
                QName.valueOf("X509Data"), X509DataType.class, x509DataType);

        KeyInfoType keyInfoType = new KeyInfoType();
        keyInfoType.getContent().add(jX509DataType);
        JAXBElement<KeyInfoType> jKeyInfoType = new JAXBElement<KeyInfoType>(
                QName.valueOf("KeyInfo"), KeyInfoType.class, keyInfoType);

        UseKeyType useKeyType = new UseKeyType();
        useKeyType.setAny(jKeyInfoType);
        JAXBElement<UseKeyType> jUseKeyType = new JAXBElement<UseKeyType>(
                QName.valueOf("UseKey"), UseKeyType.class, useKeyType);

        JAXBElement<String> tokenType = new JAXBElement<String>(
                new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512",
                        "TokenType"), String.class,
                "urn:oasis:names:tc:SAML:1.0:assertion");

        EasyMock.expect(requestMock.getAny()).andStubReturn(
                Arrays.asList((Object) jUseKeyType, (Object) tokenType));
        EasyMock.replay(requestMock);

        TokenProvider tp1 = new Saml1TokenProvider();
        TokenProvider tp2 = new Saml2TokenProvider();
        id.setTokenProviders(Arrays.asList(tp1, tp2));

        id.issue(requestMock, null);

        verify(requestMock);
    }
View Full Code Here

        verify(requestMock);
    }

    @Test
    public void testIssueDelegateWithCertWithWrongStorePass() throws Exception {
        SAMLTokenIssueOperation id = new SAMLTokenIssueOperation();

        CertificateVerifierConfig certificateVerifierConfig = new CertificateVerifierConfig();
        certificateVerifierConfig.setTrustCertAliases(Arrays.asList("cacert"));
        certificateVerifierConfig.setKeySignAlias(keySignAlias);
        certificateVerifierConfig.setKeySignPwd(keySignPwd);
        certificateVerifierConfig.setStorePath(storePath);
        certificateVerifierConfig.setStorePwd("xxx");
        id.setCertificateVerifierConfig(certificateVerifierConfig);
        JAXBElement<byte[]> jX509Certificate = new JAXBElement<byte[]>(
                QName.valueOf("X509Certificate"), byte[].class,
                Base64Utility.decode(CERT_DATA));

        X509DataType x509DataType = new X509DataType();
        x509DataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(
                jX509Certificate);
        JAXBElement<X509DataType> jX509DataType = new JAXBElement<X509DataType>(
                QName.valueOf("X509Data"), X509DataType.class, x509DataType);

        KeyInfoType keyInfoType = new KeyInfoType();
        keyInfoType.getContent().add(jX509DataType);
        JAXBElement<KeyInfoType> jKeyInfoType = new JAXBElement<KeyInfoType>(
                QName.valueOf("KeyInfo"), KeyInfoType.class, keyInfoType);

        UseKeyType useKeyType = new UseKeyType();
        useKeyType.setAny(jKeyInfoType);
        JAXBElement<UseKeyType> jUseKeyType = new JAXBElement<UseKeyType>(
                QName.valueOf("UseKey"), UseKeyType.class, useKeyType);

        JAXBElement<String> tokenType = new JAXBElement<String>(new QName(
                "http://docs.oasis-open.org/ws-sx/ws-trust/200512",
                "TokenType"), String.class,
                "urn:oasis:names:tc:SAML:1.0:assertion");

        EasyMock.expect(requestMock.getAny()).andStubReturn(
                Arrays.asList((Object) jUseKeyType, (Object) tokenType));
        EasyMock.replay(requestMock);

        TokenProvider tp1 = new Saml1TokenProvider();
        TokenProvider tp2 = new Saml2TokenProvider();
        id.setTokenProviders(Arrays.asList(tp1, tp2));

        try {
            id.issue(requestMock, null);
            fail("STSException should be thrown");
        } catch (STSException e) {
            // expected
        } finally {
            verify(requestMock);
View Full Code Here

        }
    }

    @Test
    public void testIssueDelegateWithCertWithoutTokenProvidersAndTokenType() throws Exception {
        SAMLTokenIssueOperation id = new SAMLTokenIssueOperation();

        CertificateVerifierConfig certificateVerifierConfig = new CertificateVerifierConfig();
        certificateVerifierConfig.setTrustCertAliases(Arrays.asList("cacert"));
        certificateVerifierConfig.setKeySignAlias(keySignAlias);
        certificateVerifierConfig.setKeySignPwd(keySignPwd);
        certificateVerifierConfig.setStorePath(storePath);
        certificateVerifierConfig.setStorePwd(storePwd);
        id.setCertificateVerifierConfig(certificateVerifierConfig);
        JAXBElement<byte[]> jX509Certificate = new JAXBElement<byte[]>(
                QName.valueOf("X509Certificate"), byte[].class,
                Base64Utility.decode(CERT_DATA));

        X509DataType x509DataType = new X509DataType();
        x509DataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(
                jX509Certificate);
        JAXBElement<X509DataType> jX509DataType = new JAXBElement<X509DataType>(
                QName.valueOf("X509Data"), X509DataType.class, x509DataType);

        KeyInfoType keyInfoType = new KeyInfoType();
        keyInfoType.getContent().add(jX509DataType);
        JAXBElement<KeyInfoType> jKeyInfoType = new JAXBElement<KeyInfoType>(
                QName.valueOf("KeyInfo"), KeyInfoType.class, keyInfoType);

        UseKeyType useKeyType = new UseKeyType();
        useKeyType.setAny(jKeyInfoType);
        JAXBElement<UseKeyType> jUseKeyType = new JAXBElement<UseKeyType>(
                QName.valueOf("UseKey"), UseKeyType.class, useKeyType);

        EasyMock.expect(requestMock.getAny()).andStubReturn(
                Arrays.asList((Object) jUseKeyType));
        EasyMock.replay(requestMock);


        List<TokenProvider> tps = Collections.emptyList();
        id.setTokenProviders(tps);

        try {
            id.issue(requestMock, null);
            fail("STSException should be thrown");
        } catch (STSException e) {
            //expected
        } finally {
            verify(requestMock);
View Full Code Here

        }
    }

    @Test
    public void testIssueDelegateWithoutCertAndUserToken() throws CertificateException {
        SAMLTokenIssueOperation id = new SAMLTokenIssueOperation();

        JAXBElement<String> tokenType = new JAXBElement<String>(new QName(
                "http://docs.oasis-open.org/ws-sx/ws-trust/200512",
                "TokenType"), String.class,
                "urn:oasis:names:tc:SAML:1.0:assertion");

        EasyMock.expect(requestMock.getAny()).andStubReturn(
                Arrays.asList((Object) tokenType));
        EasyMock.replay(requestMock);

        TokenProvider tp1 = new Saml1TokenProvider();
        TokenProvider tp2 = new Saml2TokenProvider();
        id.setTokenProviders(Arrays.asList(tp1, tp2));

        try {
            id.issue(requestMock, null);

            fail("STSException should be thrown");
        } catch (STSException e) {
            // expected
        } finally {
View Full Code Here

        }
    }

    @Test
    public void testIssueDelegateWithInvalidCert() throws CertificateException {
        SAMLTokenIssueOperation id = new SAMLTokenIssueOperation();
        assertNotNull(id);

        // CertificateFactory certificateFactory =
        // CertificateFactory.getInstance("X.509");
        // X509Certificate x509Certificate = null;
        // try {
        // x509Certificate =
        // (X509Certificate)certificateFactory.generateCertificate(new
        // ByteArrayInputStream(Base64.decodeBase64(CERT_DATA.getBytes())));
        // } catch (CertificateException e) {
        // e.printStackTrace();
        // }
        // JAXBElement<X509Certificate> jX509Certificate = new
        // JAXBElement<X509Certificate>(QName.valueOf("X509Certificate"),
        // X509Certificate.class, x509Certificate);

        JAXBElement<byte[]> jX509Certificate = new JAXBElement<byte[]>(
                QName.valueOf("X509Certificate"), byte[].class,
                CERT_DATA.getBytes());

        X509DataType x509DataType = new X509DataType();
        x509DataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(
                jX509Certificate);
        JAXBElement<X509DataType> jX509DataType = new JAXBElement<X509DataType>(
                QName.valueOf("X509Data"), X509DataType.class, x509DataType);

        KeyInfoType keyInfoType = new KeyInfoType();
        keyInfoType.getContent().add(jX509DataType);
        JAXBElement<KeyInfoType> jKeyInfoType = new JAXBElement<KeyInfoType>(
                QName.valueOf("KeyInfo"), KeyInfoType.class, keyInfoType);

        UseKeyType useKeyType = new UseKeyType();
        useKeyType.setAny(jKeyInfoType);
        JAXBElement<UseKeyType> jUseKeyType = new JAXBElement<UseKeyType>(
                QName.valueOf("UseKey"), UseKeyType.class, useKeyType);

        EasyMock.expect(requestMock.getAny()).andStubReturn(
                Arrays.asList((Object) jUseKeyType));
        EasyMock.replay(requestMock);


        TokenProvider tp1 = new Saml1TokenProvider();
        TokenProvider tp2 = new Saml2TokenProvider();
        id.setTokenProviders(Arrays.asList(tp1, tp2));

        try {
            id.issue(requestMock, null);
            fail("STSException should be thrown");
        } catch (STSException e) {
            //expected
        }
View Full Code Here

TOP

Related Classes of demo.sts.provider.token.SAMLTokenIssueOperation$KeyStoreInfo

Copyright © 2018 www.massapicom. 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.