Package org.apache.syncope.client.http

Examples of org.apache.syncope.client.http.PreemptiveAuthHttpRequestFactory


                    setResponsePage(WelcomePage.class, parameters);
                } catch (AccessControlException e) {
                    error(getString("login-error"));

                    PreemptiveAuthHttpRequestFactory requestFactory =
                            ((PreemptiveAuthHttpRequestFactory) SyncopeSession.
                            get().getRestTemplate().getRequestFactory());

                    ((DefaultHttpClient) requestFactory.getHttpClient()).getCredentialsProvider().clear();
                }
            }
        };

        submitButton.setDefaultFormProcessing(false);
View Full Code Here


    private String[] authenticate(final String userId, final String password) {
        final RestTemplate restTemplate = SyncopeSession.get().getRestTemplate();

        // 1. Set provided credentials to check
        PreemptiveAuthHttpRequestFactory requestFactory =
                ((PreemptiveAuthHttpRequestFactory) restTemplate.getRequestFactory());

        ((DefaultHttpClient) requestFactory.getHttpClient()).getCredentialsProvider().setCredentials(
                requestFactory.getAuthScope(), new UsernamePasswordCredentials(userId, password));

        // 2. Search authorizations for user specified by credentials
        Set<EntitlementTO> entitlements = SyncopeSession.get().getService(EntitlementService.class).getMyEntitlements();
        return CollectionWrapper.unwrap(entitlements).toArray(new String[0]);
    }
View Full Code Here

    }

    private String getSyncopeVersion() {
        final RestTemplate restTemplate = SyncopeSession.get().getRestTemplate();

        PreemptiveAuthHttpRequestFactory requestFactory = ((PreemptiveAuthHttpRequestFactory) restTemplate.
                getRequestFactory());

        String version = "";
        try {
            HttpGet get = new HttpGet(baseURL + "../version.jsp");
            HttpResponse response = requestFactory.getHttpClient().execute(get);
            version = EntityUtils.toString(response.getEntity()).trim();
        } catch (Exception e) {
            LOG.error("While fetching version from core", e);
            getSession().error(e.getMessage());
        }
View Full Code Here

        return resourceService.getConnectorObject(resourceName, type, userId);
    }

    // BEGIN Spring MVC Initialization
    private void setupRestTemplate(final String uid, final String pwd) {
        PreemptiveAuthHttpRequestFactory requestFactory = ((PreemptiveAuthHttpRequestFactory) restTemplate
                .getRequestFactory());

        ((DefaultHttpClient) requestFactory.getHttpClient()).getCredentialsProvider().setCredentials(
                requestFactory.getAuthScope(), new UsernamePasswordCredentials(uid, pwd));
    }
View Full Code Here

            exception = e.getException(SyncopeClientExceptionType.UnauthorizedRole);
        }
        assertNotNull(exception);

        // 3. auth as user just created
        PreemptiveAuthHttpRequestFactory requestFactory = ((PreemptiveAuthHttpRequestFactory) restTemplate.
                getRequestFactory());
        ((DefaultHttpClient) requestFactory.getHttpClient()).getCredentialsProvider().setCredentials(
                requestFactory.getAuthScope(), new UsernamePasswordCredentials(userTO.getUsername(), initialPassword));

        // 4. update with same password: not matching password policy
        exception = null;
        try {
            restTemplate.postForObject(BASE_URL + "user/request/update", userMod, UserRequestTO.class);
View Full Code Here

            exception = e.getException(SyncopeClientExceptionType.UnauthorizedRole);
        }
        assertNotNull(exception);

        // 3. auth as user just created
        PreemptiveAuthHttpRequestFactory requestFactory = ((PreemptiveAuthHttpRequestFactory) restTemplate.
                getRequestFactory());
        ((DefaultHttpClient) requestFactory.getHttpClient()).getCredentialsProvider().setCredentials(
                requestFactory.getAuthScope(), new UsernamePasswordCredentials(userTO.getUsername(), initialPassword));

        // 4. now request user delete works
        UserRequestTO request = restTemplate.getForObject(BASE_URL + "user/request/delete/{userId}",
                UserRequestTO.class, userTO.getId());
        assertNotNull(request);
View Full Code Here

        assertNotNull(userTO);

        assertTrue(userTO.getMembershipMap().containsKey(1L));
        assertFalse(userTO.getMembershipMap().containsKey(3L));

        PreemptiveAuthHttpRequestFactory requestFactory = ((PreemptiveAuthHttpRequestFactory) restTemplate.
                getRequestFactory());
        ((DefaultHttpClient) requestFactory.getHttpClient()).getCredentialsProvider().setCredentials(
                requestFactory.getAuthScope(), new UsernamePasswordCredentials("user1", "password"));

        SyncopeClientException exception = null;
        try {
            restTemplate.getForObject(BASE_URL + "role/selfRead/{roleId}", RoleTO.class, 3);
            fail();
View Full Code Here

    protected RestTemplate anonymousRestTemplate() {
        return new RestTemplate();
    }

    public void setupRestTemplate(final String uid, final String pwd) {
        PreemptiveAuthHttpRequestFactory requestFactory =
                ((PreemptiveAuthHttpRequestFactory) restTemplate.getRequestFactory());

        ((DefaultHttpClient) requestFactory.getHttpClient()).getCredentialsProvider().setCredentials(
                requestFactory.getAuthScope(), new UsernamePasswordCredentials(uid, pwd));
    }
View Full Code Here

        return userTO;
    }

    @Test
    public void selfRead() {
        PreemptiveAuthHttpRequestFactory requestFactory = ((PreemptiveAuthHttpRequestFactory) restTemplate.
                getRequestFactory());
        ((DefaultHttpClient) requestFactory.getHttpClient()).getCredentialsProvider().setCredentials(
                requestFactory.getAuthScope(), new UsernamePasswordCredentials("user1", "password"));

        try {
            restTemplate.getForObject(BASE_URL + "user/read/{userId}.json", UserTO.class, 1);
            fail();
        } catch (HttpClientErrorException e) {
View Full Code Here

        assertEquals(userTO.getId(), form.getUserId());
        assertNotNull(form.getTaskId());
        assertNull(form.getOwner());

        // 3. claim task from user1, not in role 7 (designated for approval in workflow definition): fail
        PreemptiveAuthHttpRequestFactory requestFactory = ((PreemptiveAuthHttpRequestFactory) restTemplate.
                getRequestFactory());
        ((DefaultHttpClient) requestFactory.getHttpClient()).getCredentialsProvider().setCredentials(
                requestFactory.getAuthScope(), new UsernamePasswordCredentials("user1", "password"));

        SyncopeClientException sce = null;
        try {
            restTemplate.getForObject(BASE_URL + "user/workflow/form/claim/{taskId}", WorkflowFormTO.class, form.
                    getTaskId());
        } catch (SyncopeClientCompositeErrorException scce) {
            sce = scce.getException(SyncopeClientExceptionType.Workflow);
        }
        assertNotNull(sce);

        // 4. claim task from user4, in to role 7
        ((DefaultHttpClient) requestFactory.getHttpClient()).getCredentialsProvider().setCredentials(
                requestFactory.getAuthScope(), new UsernamePasswordCredentials("user4", "password"));

        form = restTemplate.getForObject(BASE_URL + "user/workflow/form/claim/{taskId}", WorkflowFormTO.class, form.
                getTaskId());
        assertNotNull(form);
        assertNotNull(form.getTaskId());
View Full Code Here

TOP

Related Classes of org.apache.syncope.client.http.PreemptiveAuthHttpRequestFactory

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.