Java 类com.sun.net.httpserver.HttpPrincipal 实例源码

项目:jdk8u-jdk    文件:BasicLongCredentials.java   
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();
}
项目:openjdk-jdk10    文件:BasicLongCredentials.java   
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();
}
项目:openjdk9    文件:BasicLongCredentials.java   
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();
}
项目:DigitalMediaServer    文件:RemoteUtil.java   
public static String userName(HttpExchange t) {
    HttpPrincipal p = t.getPrincipal();
    if (p == null) {
        return "";
    }
    return p.getUsername();
}
项目:jdk8u_jdk    文件:BasicLongCredentials.java   
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();
}
项目:lookaside_java-1.8.0-openjdk    文件:BasicLongCredentials.java   
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();
}
项目:infobip-open-jdk-8    文件:BasicLongCredentials.java   
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();
}
项目:jdk8u-dev-jdk    文件:BasicLongCredentials.java   
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();
}
项目:jdk7-jdk    文件:BasicLongCredentials.java   
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();
}
项目:openjdk-source-code-learn    文件:BasicLongCredentials.java   
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();
}
项目:OLD-OpenJDK8    文件:BasicLongCredentials.java   
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();
}
项目:JAVA_UNIT    文件:BasicLongCredentials.java   
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();
}
项目:openjdk-jdk7u-jdk    文件:BasicLongCredentials.java   
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();
}
项目:openjdk-icedtea7    文件:BasicLongCredentials.java   
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();
}
项目:pi    文件:HttpExchangeImplTest.java   
@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);
}
项目:openbravo-pos    文件:JettyHttpExchange.java   
@Override
public HttpPrincipal getPrincipal()
{
    return _principal;
}
项目:openbravo-pos    文件:JettyHttpExchange.java   
public void setPrincipal(HttpPrincipal principal)
{
    this._principal = principal;
}
项目:blink-java    文件:HttpExchangeStub.java   
@Override
public HttpPrincipal getPrincipal() {
    return null;
}
项目:glowroot    文件:UserIT.java   
@Override
protected void before(HttpExchange exchange) {
    ((MockHttpExchange) exchange)
            .setPrincipal(new HttpPrincipal(PRINCIPAL_NAME, "my realm"));
}
项目:glowroot    文件:UserIT.java   
@Override
public HttpPrincipal getPrincipal() {
    throw new RuntimeException("Glowroot should not call this directly as it may fail");
}
项目:glowroot    文件:MockHttpExchange.java   
@Override
public HttpPrincipal getPrincipal() {
    return principal;
}
项目:glowroot    文件:MockHttpExchange.java   
void setPrincipal(HttpPrincipal principal) {
    this.principal = principal;
}
项目:OpenbravoPOS    文件:JettyHttpExchange.java   
@Override
public HttpPrincipal getPrincipal()
{
    return _principal;
}
项目:OpenbravoPOS    文件:JettyHttpExchange.java   
public void setPrincipal(HttpPrincipal principal)
{
    this._principal = principal;
}
项目:pi    文件:HttpExchangeImpl.java   
@Override
public HttpPrincipal getPrincipal() {
    return this.httpExchange.getPrincipal();
}
项目:pi    文件:RestQueryFilterTest.java   
@Override
public HttpPrincipal getPrincipal() {
    // TODO Auto-generated method stub
    return null;
}
项目:javaone-shanghai-2013-javafx-presentation    文件:DigestAuthenticator.java   
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;
}