Package com.hp.hpl.jena.sparql.engine.http

Examples of com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP


        qe.execAsk();
    }

    @Test
    public void query_with_auth_08() throws URISyntaxException {
        QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(serviceQuery, "ASK { }");

        // Auth credentials for valid user with correct password and scoped to
        // correct URI
        ScopedAuthenticator authenticator = new ScopedAuthenticator(new URI(serviceQuery), "allowed", "password".toCharArray());
        qe.setAuthenticator(authenticator);
        Assert.assertTrue(qe.execAsk());
    }
View Full Code Here


        Assert.assertTrue(qe.execAsk());
    }

    @Test
    public void query_with_auth_09() throws URISyntaxException {
        QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(serviceQuery, "ASK { }");

        // Auth credentials for valid user with correct password using
        // pre-emptive auth
        ScopedAuthenticator authenticator = new ScopedAuthenticator(new URI(serviceQuery), "allowed", "password".toCharArray());
        qe.setAuthenticator(new PreemptiveBasicAuthenticator(authenticator));
        Assert.assertTrue(qe.execAsk());
    }
View Full Code Here

    @Test
    public void query_with_auth_10() {
        Context ctx = ARQ.getContext();
        try {
            QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(serviceQuery, "ASK { }");

            // Auth credentials for valid user with correct password and scoped
            // to correct URI
            // Provided via Service Context and its associated authenticator
            Map<String, Context> serviceContext = new HashMap<String, Context>();
            Context authContext = new Context();
            authContext.put(Service.queryAuthUser, "allowed");
            authContext.put(Service.queryAuthPwd, "password");
            serviceContext.put(serviceQuery, authContext);
            ctx.put(Service.serviceContext, serviceContext);

            qe.setAuthenticator(new ServiceAuthenticator());
            Assert.assertTrue(qe.execAsk());
        } finally {
            ctx.remove(Service.serviceContext);
        }
    }
View Full Code Here

   
    @Test
    public void query_with_auth_11() {
        Context ctx = ARQ.getContext();
        try {
            QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(serviceQuery, "ASK { }");

            // Auth credentials for valid user with correct password and scoped
            // to base URI of the actual service URL
            // Provided via Service Context and its associated authenticator
            Map<String, Context> serviceContext = new HashMap<String, Context>();
            Context authContext = new Context();
            authContext.put(Service.queryAuthUser, "allowed");
            authContext.put(Service.queryAuthPwd, "password");
            serviceContext.put(urlRoot, authContext);
            ctx.put(Service.serviceContext, serviceContext);

            qe.setAuthenticator(new ServiceAuthenticator());
            Assert.assertTrue(qe.execAsk());
        } finally {
            ctx.remove(Service.serviceContext);
        }
    }
View Full Code Here

   
    @Test
    public void query_with_auth_12() {
        ARQ.getContext().remove(Service.serviceContext);

        QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(serviceQuery, "ASK { }");

        // Auth credentials for valid user with correct password
        // Use service authenticator with fallback credentials.
        qe.setAuthenticator(new ServiceAuthenticator("allowed", "password".toCharArray()));
        Assert.assertTrue(qe.execAsk());
     }
View Full Code Here

        Assert.assertTrue(qe.execAsk());
     }
   
    @Test
    public void query_with_auth_13() throws URISyntaxException {
        QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(serviceQuery, "ASK { }");

        // Auth credentials for valid user with correct password and scoped to
        // base URI of the actual service URL
        ScopedAuthenticator authenticator = new ScopedAuthenticator(new URI(urlRoot), "allowed", "password".toCharArray());
        qe.setAuthenticator(authenticator);
        Assert.assertTrue(qe.execAsk());
    }
View Full Code Here

        Assert.assertTrue(qe.execAsk());
    }
   
    @Test
    public void query_with_auth_14() throws URISyntaxException {
        QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(serviceQuery, "ASK { }");

        // Auth credentials for valid user with correct password and scoped to
        // base URI of the actual service URL
        ScopedAuthenticator authenticator = new ScopedAuthenticator(new URI("http://localhost:" + port), "allowed", "password".toCharArray());
        qe.setAuthenticator(authenticator);
        Assert.assertTrue(qe.execAsk());
    }
View Full Code Here

    {
        checkNotNull(service, "URL for service is null") ;
        //checkNotNull(defaultGraphURIs, "List of default graph URIs is null") ;
        //checkNotNull(namedGraphURIs, "List of named graph URIs is null") ;
        checkArg(query) ;
        QueryEngineHTTP qe = createServiceRequest(service, query, authenticator) ;
        if ( defaultGraphURIs != null )
            qe.setDefaultGraphURIs(defaultGraphURIs) ;
        if ( namedGraphURIs != null )
            qe.setNamedGraphURIs(namedGraphURIs) ;
        return qe ;
    }
View Full Code Here

    static public QueryExecution sparqlService(String service, Query query, String defaultGraph, HttpAuthenticator authenticator)
    {
        checkNotNull(service, "URL for service is null") ;
        //checkNotNull(defaultGraph, "IRI for default graph is null") ;
        checkArg(query) ;
        QueryEngineHTTP qe = createServiceRequest(service, query, authenticator) ;
        qe.addDefaultGraph(defaultGraph) ;
        return qe ;
    }
View Full Code Here

     * @param authenticator HTTP Authenticator
     * @return Remote Query Engine
     */
    static public QueryEngineHTTP createServiceRequest(String service, Query query, HttpAuthenticator authenticator)
    {
        QueryEngineHTTP qe = new QueryEngineHTTP(service, query, authenticator) ;
        return qe ;
    }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP

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.