コード例 #1
0
 @Test
 public void testEmptyConfig() {
   System.setProperty(GatewayConfigImpl.GATEWAY_HOME_VAR, getHomeDirName("conf-empty/conf/empty"));
   GatewayConfig config = new GatewayConfigImpl();
   assertThat(config.getGatewayPort(), is(8888));
   // assertThat( config.getShiroConfigFile(), is( "shiro.ini") );
 }
コード例 #2
0
 @Test
 public void testDefaultDeploymentDir() {
   String homeDirName = getHomeDirName("conf-site/conf/gateway-site.xml");
   System.setProperty(GatewayConfigImpl.GATEWAY_HOME_VAR, homeDirName);
   System.setProperty(GatewayConfigImpl.GATEWAY_DATA_HOME_VAR, homeDirName);
   GatewayConfig config = new GatewayConfigImpl();
   assertThat(config.getGatewayDeploymentDir(), is(homeDirName + File.separator + "deployments"));
 }
コード例 #3
0
 @Test
 public void testForUpdatedDeploymentDir() {
   String homeDirName = getHomeDirName("conf-demo/conf/gateway-site.xml");
   System.setProperty(GatewayConfigImpl.GATEWAY_HOME_VAR, homeDirName);
   System.setProperty(GatewayConfigImpl.GATEWAY_DATA_HOME_VAR, homeDirName);
   GatewayConfig config = new GatewayConfigImpl();
   assertTrue(("target/test").equalsIgnoreCase(config.getGatewayDeploymentDir()));
 }
コード例 #4
0
 @Test
 public void testForDataDirSetAsConfiguration() {
   String homeDirName = getHomeDirName("conf-demo/conf/gateway-site.xml");
   System.setProperty(GatewayConfigImpl.GATEWAY_HOME_VAR, homeDirName);
   System.clearProperty(GatewayConfigImpl.GATEWAY_DATA_HOME_VAR);
   GatewayConfig config = new GatewayConfigImpl();
   assertTrue(("target/testDataDir").equalsIgnoreCase(config.getGatewayDataDir()));
 }
コード例 #5
0
 @Test
 public void testDemoConfig() {
   System.setProperty(
       GatewayConfigImpl.GATEWAY_HOME_VAR, getHomeDirName("conf-demo/conf/gateway-default.xml"));
   GatewayConfig config = new GatewayConfigImpl();
   assertThat(config.getGatewayPort(), is(8888));
   assertTrue(config.getExcludedSSLProtocols().get(0).equals("SSLv3"));
   // assertThat( config.getShiroConfigFile(), is( "full-shiro.ini") );
 }
コード例 #6
0
 @Test
 public void testForDefaultDataDir() {
   String homeDirName = getHomeDirName("conf-site/conf/gateway-site.xml");
   System.setProperty(GatewayConfigImpl.GATEWAY_HOME_VAR, homeDirName);
   System.clearProperty(GatewayConfigImpl.GATEWAY_DATA_HOME_VAR);
   GatewayConfig config = new GatewayConfigImpl();
   assertTrue(
       (homeDirName + File.separator + "data").equalsIgnoreCase(config.getGatewayDataDir()));
 }
コード例 #7
0
 @Test
 public void testFullConfig() {
   System.setProperty(
       GatewayConfigImpl.GATEWAY_HOME_VAR, getHomeDirName("conf-full/conf/gateway-default.xml"));
   GatewayConfig config = new GatewayConfigImpl();
   assertThat(config.getGatewayPort(), is(7777));
   assertThat(config.isClientAuthNeeded(), is(false));
   assertNull("ssl.exclude.protocols should be null.", config.getExcludedSSLProtocols());
   // assertThat( config.getShiroConfigFile(), is( "full-shiro.ini") );
 }
コード例 #8
0
 @Test
 public void testStacksServicesDir() {
   System.clearProperty(GatewayConfigImpl.GATEWAY_HOME_VAR);
   GatewayConfig config = new GatewayConfigImpl();
   assertThat(config.getGatewayServicesDir(), Matchers.endsWith("data/services"));
   String homeDirName = getHomeDirName("conf-demo/conf/gateway-site.xml");
   System.setProperty(GatewayConfigImpl.GATEWAY_HOME_VAR, homeDirName);
   config = new GatewayConfigImpl();
   assertEquals("target/test", config.getGatewayServicesDir());
 }
コード例 #9
0
 /**
  * When data dir is set at both system property and configuration level , then system property
  * value should be considered
  */
 @Test
 public void testDataDirSetAsBothSystemPropertyAndConfig() {
   String homeDirName = getHomeDirName("conf-demo/conf/gateway-site.xml");
   System.setProperty(GatewayConfigImpl.GATEWAY_HOME_VAR, homeDirName);
   System.setProperty(
       GatewayConfigImpl.GATEWAY_DATA_HOME_VAR,
       homeDirName + File.separator + "DataDirSystemProperty");
   GatewayConfig config = new GatewayConfigImpl();
   assertTrue(
       (homeDirName + File.separator + "DataDirSystemProperty")
           .equalsIgnoreCase(config.getGatewayDataDir()));
 }
コード例 #10
0
ファイル: JettySSLService.java プロジェクト: raapadma/knox
  @Override
  public void init(GatewayConfig config, Map<String, String> options)
      throws ServiceLifecycleException {
    // set any JSSE or security related system properties
    System.setProperty(EPHEMERAL_DH_KEY_SIZE_PROPERTY, config.getEphemeralDHKeySize());
    try {
      if (!ks.isCredentialStoreForClusterAvailable(GATEWAY_CREDENTIAL_STORE_NAME)) {
        log.creatingCredentialStoreForGateway();
        ks.createCredentialStoreForCluster(GATEWAY_CREDENTIAL_STORE_NAME);
        // LET'S NOT GENERATE A DIFFERENT KEY PASSPHRASE BY DEFAULT ANYMORE
        // IF A DEPLOYMENT WANTS TO CHANGE THE KEY PASSPHRASE TO MAKE IT MORE SECURE THEN
        // THEY CAN ADD THE ALIAS EXPLICITLY WITH THE CLI
        // as.generateAliasForCluster(GATEWAY_CREDENTIAL_STORE_NAME, GATEWAY_IDENTITY_PASSPHRASE);
      } else {
        log.credentialStoreForGatewayFoundNotCreating();
      }
    } catch (KeystoreServiceException e) {
      throw new ServiceLifecycleException(
          "Keystore was not loaded properly - the provided (or persisted) master secret may not match the password for the keystore.",
          e);
    }

    try {
      if (!ks.isKeystoreForGatewayAvailable()) {
        log.creatingKeyStoreForGateway();
        ks.createKeystoreForGateway();
        char[] passphrase = null;
        try {
          passphrase = as.getGatewayIdentityPassphrase();
        } catch (AliasServiceException e) {
          throw new ServiceLifecycleException(
              "Error accessing credential store for the gateway.", e);
        }
        if (passphrase == null) {
          passphrase = ms.getMasterSecret();
        }
        ks.addSelfSignedCertForGateway("gateway-identity", passphrase);
      } else {
        log.keyStoreForGatewayFoundNotCreating();
      }
      logAndValidateCertificate();
    } catch (KeystoreServiceException e) {
      throw new ServiceLifecycleException(
          "Keystore was not loaded properly - the provided (or persisted) master secret may not match the password for the keystore.",
          e);
    }

    keystoreType = config.getKeystoreType();
    sslExcludeProtocols = config.getExcludedSSLProtocols();
    clientAuthNeeded = config.isClientAuthNeeded();
    truststorePath = config.getTruststorePath();
    trustAllCerts = config.getTrustAllCerts();
    trustStoreType = config.getTruststoreType();
  }
コード例 #11
0
 @Test
 public void testSiteConfig() {
   System.setProperty(
       GatewayConfigImpl.GATEWAY_HOME_VAR, getHomeDirName("conf-site/conf/gateway-site.xml"));
   GatewayConfig config = new GatewayConfigImpl();
   assertThat(config.getGatewayPort(), is(5555));
   assertThat(config.isClientAuthNeeded(), is(true));
   assertThat(config.getTruststorePath(), is("./gateway-trust.jks"));
   assertThat(config.getTruststoreType(), is("PKCS12"));
   assertThat(config.getKeystoreType(), is("JKS"));
 }
コード例 #12
0
 public String getUrl(String serviceRole, boolean real) {
   String url;
   String localHostName = getLocalHostName();
   Service service = services.get(serviceRole);
   if (useGateway && !real) {
     url =
         "http://"
             + localHostName
             + ":"
             + gateway.getAddresses()[0].getPort()
             + "/"
             + config.getGatewayPath()
             + service.gatewayPath;
   } else if (service.mock) {
     url = "http://" + localHostName + ":" + service.server.getPort();
   } else {
     url = service.realUrl.toASCIIString();
   }
   return url;
 }
コード例 #13
0
  public void cleanup() throws Exception {
    gateway.stop();
    FileUtils.deleteQuietly(new File(config.getGatewayTopologyDir()));
    FileUtils.deleteQuietly(new File(config.getGatewayConfDir()));
    FileUtils.deleteQuietly(new File(config.getGatewaySecurityDir()));
    FileUtils.deleteQuietly(new File(config.getGatewayDeploymentDir()));
    FileUtils.deleteQuietly(new File(config.getGatewayDataDir()));
    FileUtils.deleteQuietly(new File(config.getGatewayServicesDir()));

    for (Service service : services.values()) {
      service.server.stop();
    }
    services.clear();

    ldap.stop(true);
  }
コード例 #14
0
  public static void setupGateway() throws Exception {

    File targetDir = new File(System.getProperty("user.dir"), "target");
    File gatewayDir = new File(targetDir, "gateway-home-" + UUID.randomUUID());
    gatewayDir.mkdirs();

    GatewayTestConfig testConfig = new GatewayTestConfig();
    config = testConfig;
    testConfig.setGatewayHomeDir(gatewayDir.getAbsolutePath());

    File topoDir = new File(testConfig.getGatewayTopologyDir());
    topoDir.mkdirs();

    File deployDir = new File(testConfig.getGatewayDeploymentDir());
    deployDir.mkdirs();

    File descriptor = new File(topoDir, "test-cluster.xml");
    FileOutputStream stream = new FileOutputStream(descriptor);
    createTopology().toStream(stream);
    stream.close();

    DefaultGatewayServices srvcs = new DefaultGatewayServices();
    Map<String, String> options = new HashMap<String, String>();
    options.put("persist-master", "false");
    options.put("master", "password");
    try {
      srvcs.init(testConfig, options);
    } catch (ServiceLifecycleException e) {
      e.printStackTrace(); // I18N not required.
    }

    gateway = GatewayServer.startGateway(testConfig, srvcs);
    MatcherAssert.assertThat("Failed to start gateway.", gateway, notNullValue());

    LOG.info("Gateway port = " + gateway.getAddresses()[0].getPort());

    gatewayUrl =
        "http://localhost:" + gateway.getAddresses()[0].getPort() + "/" + config.getGatewayPath();
    clusterUrl = gatewayUrl + "/test-cluster";
  }
コード例 #15
0
 @Test
 public void testDefaultAppRedirectPath() {
   GatewayConfig config = new GatewayConfigImpl();
   assertThat(config.getDefaultAppRedirectPath(), is("/gateway/sandbox"));
 }
コード例 #16
0
 @Test
 public void testDefaultTopologyName() {
   GatewayConfig config = new GatewayConfigImpl();
   assertThat(config.getDefaultTopologyName(), is("sandbox"));
 }