当前位置: 首页>>代码示例>>Java>>正文


Java B64Code.encode方法代码示例

本文整理汇总了Java中org.eclipse.jetty.util.B64Code.encode方法的典型用法代码示例。如果您正苦于以下问题:Java B64Code.encode方法的具体用法?Java B64Code.encode怎么用?Java B64Code.encode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jetty.util.B64Code的用法示例。


在下文中一共展示了B64Code.encode方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getWeakETag

import org.eclipse.jetty.util.B64Code; //导入方法依赖的package包/类
public String getWeakETag()
{
    try
    {
        StringBuilder b = new StringBuilder(32);
        b.append("W/\"");
        
        String name=getName();
        int length=name.length();
        long lhash=0;
        for (int i=0; i<length;i++)
            lhash=31*lhash+name.charAt(i);
        
        B64Code.encode(lastModified()^lhash,b);
        B64Code.encode(length()^lhash,b);
        b.append('"');
        return b.toString();
    } 
    catch (IOException e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:itead,项目名称:IoTgo_Android_App,代码行数:24,代码来源:Resource.java

示例2: HostedGraphiteSender

import org.eclipse.jetty.util.B64Code; //导入方法依赖的package包/类
public HostedGraphiteSender(String apiKey) {

        source = Util.source();

        //  Create an https capable http client.
        SslContextFactory sslContextFactory = new SslContextFactory();
        httpClient = new HttpClient(sslContextFactory);

        HttpField agent = new HttpField("User-Agent", "app-server-metrics/" +
                (getClass().getPackage().getImplementationVersion() != null ? getClass().getPackage().getImplementationVersion() : "development"));

        httpClient.setUserAgentField(agent);

        try {
            httpClient.start();
        } catch (Exception e) {
            log.error(e);
        }

        this.authHeader = "Basic " + B64Code.encode(apiKey);
    }
 
开发者ID:GeoNet,项目名称:app-server-metrics,代码行数:22,代码来源:HostedGraphiteSender.java

示例3: hashKey

import org.eclipse.jetty.util.B64Code; //导入方法依赖的package包/类
public static String hashKey(String key)
{
    try
    {
        MessageDigest md = MessageDigest.getInstance("SHA1");
        md.update(key.getBytes("UTF-8"));
        md.update(MAGIC);
        return new String(B64Code.encode(md.digest()));
    }
    catch (Exception e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:itead,项目名称:IoTgo_Android_App,代码行数:15,代码来源:WebSocketConnectionRFC6455.java

示例4: getUrl

import org.eclipse.jetty.util.B64Code; //导入方法依赖的package包/类
/**
 * Simple logic to perform a authenticated GET request
 *
 * @param url
 * @param timeout
 * @return
 */
private String getUrl(String url, int timeout) {
    url += (url.contains("?") ? "&" : "?") + "timestamp=" + System.currentTimeMillis();
    startHttpClient(client);

    Request request = client.newRequest(url).timeout(TIMEOUT, TimeUnit.MILLISECONDS);

    AutelisConfiguration configuration = getConfig().as(AutelisConfiguration.class);
    String user = configuration.user;
    String password = configuration.password;

    String basicAuthentication = "Basic " + B64Code.encode(user + ":" + password, StringUtil.__ISO_8859_1);

    request.header(HttpHeader.AUTHORIZATION, basicAuthentication);

    try {
        ContentResponse response = request.send();
        int statusCode = response.getStatus();
        if (statusCode != HttpStatus.OK_200) {
            logger.debug("Method failed: {}", response.getStatus() + " " + response.getReason());
            return null;
        }
        return response.getContentAsString();
    } catch (Exception e) {
        logger.debug("Could not make http connection", e);
    }
    return null;
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:35,代码来源:AutelisHandler.java

示例5: setupServer

import org.eclipse.jetty.util.B64Code; //导入方法依赖的package包/类
@BeforeClass
    public static void setupServer() throws Exception {
        // start a local HTTP proxy using Jetty server
        server = new Server();

/*
        final SSLContextParameters contextParameters = new SSLContextParameters();
        final SslContextFactory sslContextFactory = new SslContextFactory();
        sslContextFactory.setSslContext(contextParameters.createSSLContext());
        ServerConnector connector = new ServerConnector(server, sslContextFactory);
*/
        ServerConnector connector = new ServerConnector(server);

        connector.setHost(HTTP_PROXY_HOST);
        server.addConnector(connector);

        final String authenticationString = "Basic "
            + B64Code.encode(HTTP_PROXY_USER_NAME + ":" + HTTP_PROXY_PASSWORD, StringUtil.__ISO_8859_1);

        ConnectHandler connectHandler = new ConnectHandler() {
            @Override
            protected boolean handleAuthentication(HttpServletRequest request, HttpServletResponse response, String address) {
                // validate proxy-authentication header
                final String header = request.getHeader(PROXY_AUTHORIZATION.toString());
                if (!authenticationString.equals(header)) {
                    LOG.warn("Missing header " + PROXY_AUTHORIZATION);
                    // ask for authentication header
                    response.setHeader(PROXY_AUTHENTICATE.toString(), String.format("Basic realm=\"%s\"", HTTP_PROXY_REALM));
                    return false;
                }
                LOG.info("Request contains required header " + PROXY_AUTHORIZATION);
                return true;
            }
        };
        server.setHandler(connectHandler);

        LOG.info("Starting proxy server...");
        server.start();

        httpProxyPort = connector.getLocalPort();
        LOG.info("Started proxy server on port {}", httpProxyPort);
    }
 
开发者ID:HydAu,项目名称:Camel,代码行数:43,代码来源:HttpProxyMojoIntegrationTest.java

示例6: toBasicAuth

import org.eclipse.jetty.util.B64Code; //导入方法依赖的package包/类
public String toBasicAuth() {
  return "Basic " + B64Code.encode(_user + ":" + _password);
}
 
开发者ID:h2oai,项目名称:h2o-3,代码行数:4,代码来源:JettyProxy.java

示例7: getUsernameAndPassEncoded

import org.eclipse.jetty.util.B64Code; //导入方法依赖的package包/类
protected static String getUsernameAndPassEncoded() {
    return "Basic " + B64Code.encode("cash1981" + ":" + "foo", StringUtil.__ISO_8859_1);
}
 
开发者ID:cash1981,项目名称:civilization-boardgame-rest,代码行数:4,代码来源:AbstractCivilizationTest.java

示例8: getAdminEncoded

import org.eclipse.jetty.util.B64Code; //导入方法依赖的package包/类
protected static String getAdminEncoded() {
    return "Basic " + B64Code.encode("admin" + ":" + "foo", StringUtil.__ISO_8859_1);
}
 
开发者ID:cash1981,项目名称:civilization-boardgame-rest,代码行数:4,代码来源:AbstractCivilizationTest.java

示例9: getItchiEncoded

import org.eclipse.jetty.util.B64Code; //导入方法依赖的package包/类
protected static String getItchiEncoded() {
    return "Basic " + B64Code.encode("Itchi" + ":" + "foo", StringUtil.__ISO_8859_1);
}
 
开发者ID:cash1981,项目名称:civilization-boardgame-rest,代码行数:4,代码来源:AbstractCivilizationTest.java

示例10: getValue

import org.eclipse.jetty.util.B64Code; //导入方法依赖的package包/类
private final String getValue(String user, String password) {
    String encoding = StringUtil.__ISO_8859_1;
    String value = "Basic " + B64Code.encode(user + ":" + password, encoding);
    return value;
}
 
开发者ID:uli-heller,项目名称:uli-mini-tools,代码行数:6,代码来源:BasicProxyAuthentication.java


注:本文中的org.eclipse.jetty.util.B64Code.encode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。