Package com.streamreduce.core.model

Examples of com.streamreduce.core.model.ConnectionCredentials


        return new Connection.Builder()
                .alias("PingdomClientIT Connection")
                .account(testAccount)
                .user(testUser)
                .authType(AuthType.USERNAME_PASSWORD_WITH_API_KEY)
                .credentials(new ConnectionCredentials(username, password, apiKey))
                .url(PingdomClient.PINGDOM_URL)
                .provider(ConnectionProvidersForTests.PINGDOM_PROVIDER)
                .build();
    }
View Full Code Here


                .accountOriginator(true)
                .fullname("Nodeable Test User")
                .username("test_user_" + new Date().getTime() + "@nodeable.com")
                .build();

        ConnectionCredentials credentials = new ConnectionCredentials();

        credentials.setOauthToken(twitterOAuthToken);
        credentials.setOauthTokenSecret(twitterOAuthSecret);

        connection = new Connection.Builder()
                .credentials(credentials)
                .provider(ConnectionProvidersForTests.TWITTER_PROVIDER)
                .alias("Test Twitter Connection")
View Full Code Here

        //Reuse the same connection but do enough to make it look like a new, non-duplicate connection
        awsConnection.setId(null);
        awsConnection.setUser(testUser);
        awsConnection.setAccount(testUser.getAccount());
        awsConnection.setCredentials(new ConnectionCredentials(anotherAccessKey, anotherSecretKey));
        awsConnection.setOutboundConfigurations(Sets.newHashSet(new OutboundConfiguration.Builder()
                .protocol("s3")
                .dataTypes(OutboundDataType.PROCESSED)
                .namespace(bucketName)
                .credentials(new ConnectionCredentials(anotherAccessKey, anotherSecretKey))
                .build()));

        //Saving this connection should fail because the outboundConfiguration is invalid
        connectionService.createConnection(awsConnection);
    }
View Full Code Here

        String anotherSecretKey = "LplQfj37z4R0Uj00gErN0qLTr0ek8FHFrm30CUba";
        createdConnection.addOutboundConfiguration(new OutboundConfiguration.Builder()
                .protocol("s3")
                .dataTypes(OutboundDataType.PROCESSED)
                .namespace(bucketName)
                .credentials(new ConnectionCredentials(anotherAccessKey, anotherSecretKey))
                .build());
        connectionService.updateConnection(createdConnection);
    }
View Full Code Here

    @Test
    public void testJiraConnectionCRUD() throws Exception {
        Connection tmpConnection = new Connection.Builder()
                .alias("Nodeable Jira")
                .description("Nodeable's Jira instance.")
                .credentials(new ConnectionCredentials(jiraProperties.getString("nodeable.jira.username"),
                        jiraProperties.getString("nodeable.jira.password")))
                .provider(connectionProviderFactory.connectionProviderFromId(ProviderIdConstants.JIRA_PROVIDER_ID))
                .url(jiraProperties.getString("nodeable.jira.url"))
                .authType(AuthType.USERNAME_PASSWORD)
                .user(testUser)
                .build();

        Connection connection = connectionService.createConnection(tmpConnection);

        // Set lastActivity
        HashMap<String, String> metadata = new HashMap<>();
        metadata.put("last_activity_poll", Long.toString(System.currentTimeMillis()));
        connection.setMetadata(metadata);

        assertNotNull(connection.getId());

        /* Verify the projects returned look like what we expect.  (This is fragile and depends on us knowing
           the projects the Jira user we're testing with has access to.
         */
        validateJiraProjectHostingInventoryItems(connection);
        pollForProjectHostingActivity(connection);

        /* Test reading back the connection */
        connection = connectionService.getConnection(connection.getId());
        assertNotNull(connection);

        /* Test reading all Jira connections */
        assertEquals(1, connectionService.getConnections(ProjectHostingProvider.TYPE, testUser).size());

        /* Test updating a connection */
        connection.setCredentials(new ConnectionCredentials(jiraProperties.getString("nodeable.jira.username"),
                jiraProperties.getString("nodeable.jira.password")));
        connection.setDescription("Updated description.");
        connection = connectionService.updateConnection(connection);

        assertEquals("Updated description.", connectionService.getConnection(connection.getId()).getDescription());
View Full Code Here

    @Test
    public void testUpdateConnectionPersistsOutboundConfigurations() throws Exception {

        OutboundConfiguration outboundConfiguration = new OutboundConfiguration.Builder()
                .credentials(new ConnectionCredentials(cloudBundle.getString("nodeable.aws.accessKeyId"), cloudBundle.getString("nodeable.aws.secretKey")))
                .destination("eu-west-1")
                .protocol("s3")
                .namespace("com.streamreduce.bucket")
                .dataTypes(OutboundDataType.PROCESSED)
                .build();
View Full Code Here

        }
    }

    @Test
    public void testCreateTwitterConnectionWithValidOAuthToken() throws Exception {
        ConnectionCredentials credentials = new ConnectionCredentials();

        credentials.setOauthToken(twitterProperties.getString("nodeable.integrations.twitter.oauth_token"));
        credentials.setOauthTokenSecret(twitterProperties.getString("nodeable.integrations.twitter.oauth_secret"));
        Connection twitterConnection = connectionService.createConnection(new Connection.Builder()
                .account(getTestAccount())
                .alias("Test Twiter Connection")
                .authType(AuthType.OAUTH)
                .credentials(credentials)
                .provider(connectionProviderFactory.connectionProviderFromId(ProviderIdConstants.TWITTER_PROVIDER_ID))
                .user(getTestUser())
                .visibility(SobaObject.Visibility.ACCOUNT)
                .build());
        ConnectionCredentials twitterCredentials = twitterConnection.getCredentials();

        Assert.assertNotNull(twitterCredentials.getOauthToken());
        Assert.assertNotNull(twitterCredentials.getOauthTokenSecret());
        Assert.assertEquals("Nodeable", twitterCredentials.getIdentity());
    }
View Full Code Here

        return dto;
    }

    public OutboundConfigurationResponseDTO(OutboundConfiguration outboundConfiguration) {
        super(outboundConfiguration);
        ConnectionCredentials creds = outboundConfiguration.getCredentials();
        if (creds != null && StringUtils.isNotBlank(creds.getIdentity())) {
            this.identity = creds.getIdentity();
        }
    }
View Full Code Here

        setIdentityForOauthConnection(connection);
    }

    private void finishHandshakeAndSetRealOauthTokens(Connection connection) {
        ConnectionCredentials credentials = connection.getCredentials();
        OAuthEnabledConnectionProvider oauthProvider =
                connectionProviderFactory.oauthEnabledConnectionProviderFromId(connection.getProviderId());
        OAuthService oAuthService = oauthProvider.getOAuthService();
        Token requestToken = cacheService.retrieveAndRemoveToken(credentials.getOauthToken());
        Token token = oAuthService.getAccessToken(requestToken, new Verifier(credentials.getOauthVerifier()));
        oauthProvider.updateCredentials(credentials, token);
    }
View Full Code Here

    private void setCredentialsIfGateway(Connection connection) {
        if (connection.getAuthType() != null && connection.getAuthType().equals(AuthType.API_KEY)) {
            // auto generate an API key for them
            if (connection.getCredentials() == null) {
                connection.setCredentials(new ConnectionCredentials());
            }
            // we also use a user agent as a validation factor
            // so when we later validate the token, we also validate the user agent
            String apiToken = SecurityUtil.issueRandomAPIToken();
            connection.getCredentials().setIdentity(apiToken);
View Full Code Here

TOP

Related Classes of com.streamreduce.core.model.ConnectionCredentials

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.