Package org.apache.sling.replication.transport.authentication

Examples of org.apache.sling.replication.transport.authentication.TransportAuthenticationContext.addAttribute()


                // TODO : http client should be cached and reused

                CredentialsProvider credentialsProvider = new BasicCredentialsProvider();

                TransportAuthenticationContext context = new TransportAuthenticationContext();
                context.addAttribute("endpoint", endpoint);
                credentialsProvider = authenticationProvider.authenticate(credentialsProvider, context);

                final CloseableHttpAsyncClient httpClient = HttpAsyncClients.custom()
                        .setDefaultCredentialsProvider(credentialsProvider)
                        .build();
View Full Code Here


        Session session = null;
        try {
            TransportAuthenticationContext transportAuthenticationContext = new TransportAuthenticationContext();
            String path = replicationEndpoint.getUri().toString().replace("repo:/", "");
            transportAuthenticationContext.addAttribute("path", path);
            session = transportAuthenticationProvider.authenticate(repository, transportAuthenticationContext);
            int lastSlash = replicationPackage.getId().lastIndexOf('/');
            String nodeName = Text.escape(lastSlash < 0 ? replicationPackage.getId() : replicationPackage.getId().substring(lastSlash + 1));
            log.info("creating node {} in {}", replicationPackage.getId(), nodeName);
View Full Code Here

                        replicationEndpoint.getUri(), transportAuthenticationProvider});

        try {
            Executor executor = Executor.newInstance();
            TransportAuthenticationContext context = new TransportAuthenticationContext();
            context.addAttribute("endpoint", replicationEndpoint);
            executor = transportAuthenticationProvider.authenticate(executor, context);

            deliverPackage(executor, replicationPackage, replicationEndpoint);

        } catch (Exception ex) {
View Full Code Here

        try {
            Executor executor = Executor.newInstance();

            TransportAuthenticationContext context = new TransportAuthenticationContext();
            context.addAttribute("endpoint", replicationEndpoint);
            executor = transportAuthenticationProvider.authenticate(executor, context);

            Request req = Request.Post(replicationEndpoint.getUri()).useExpectContinue();

            InputStream inputStream = null;
View Full Code Here

            // TODO : executor should be cached and reused

            Executor executor = Executor.newInstance();
            TransportAuthenticationContext context = new TransportAuthenticationContext();
            context.addAttribute("endpoint", replicationEndpoint);
            executor = transportAuthenticationProvider.authenticate(executor, context);

            Request req = Request.Post(replicationURI).useExpectContinue();

            // TODO : add queue parameter
View Full Code Here

        String serviceName = "service";
        RepositoryTransportAuthenticationProvider repositoryTransportAuthenticationProvider = new RepositoryTransportAuthenticationProvider(serviceName);

        SlingRepository repo = mock(SlingRepository.class);
        TransportAuthenticationContext context = new TransportAuthenticationContext();
        context.addAttribute("path", "/foo/bar");
        try {
            repositoryTransportAuthenticationProvider.authenticate(repo, context);
            fail("cannot authenticate a without privileges");
        } catch (TransportAuthenticationException e) {
            // expected to fail
View Full Code Here

    public void testAuthenticateWithPathAndPrivilege() throws Exception {
        String serviceName = "service";

        TransportAuthenticationContext context = new TransportAuthenticationContext();
        String path = "/foo/bar";
        context.addAttribute("path", path);
        String privilege = Privilege.JCR_WRITE;
        context.addAttribute("privilege", privilege);

        SlingRepository repo = mock(SlingRepository.class);
        Session authenticatedSession = mock(Session.class);
View Full Code Here

        TransportAuthenticationContext context = new TransportAuthenticationContext();
        String path = "/foo/bar";
        context.addAttribute("path", path);
        String privilege = Privilege.JCR_WRITE;
        context.addAttribute("privilege", privilege);

        SlingRepository repo = mock(SlingRepository.class);
        Session authenticatedSession = mock(Session.class);
        when(authenticatedSession.hasPermission(path, privilege)).thenReturn(true);
        when(repo.loginService(serviceName, null)).thenReturn(authenticatedSession);
View Full Code Here

    public void testAuthenticationWithAuthenticableAndCorrectContext() throws Exception {
        UserCredentialsTransportAuthenticationProvider authenticationHandler = new UserCredentialsTransportAuthenticationProvider(
                "foo", "bar");
        Executor authenticable = Executor.newInstance();
        TransportAuthenticationContext context = new TransportAuthenticationContext();
        context.addAttribute("endpoint", new ReplicationEndpoint("http://www.apache.org"));
        authenticationHandler.authenticate(authenticable, context);
    }
}
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.