• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java HttpAuthenticator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.jena.atlas.web.auth.HttpAuthenticator的典型用法代码示例。如果您正苦于以下问题:Java HttpAuthenticator类的具体用法?Java HttpAuthenticator怎么用?Java HttpAuthenticator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HttpAuthenticator类属于org.apache.jena.atlas.web.auth包,在下文中一共展示了HttpAuthenticator类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: prepareAuthentication

import org.apache.jena.atlas.web.auth.HttpAuthenticator; //导入依赖的package包/类
/**
 * Prepares an authenticator that may use simple authentication
 * 
 * @param username
 *            User name
 * @param password
 *            Password
 * @param preemptive
 *            Preemptive auth?
 * @param endpoints
 *            Endpoints to configure authentication for
 * @return Authenticator or null if insufficient information to authenticate
 */
public static HttpAuthenticator prepareAuthentication(String username, String password, boolean preemptive, String... endpoints) {
    if (username != null && password != null) {
        try {
            Map<URI, Pair<String, char[]>> logins = new HashMap<URI, Pair<String, char[]>>();
            for (String endpoint : endpoints) {
                if (endpoint == null)
                    continue;
                logins.put(new URI(endpoint), Pair.create(username, password.toCharArray()));
            }

            HttpAuthenticator authenticator = new ScopedAuthenticator(logins);
            if (preemptive) {
                authenticator = new PreemptiveBasicAuthenticator(authenticator);
            }
            return authenticator;
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException("Invalid Endpoint URL, unable to configure authentication: " + e.getMessage(),
                    e);
        }
    }
    return null;
}
 
开发者ID:rvesse,项目名称:sparql-query-bm,代码行数:36,代码来源:AuthUtils.java


示例2: readTriplesFromKs

import org.apache.jena.atlas.web.auth.HttpAuthenticator; //导入依赖的package包/类
public static ArrayList<Statement> readTriplesFromKs(String subjectUri, String sparqlQuery){

        ArrayList<Statement> triples = new ArrayList<Statement>();
        HttpAuthenticator authenticator = new SimpleAuthenticator(user, pass.toCharArray());
        try {
            qCount++;
            QueryExecution x = QueryExecutionFactory.sparqlService(serviceEndpoint, sparqlQuery, authenticator);
            ResultSet resultset = x.execSelect();
            while (resultset.hasNext()) {
                QuerySolution solution = resultset.nextSolution();
                String relString = solution.get("predicate").toString();
                RDFNode obj = solution.get("object");
                Model model = ModelFactory.createDefaultModel();
                Resource subj = model.createResource(subjectUri);
                Statement s = createStatement(subj, ResourceFactory.createProperty(relString), obj);
                triples.add(s);
            }
        } catch (Exception e) {
            //e.printStackTrace();
        }
        return triples;
    }
 
开发者ID:cltl,项目名称:EventCoreference,代码行数:23,代码来源:TrigKSTripleReader.java


示例3: readEventIdsFromKs

import org.apache.jena.atlas.web.auth.HttpAuthenticator; //导入依赖的package包/类
public static ArrayList<String> readEventIdsFromKs(String sparqlQuery)throws Exception {
    ArrayList<String> eventIds = new ArrayList<String>();
    //System.out.println("serviceEndpoint = " + serviceEndpoint);
    //System.out.println("sparqlQuery = " + sparqlQuery);
    //System.out.println("user = " + user);
    //System.out.println("pass = " + pass);
    HttpAuthenticator authenticator = new SimpleAuthenticator(user, pass.toCharArray());

    QueryExecution x = QueryExecutionFactory.sparqlService(serviceEndpoint, sparqlQuery, authenticator);
    ResultSet resultset = x.execSelect();
    while (resultset.hasNext()) {
        QuerySolution solution = resultset.nextSolution();
        //System.out.println("solution.toString() = " + solution.toString());
        //( ?event = <http://www.newsreader-project.eu/data/Dasym-Pilot/425819_relink_dominant.naf#ev24> )
        String currentEvent = solution.get("event").toString();
        //System.out.println("currentEvent = " + currentEvent);
        //http://www.newsreader-project.eu/data/Dasym-Pilot/425819_relink_dominant.naf#ev24
        if (!eventIds.contains(currentEvent)) {
            eventIds.add(currentEvent);
        }
    }
    return eventIds;
}
 
开发者ID:cltl,项目名称:EventCoreference,代码行数:24,代码来源:TrigKSTripleReader.java


示例4: inferIdentityRelations

import org.apache.jena.atlas.web.auth.HttpAuthenticator; //导入依赖的package包/类
private static void inferIdentityRelations(String sparqlQuery, boolean matchILI, boolean matchLemma, boolean matchMultiple, int iliSize, Node eventId, DatasetGraph g) {
    if (matchILI || matchLemma) {
        sparqlQuery += "GROUP BY ?ev";
    }
    HttpAuthenticator authenticator = new SimpleAuthenticator(user, pass.toCharArray());
    QueryExecution x = QueryExecutionFactory.sparqlService(serviceEndpoint, sparqlQuery, authenticator);
    ResultSet resultset = x.execSelect();
    int threshold;
    while (resultset.hasNext()) {
        QuerySolution solution = resultset.nextSolution();
        if (matchILI || matchLemma) {
            if (matchILI)
                threshold = conceptMatchThreshold;
            else
                threshold=phraseMatchThreshold;

            if (matchMultiple) {
                //System.out.println(solution);
                if (checkIliLemmaThreshold(iliSize, solution.get("conceptcount").asLiteral().getInt(), solution.get("myconceptcount").asLiteral().getInt(), threshold)) {
                    insertIdentity(g, eventId, solution.get("ev").asNode());
                }
            } else {
                if (checkIliLemmaThreshold(1, solution.get("conceptcount").asLiteral().getInt(), 1, threshold)) {
                    insertIdentity(g, eventId, solution.get("ev").asNode());
                }
            }
        } else {
            insertIdentity(g, eventId, solution.get("ev").asNode());
        }
    }
}
 
开发者ID:newsreader,项目名称:StreamEventCoreference,代码行数:32,代码来源:ProcessEventObjectsStream.java


示例5: inferMultitimesIdentityRelations

import org.apache.jena.atlas.web.auth.HttpAuthenticator; //导入依赖的package包/类
private static ArrayList<Node> inferMultitimesIdentityRelations (String sparqlQuery, boolean matchILI, boolean matchLemma, boolean matchMultiple, int iliSize, String eventId) {
    if (matchILI || matchLemma) {
        sparqlQuery += "GROUP BY ?ev";
    }
    HttpAuthenticator authenticator = new SimpleAuthenticator(user, pass.toCharArray());
    QueryExecution x = QueryExecutionFactory.sparqlService(serviceEndpoint, sparqlQuery, authenticator);
    ResultSet resultset = x.execSelect();
    int threshold;
    ArrayList<Node> rslt = new ArrayList<Node>();
    while (resultset.hasNext()) {
        QuerySolution solution = resultset.nextSolution();
        if (matchILI || matchLemma) {
            if (matchILI)
                threshold = conceptMatchThreshold;
            else
                threshold=phraseMatchThreshold;

            if (matchMultiple) {
                //System.out.println(solution);
                if (checkIliLemmaThreshold(iliSize, solution.get("conceptcount").asLiteral().getInt(), solution.get("myconceptcount").asLiteral().getInt(), threshold)) {
                    rslt.add(solution.get("ev").asNode());
                }
            } else {
                if (checkIliLemmaThreshold(1, solution.get("conceptcount").asLiteral().getInt(), 1, threshold)) {
                    rslt.add(solution.get("ev").asNode());
                }
            }
        } else {
            rslt.add(solution.get("ev").asNode());
        }
    }
    return rslt;
}
 
开发者ID:newsreader,项目名称:StreamEventCoreference,代码行数:34,代码来源:ProcessEventObjectsStream.java


示例6: prepareAuthenticator

import org.apache.jena.atlas.web.auth.HttpAuthenticator; //导入依赖的package包/类
/**
 * Prepares an authenticator that may use simple/form based authentication
 * 
 * @param username
 *            User name
 * @param password
 *            Password
 * @param preemptive
 *            Preemptive auth?
 * @param formUrl
 *            Form login URL
 * @param formUserField
 *            Form user field
 * @param formPwdField
 *            Form password field
 * @param endpoints
 *            Endpoints to configure authentication for
 * @return Authenticator or null if insufficient information to authenticate
 */
public static HttpAuthenticator prepareAuthenticator(String username, String password, boolean preemptive, String formUrl,
        String formUserField, String formPwdField, String... endpoints) {
    if (username != null && password != null) {
        if (formUrl != null) {
            // Configure forms auth
            if (formUserField == null)
                formUserField = ApacheModAuthFormLogin.USER_FIELD;
            if (formPwdField == null)
                formPwdField = ApacheModAuthFormLogin.PASSWORD_FIELD;

            FormLogin login = new FormLogin(formUrl, formUserField, formPwdField, username, password.toCharArray());
            try {
                Map<URI, FormLogin> logins = new HashMap<URI, FormLogin>();
                for (String endpoint : endpoints) {
                    if (endpoint == null)
                        continue;
                    logins.put(new URI(endpoint), login);
                }
                return new FormsAuthenticator(logins);
            } catch (URISyntaxException e) {
                throw new IllegalArgumentException("Invalid Endpoint URL, unable to configure form based authentication: "
                        + e.getMessage(), e);
            }
        } else {
            // Use standard HTTP authentication
            return prepareAuthentication(username, password, preemptive, endpoints);
        }
    }

    // Insufficient options to configure authentication
    return null;
}
 
开发者ID:rvesse,项目名称:sparql-query-bm,代码行数:52,代码来源:AuthUtils.java


示例7: apply

import org.apache.jena.atlas.web.auth.HttpAuthenticator; //导入依赖的package包/类
@Override
public void apply(AbstractHttpClient client, HttpContext httpContext, URI target) {
    // Pick and apply an authenticator at random
    int id = this.rand.nextInt(this.authenticators.size());

    HttpAuthenticator authenticator = this.authenticators.get(id);
    if (authenticator == null) {
        logger.info("Picked authenticator " + id + " which does no authentication");
        return;
    }
    logger.info("Picked authenticator " + id + " which is " + authenticator.toString());
    authenticator.apply(client, httpContext, target);
}
 
开发者ID:rvesse,项目名称:sparql-query-bm,代码行数:14,代码来源:RandomAuthenticatorPool.java


示例8: getAuthenticator

import org.apache.jena.atlas.web.auth.HttpAuthenticator; //导入依赖的package包/类
@Override
public HttpAuthenticator getAuthenticator() {
    return this.authenticator;
}
 
开发者ID:rvesse,项目名称:sparql-query-bm,代码行数:5,代码来源:OptionsImpl.java


示例9: setAuthenticator

import org.apache.jena.atlas.web.auth.HttpAuthenticator; //导入依赖的package包/类
@Override
public void setAuthenticator(HttpAuthenticator authenticator) {
    this.authenticator = authenticator;
}
 
开发者ID:rvesse,项目名称:sparql-query-bm,代码行数:5,代码来源:OptionsImpl.java


示例10: invalidate

import org.apache.jena.atlas.web.auth.HttpAuthenticator; //导入依赖的package包/类
@Override
public void invalidate() {
    for (HttpAuthenticator authenticator : this.authenticators) {
        authenticator.invalidate();
    }
}
 
开发者ID:rvesse,项目名称:sparql-query-bm,代码行数:7,代码来源:RandomAuthenticatorPool.java


示例11: getAuthenticator

import org.apache.jena.atlas.web.auth.HttpAuthenticator; //导入依赖的package包/类
/**
 * Gets the HTTP authenticator in use
 * 
 * @return HTTP authenticator
 */
public abstract HttpAuthenticator getAuthenticator();
 
开发者ID:rvesse,项目名称:sparql-query-bm,代码行数:7,代码来源:Options.java


示例12: setAuthenticator

import org.apache.jena.atlas.web.auth.HttpAuthenticator; //导入依赖的package包/类
/**
 * Sets the HTTP authenticator used
 * 
 * @param authenticator
 *            HTTP authenticator
 */
public abstract void setAuthenticator(HttpAuthenticator authenticator);
 
开发者ID:rvesse,项目名称:sparql-query-bm,代码行数:8,代码来源:Options.java


示例13: RandomAuthenticatorPool

import org.apache.jena.atlas.web.auth.HttpAuthenticator; //导入依赖的package包/类
/**
 * Creates a new authenticator
 * 
 * @param authenticators
 *            Pool of authenticators where each represents a possible
 *            authentication method and/or set of credentials
 */
public RandomAuthenticatorPool(Collection<HttpAuthenticator> authenticators) {
    this.authenticators.addAll(authenticators);
}
 
开发者ID:rvesse,项目名称:sparql-query-bm,代码行数:11,代码来源:RandomAuthenticatorPool.java



注:本文中的org.apache.jena.atlas.web.auth.HttpAuthenticator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WritableCellFeatures类代码示例发布时间:2022-05-22
下一篇:
Java OrderByLink类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap