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

Examples of org.apache.sling.replication.transport.authentication.TransportAuthenticationContext


                // 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


    public void deliverPackageToEndpoint(ReplicationPackage replicationPackage, ReplicationEndpoint replicationEndpoint)
            throws Exception {

        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

                new Object[]{replicationPackage.getId(),
                        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

            List<ReplicationPackage> result = new ArrayList<ReplicationPackage>();

            // 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

    public void testAuthenticateWithoutPath() throws Exception {
        String serviceName = "service";
        RepositoryTransportAuthenticationProvider repositoryTransportAuthenticationProvider = new RepositoryTransportAuthenticationProvider(serviceName);

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

    public void testAuthenticateWithPathAndNoPrivilege() throws Exception {
        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

    @Test
    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);
        when(authenticatedSession.hasPermission(path, privilege)).thenReturn(true);
        when(repo.loginService(serviceName, null)).thenReturn(authenticatedSession);
View Full Code Here

    @Test
    public void testAuthenticationWithNullAuthenticableAndContext() throws Exception {
        UserCredentialsTransportAuthenticationProvider authenticationHandler = new UserCredentialsTransportAuthenticationProvider(
                "foo", "bar");
        Executor authenticable = null;
        TransportAuthenticationContext context = null;
        try {
            authenticationHandler.authenticate(authenticable, context);
            fail("could not authenticate a null authenticable");
        } catch (Exception e) {
            // expected to fail
View Full Code Here

    @Test
    public void testAuthenticationWithAuthenticableAndNullContext() throws Exception {
        UserCredentialsTransportAuthenticationProvider authenticationHandler = new UserCredentialsTransportAuthenticationProvider(
                "foo", "bar");
        Executor authenticable = Executor.newInstance();
        TransportAuthenticationContext context = null;
        try {
            authenticationHandler.authenticate(authenticable, context);
            fail("could not authenticate with a null context");
        } catch (Exception e) {
            // expected to fail
View Full Code Here

TOP

Related Classes of org.apache.sling.replication.transport.authentication.TransportAuthenticationContext

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.