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


Java HttpPrincipal类代码示例

本文整理汇总了Java中com.sun.net.httpserver.HttpPrincipal的典型用法代码示例。如果您正苦于以下问题:Java HttpPrincipal类的具体用法?Java HttpPrincipal怎么用?Java HttpPrincipal使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: handle

import com.sun.net.httpserver.HttpPrincipal; //导入依赖的package包/类
@Override
public void handle (HttpExchange t)
    throws IOException
{
    InputStream is = t.getRequestBody();
    Headers map = t.getRequestHeaders();
    Headers rmap = t.getResponseHeaders();
    while (is.read() != -1);
    is.close();
    t.sendResponseHeaders(200, -1);
    HttpPrincipal p = t.getPrincipal();
    if (!p.getUsername().equals("fred")) {
        error = true;
    }
    if (!p.getRealm().equals("[email protected]")) {
        error = true;
    }
    t.close();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:Deadlock.java

示例2: handle

import com.sun.net.httpserver.HttpPrincipal; //导入依赖的package包/类
public void handle (HttpExchange t) throws IOException {
    InputStream is = t.getRequestBody();
    while (is.read () != -1) ;
    is.close();
    t.sendResponseHeaders(200, -1);
    HttpPrincipal p = t.getPrincipal();
    if (!p.getUsername().equals(USERNAME)) {
        error = true;
    }
    if (!p.getRealm().equals(REALM)) {
        error = true;
    }
    t.close();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:15,代码来源:BasicLongCredentials.java

示例3: userName

import com.sun.net.httpserver.HttpPrincipal; //导入依赖的package包/类
public static String userName(HttpExchange t) {
	HttpPrincipal p = t.getPrincipal();
	if (p == null) {
		return "";
	}
	return p.getUsername();
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:8,代码来源:RemoteUtil.java

示例4: testGetPrincipal

import com.sun.net.httpserver.HttpPrincipal; //导入依赖的package包/类
@Test
public void testGetPrincipal() {
    // setup
    HttpPrincipal expectedResult = mock(HttpPrincipal.class);
    when(this.httpExchange.getPrincipal()).thenReturn(expectedResult);

    // act
    HttpPrincipal result = this.httpExchangeImpl.getPrincipal();

    // assert
    assertEquals(expectedResult, result);
}
 
开发者ID:barnyard,项目名称:pi,代码行数:13,代码来源:HttpExchangeImplTest.java

示例5: getPrincipal

import com.sun.net.httpserver.HttpPrincipal; //导入依赖的package包/类
@Override
public HttpPrincipal getPrincipal()
{
	return _principal;
}
 
开发者ID:iMartinezMateu,项目名称:openbravo-pos,代码行数:6,代码来源:JettyHttpExchange.java

示例6: setPrincipal

import com.sun.net.httpserver.HttpPrincipal; //导入依赖的package包/类
public void setPrincipal(HttpPrincipal principal)
{
	this._principal = principal;
}
 
开发者ID:iMartinezMateu,项目名称:openbravo-pos,代码行数:5,代码来源:JettyHttpExchange.java

示例7: getPrincipal

import com.sun.net.httpserver.HttpPrincipal; //导入依赖的package包/类
@Override
public HttpPrincipal getPrincipal() {
    return null;
}
 
开发者ID:rockem,项目名称:blink-java,代码行数:5,代码来源:HttpExchangeStub.java

示例8: before

import com.sun.net.httpserver.HttpPrincipal; //导入依赖的package包/类
@Override
protected void before(HttpExchange exchange) {
    ((MockHttpExchange) exchange)
            .setPrincipal(new HttpPrincipal(PRINCIPAL_NAME, "my realm"));
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:6,代码来源:UserIT.java

示例9: getPrincipal

import com.sun.net.httpserver.HttpPrincipal; //导入依赖的package包/类
@Override
public HttpPrincipal getPrincipal() {
    throw new RuntimeException("Glowroot should not call this directly as it may fail");
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:5,代码来源:UserIT.java

示例10: getPrincipal

import com.sun.net.httpserver.HttpPrincipal; //导入依赖的package包/类
@Override
public HttpPrincipal getPrincipal() {
    return principal;
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:5,代码来源:MockHttpExchange.java

示例11: setPrincipal

import com.sun.net.httpserver.HttpPrincipal; //导入依赖的package包/类
void setPrincipal(HttpPrincipal principal) {
    this.principal = principal;
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:4,代码来源:MockHttpExchange.java

示例12: getPrincipal

import com.sun.net.httpserver.HttpPrincipal; //导入依赖的package包/类
@Override
public HttpPrincipal getPrincipal() {
    return this.httpExchange.getPrincipal();
}
 
开发者ID:barnyard,项目名称:pi,代码行数:5,代码来源:HttpExchangeImpl.java

示例13: getPrincipal

import com.sun.net.httpserver.HttpPrincipal; //导入依赖的package包/类
@Override
public HttpPrincipal getPrincipal() {
    // TODO Auto-generated method stub
    return null;
}
 
开发者ID:barnyard,项目名称:pi,代码行数:6,代码来源:RestQueryFilterTest.java

示例14: validateUser

import com.sun.net.httpserver.HttpPrincipal; //导入依赖的package包/类
private HttpPrincipal validateUser(HttpExchange httpExchange, Map<String, String> challengeParameters) {
    String realm = challengeParameters.get("realm");
    String username = challengeParameters.get("username");

    if (realm == null || realm.length() == 0 || username == null || username.length() == 0) {
        return null;
    }
    String password = passwords.getProperty(username);
    if (password == null) {
    	return null;
    }
    try {
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        md5.update(username.getBytes());
        md5.update(COL);
        md5.update(realm.getBytes());
        md5.update(COL);
        md5.update(password.getBytes());

        byte[] ha1 = Utils.toHexBytes(md5.digest());

        md5.update(httpExchange.getRequestMethod().getBytes());
        md5.update(COL);
        md5.update(challengeParameters.get("uri").getBytes());

        byte[] ha2 = Utils.toHexBytes(md5.digest());

        md5.update(ha1);
        md5.update(COL);
        md5.update(challengeParameters.get("nonce").getBytes());
        md5.update(COL);
        md5.update(ha2);

        byte[] expectedResponse = Utils.toHexBytes(md5.digest());
        byte[] actualResponse = challengeParameters.get("response").getBytes();

        if (MessageDigest.isEqual(expectedResponse, actualResponse)) {
            return new HttpPrincipal(username, realm);
        }

    } catch (NoSuchAlgorithmException e) {
        throw new IllegalStateException("No MD5? Should not be possible", e);
    }

    return null;
}
 
开发者ID:NitorCreations,项目名称:javaone-shanghai-2013-javafx-presentation,代码行数:47,代码来源:DigestAuthenticator.java


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