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


Java Server.stop方法代码示例

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


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

示例1: testExternalDelegationTokenSecretManager

import org.mortbay.jetty.Server; //导入方法依赖的package包/类
@Test
public void testExternalDelegationTokenSecretManager() throws Exception {
  DummyDelegationTokenSecretManager secretMgr
      = new DummyDelegationTokenSecretManager();
  final Server jetty = createJettyServer();
  Context context = new Context();
  context.setContextPath("/foo");
  jetty.setHandler(context);
  context.addFilter(new FilterHolder(AFilter.class), "/*", 0);
  context.addServlet(new ServletHolder(PingServlet.class), "/bar");
  try {
    secretMgr.startThreads();
    context.setAttribute(DelegationTokenAuthenticationFilter.
            DELEGATION_TOKEN_SECRET_MANAGER_ATTR, secretMgr);
    jetty.start();
    URL authURL = new URL(getJettyURL() + "/foo/bar?authenticated=foo");

    DelegationTokenAuthenticatedURL.Token token =
        new DelegationTokenAuthenticatedURL.Token();
    DelegationTokenAuthenticatedURL aUrl =
        new DelegationTokenAuthenticatedURL();

    aUrl.getDelegationToken(authURL, token, FOO_USER);
    Assert.assertNotNull(token.getDelegationToken());
    Assert.assertEquals(new Text("fooKind"),
        token.getDelegationToken().getKind());

  } finally {
    jetty.stop();
    secretMgr.stopThreads();
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:33,代码来源:TestWebDelegationToken.java

示例2: testFallbackToPseudoDelegationTokenAuthenticator

import org.mortbay.jetty.Server; //导入方法依赖的package包/类
@Test
public void testFallbackToPseudoDelegationTokenAuthenticator()
    throws Exception {
  final Server jetty = createJettyServer();
  Context context = new Context();
  context.setContextPath("/foo");
  jetty.setHandler(context);
  context.addFilter(new FilterHolder(PseudoDTAFilter.class), "/*", 0);
  context.addServlet(new ServletHolder(UserServlet.class), "/bar");

  try {
    jetty.start();
    final URL url = new URL(getJettyURL() + "/foo/bar");

    UserGroupInformation ugi = UserGroupInformation.createRemoteUser(FOO_USER);
    ugi.doAs(new PrivilegedExceptionAction<Void>() {
      @Override
      public Void run() throws Exception {
        DelegationTokenAuthenticatedURL.Token token =
            new DelegationTokenAuthenticatedURL.Token();
        DelegationTokenAuthenticatedURL aUrl =
            new DelegationTokenAuthenticatedURL();
        HttpURLConnection conn = aUrl.openConnection(url, token);
        Assert.assertEquals(HttpURLConnection.HTTP_OK,
            conn.getResponseCode());
        List<String> ret = IOUtils.readLines(conn.getInputStream());
        Assert.assertEquals(1, ret.size());
        Assert.assertEquals(FOO_USER, ret.get(0));

        aUrl.getDelegationToken(url, token, FOO_USER);
        Assert.assertNotNull(token.getDelegationToken());
        Assert.assertEquals(new Text("token-kind"),
            token.getDelegationToken().getKind());
        return null;
      }
    });
  } finally {
    jetty.stop();
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:41,代码来源:TestWebDelegationToken.java

示例3: testIpaddressCheck

import org.mortbay.jetty.Server; //导入方法依赖的package包/类
@Test
public void testIpaddressCheck() throws Exception {
  final Server jetty = createJettyServer();
  ((AbstractConnector)jetty.getConnectors()[0]).setResolveNames(true);
  Context context = new Context();
  context.setContextPath("/foo");
  jetty.setHandler(context);

  context.addFilter(new FilterHolder(IpAddressBasedPseudoDTAFilter.class), "/*", 0);
  context.addServlet(new ServletHolder(UGIServlet.class), "/bar");

  try {
    jetty.start();
    final URL url = new URL(getJettyURL() + "/foo/bar");

    UserGroupInformation ugi = UserGroupInformation.createRemoteUser(FOO_USER);
    ugi.doAs(new PrivilegedExceptionAction<Void>() {
      @Override
      public Void run() throws Exception {
        DelegationTokenAuthenticatedURL.Token token =
                new DelegationTokenAuthenticatedURL.Token();
        DelegationTokenAuthenticatedURL aUrl =
                new DelegationTokenAuthenticatedURL();

        // user ok-user via proxyuser foo
        HttpURLConnection conn = aUrl.openConnection(url, token, OK_USER);
        Assert.assertEquals(HttpURLConnection.HTTP_OK,
                conn.getResponseCode());
        List<String> ret = IOUtils.readLines(conn.getInputStream());
        Assert.assertEquals(1, ret.size());
        Assert.assertEquals("realugi=" + FOO_USER +":remoteuser=" + OK_USER +
                ":ugi=" + OK_USER, ret.get(0));

        return null;
      }
    });
  } finally {
    jetty.stop();
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:41,代码来源:TestWebDelegationToken.java

示例4: main

import org.mortbay.jetty.Server; //导入方法依赖的package包/类
public static void main(String[] args) {
    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(1000 * 60 * 60);
    connector.setSoLingerTime(-1);
    connector.setPort(9080);
    server.setConnectors(new Connector[]{connector});

    WebAppContext context = new WebAppContext();
    context.setServer(server);
    context.setContextPath("/");

    ProtectionDomain protectionDomain = Main.class.getProtectionDomain();
    URL location = protectionDomain.getCodeSource().getLocation();
    context.setWar(location.toExternalForm());

    server.addHandler(context);
    try {
        server.start();
        System.in.read();
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(100);
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:30,代码来源:WebLauncher.java

示例5: testDelegationTokenAuthenticatedURLWithNoDT

import org.mortbay.jetty.Server; //导入方法依赖的package包/类
private void testDelegationTokenAuthenticatedURLWithNoDT(
    Class<? extends Filter> filterClass)  throws Exception {
  final Server jetty = createJettyServer();
  Context context = new Context();
  context.setContextPath("/foo");
  jetty.setHandler(context);
  context.addFilter(new FilterHolder(filterClass), "/*", 0);
  context.addServlet(new ServletHolder(UserServlet.class), "/bar");

  try {
    jetty.start();
    final URL url = new URL(getJettyURL() + "/foo/bar");

    UserGroupInformation ugi = UserGroupInformation.createRemoteUser(FOO_USER);
    ugi.doAs(new PrivilegedExceptionAction<Void>() {
      @Override
      public Void run() throws Exception {
        DelegationTokenAuthenticatedURL.Token token =
            new DelegationTokenAuthenticatedURL.Token();
        DelegationTokenAuthenticatedURL aUrl =
            new DelegationTokenAuthenticatedURL();
        HttpURLConnection conn = aUrl.openConnection(url, token);
        Assert.assertEquals(HttpURLConnection.HTTP_OK,
            conn.getResponseCode());
        List<String> ret = IOUtils.readLines(conn.getInputStream());
        Assert.assertEquals(1, ret.size());
        Assert.assertEquals(FOO_USER, ret.get(0));

        try {
          aUrl.getDelegationToken(url, token, FOO_USER);
          Assert.fail();
        } catch (AuthenticationException ex) {
          Assert.assertTrue(ex.getMessage().contains(
              "delegation token operation"));
        }
        return null;
      }
    });
  } finally {
    jetty.stop();
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:43,代码来源:TestWebDelegationToken.java

示例6: testHttpUGI

import org.mortbay.jetty.Server; //导入方法依赖的package包/类
@Test
public void testHttpUGI() throws Exception {
  final Server jetty = createJettyServer();
  Context context = new Context();
  context.setContextPath("/foo");
  jetty.setHandler(context);
  context.addFilter(new FilterHolder(PseudoDTAFilter.class), "/*", 0);
  context.addServlet(new ServletHolder(UGIServlet.class), "/bar");

  try {
    jetty.start();
    final URL url = new URL(getJettyURL() + "/foo/bar");

    UserGroupInformation ugi = UserGroupInformation.createRemoteUser(FOO_USER);
    ugi.doAs(new PrivilegedExceptionAction<Void>() {
      @Override
      public Void run() throws Exception {
        DelegationTokenAuthenticatedURL.Token token =
            new DelegationTokenAuthenticatedURL.Token();
        DelegationTokenAuthenticatedURL aUrl =
            new DelegationTokenAuthenticatedURL();

        // user foo
        HttpURLConnection conn = aUrl.openConnection(url, token);
        Assert.assertEquals(HttpURLConnection.HTTP_OK,
            conn.getResponseCode());
        List<String> ret = IOUtils.readLines(conn.getInputStream());
        Assert.assertEquals(1, ret.size());
        Assert.assertEquals("remoteuser=" + FOO_USER+ ":ugi=" + FOO_USER, 
            ret.get(0));

        // user ok-user via proxyuser foo
        conn = aUrl.openConnection(url, token, OK_USER);
        Assert.assertEquals(HttpURLConnection.HTTP_OK,
            conn.getResponseCode());
        ret = IOUtils.readLines(conn.getInputStream());
        Assert.assertEquals(1, ret.size());
        Assert.assertEquals("realugi=" + FOO_USER +":remoteuser=" + OK_USER + 
                ":ugi=" + OK_USER, ret.get(0));

        return null;
      }
    });
  } finally {
    jetty.stop();
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:48,代码来源:TestWebDelegationToken.java


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