text:
package com.streamsets.pipeline.lib.remote;

import com.streamsets.pipeline.api.Stage;
import com.streamsets.pipeline.lib.tls.KeyStoreType;
import com.streamsets.pipeline.stage.connection.remote.FTPSDataChannelProtectionLevel;
import com.streamsets.pipeline.stage.connection.remote.FTPSMode;
import com.streamsets.pipeline.stage.connection.remote.FTPSTrustStore;
import org.junit.Assert;
import org.junit.Test;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.security.KeyStore;
import java.security.Security;
import java.security.cert.Certificate;
import java.util.List;

public class TestFTPRemoteConnectorFTPS extends TestFTPRemoteConnector {

  @Override
  protected void setupServer() throws Exception {
    setupFTPSServer(path, KeyStoreType.JKS, null, false);
  }

  @Override
  protected String getScheme() {
    return "ftps";
  }

  @Test
  public void testImplicit() throws Exception {
    // We've been using EXPLICIT in all other tests; here we make sure IMPLICIT works
    super.after();
    setupFTPSServer(path, KeyStoreType.JKS, null, true);

    RemoteConnector connector = getConnector(getBean(
        FTPSMode.IMPLICIT,
        FTPSDataChannelProtectionLevel.PRIVATE,
        null,
        null,
        null,
        FTPSTrustStore.ALLOW_ALL,
        null,
        null,
        null
    ));

    List<Stage.ConfigIssue> issues = initWithNoIssues(connector);
    Assert.assertEquals(0, issues.size());
    verifyConnection(connector);

    connector.close();
  }

  @Test
  public void testProtectionLevelClear() throws Exception {
    RemoteConnector connector = getConnector(getBean(
        FTPSMode.EXPLICIT,
        FTPSDataChannelProtectionLevel.CLEAR,
        null,
        null,
        null,
        FTPSTrustStore.ALLOW_ALL,
        null,
        null,
        null
    ));

    List<Stage.ConfigIssue> issues = initWithNoIssues(connector);
    Assert.assertEquals(0, issues.size());
    verifyConnection(connector);
    Assert.assertFalse(
        ftpServer.getListener("default").getActiveSessions().iterator().next().getDataConnection().isSecure());

    connector.close();
  }

  @Test
  public void testProtectionLevelPrivate() throws Exception {
    RemoteConnector connector = getConnector(getBean(
        FTPSMode.EXPLICIT,
        FTPSDataChannelProtectionLevel.PRIVATE,
        null,
        null,
        null,
        FTPSTrustStore.ALLOW_ALL,
        null,
        null,
        null
    ));

    List<Stage.ConfigIssue> issues = initWithNoIssues(connector);
    Assert.assertEquals(0, issues.size());
    verifyConnection(connector);
    Assert.assertTrue(
        ftpServer.getListener("default").getActiveSessions().iterator().next().getDataConnection().isSecure());

    connector.close();
  }

  @Test
  public void testClientCertEmptyFile() throws Exception {
    super.after();
    setupFTPSServer(path, KeyStoreType.JKS, KeyStoreType.JKS, false);

    RemoteConnector connector = getConnector(getBean(
        FTPSMode.EXPLICIT,
        FTPSDataChannelProtectionLevel.PRIVATE,
        "",
        KeyStoreType.JKS,
        KEYSTORE_PASSWORD,
        FTPSTrustStore.ALLOW_ALL,
        null,
        null,
        null
    ));

    List<Stage.ConfigIssue> issues = initAndCheckIssue(
        connector,
        "CREDENTIALS",
        "conf.remoteConfig.ftpsClientCertKeystoreFile",
        Errors.REMOTE_12
    );
    Assert.assertEquals(1, issues.size());

    connector.close();
  }

  @Test
  public void testClientCertWrongPassword() throws Exception {
    super.after();
    setupFTPSServer(path, KeyStoreType.JKS, KeyStoreType.JKS, false);

    RemoteConnector connector = getConnector(getBean(
        FTPSMode.EXPLICIT,
        FTPSDataChannelProtectionLevel.PRIVATE,
        clientCertificateKeystore.getAbsolutePath(),
        KeyStoreType.JKS,
        KEYSTORE_PASSWORD + "wrong",
        FTPSTrustStore.ALLOW_ALL,
        null,
        null,
        null
    ));

    List<Stage.ConfigIssue> issues = initAndCheckIssue(
        connector,
        "CREDENTIALS",
        "conf.remoteConfig.ftpsClientCertKeystoreFile",
        Errors.REMOTE_14,
        "key",
        clientCertificateKeystore.getAbsolutePath(),
        "Keystore was tampered with, or password was incorrect",
        null
    );
    Assert.assertEquals(1, issues.size());

    connector.close();
  }

  @Test
  public void testClientCertFileNotExist() throws Exception {
    super.after();
    setupFTPSServer(path, KeyStoreType.JKS, KeyStoreType.JKS, false);

    String badFile = clientCertificateKeystore.getAbsolutePath() + "bad";
    RemoteConnector connector = getConnector(getBean(
        FTPSMode.EXPLICIT,
        FTPSDataChannelProtectionLevel.PRIVATE,
        badFile,
        KeyStoreType.JKS,
        KEYSTORE_PASSWORD,
        FTPSTrustStore.ALLOW_ALL,
        null,
        null,
        null
    ));

    List<Stage.ConfigIssue> issues = initAndCheckIssue(
        connector,
        "CREDENTIALS",
        "conf.remoteConfig.ftpsClientCertKeystoreFile",
        Errors.REMOTE_14,
        "key",
        badFile,
        badFile + " (No such file or directory)",
        null
    );
    Assert.assertEquals(1, issues.size());

    connector.close();
  }

  @Test
  public void testClientCertKeyManagerFail() throws Exception {
    super.after();
    setupFTPSServer(path, KeyStoreType.JKS, KeyStoreType.JKS, false);
    ruinClientKeystoreToBreakKeyManager();

    RemoteConnector connector = getConnector(getBean(
        FTPSMode.EXPLICIT,
        FTPSDataChannelProtectionLevel.PRIVATE,
        clientCertificateKeystore.getAbsolutePath(),
        KeyStoreType.JKS,
        KEYSTORE_PASSWORD,
        FTPSTrustStore.ALLOW_ALL,
        null,
        null,
        null
    ));

    List<Stage.ConfigIssue> issues = initAndCheckIssue(
        connector,
        "CREDENTIALS",
        "conf.remoteConfig.ftpsClientCertKeystoreFile",
        Errors.REMOTE_15,
        "key",
        "Cannot recover key",
        null
    );
    Assert.assertEquals(1, issues.size());

    connector.close();
  }

  @Test
  public void testClientCertJKS() throws Exception {
    super.after();
    setupFTPSServer(path, KeyStoreType.JKS, KeyStoreType.JKS, false);

    RemoteConnector connector = getConnector(getBean(
        FTPSMode.EXPLICIT,
        FTPSDataChannelProtectionLevel.PRIVATE,
        clientCertificateKeystore.getAbsolutePath(),
        KeyStoreType.JKS,
        KEYSTORE_PASSWORD,
        FTPSTrustStore.ALLOW_ALL,
        null,
        null,
        null
    ));

    List<Stage.ConfigIssue> issues = initWithNoIssues(connector);
    Assert.assertEquals(0, issues.size());
    verifyConnection(connector);

    connector.close();
  }

  @Test
  public void testClientCertPKC12() throws Exception {
    super.after();
    setupFTPSServer(path, KeyStoreType.JKS, KeyStoreType.PKCS12, false);

    RemoteConnector connector = getConnector(getBean(
        FTPSMode.EXPLICIT,
        FTPSDataChannelProtectionLevel.PRIVATE,
        clientCertificateKeystore.getAbsolutePath(),
        KeyStoreType.PKCS12,
        KEYSTORE_PASSWORD,
        FTPSTrustStore.ALLOW_ALL,
        null,
        null,
        null
    ));

    List<Stage.ConfigIssue> issues = initWithNoIssues(connector);
    Assert.assertEquals(0, issues.size());
    verifyConnection(connector);

    connector.close();
  }

  @Test
  public void testClientCertReject() throws Exception {
    super.after();
    setupFTPSServer(path, KeyStoreType.JKS, KeyStoreType.JKS, false);

    RemoteConnector connector = getConnector(getBean(
        FTPSMode.EXPLICIT,
        FTPSDataChannelProtectionLevel.PRIVATE,
        // Client cert not in Server's Truststore
        generateCertificateKeystore(KeyStoreType.JKS).getAbsolutePath(),
        KeyStoreType.JKS,
        KEYSTORE_PASSWORD,
        FTPSTrustStore.ALLOW_ALL,
        null,
        null,
        null
    ));

    List<Stage.ConfigIssue> issues = initAndCheckIssue(
        connector,
        "SFTP/FTP/FTPS",
        "conf.remoteConfig.remoteAddress",
        Errors.REMOTE_11,
        getScheme() + "://localhost:" + port + "/",
        "Could not connect to FTP server on \"localhost\".",
        null
    );
    Assert.assertEquals(1, issues.size());

    connector.close();
  }

  @Test
  public void testTrustStoreEmptyFile() throws Exception {
    RemoteConnector connector = getConnector(getBean(
        FTPSMode.EXPLICIT,
        FTPSDataChannelProtectionLevel.PRIVATE,
        null,
        null,
        null,
        FTPSTrustStore.FILE,
        "",
        KeyStoreType.JKS,
        KEYSTORE_PASSWORD
    ));

    List<Stage.ConfigIssue> issues = initAndCheckIssue(
        connector,
        "CREDENTIALS",
        "conf.remoteConfig.ftpsTruststoreFile",
        Errors.REMOTE_13
    );
    Assert.assertEquals(1, issues.size());

    connector.close();
  }

  @Test
  public void testTrustStoreWrongPassword() throws Exception {
    RemoteConnector connector = getConnector(getBean(
        FTPSMode.EXPLICIT,
        FTPSDataChannelProtectionLevel.PRIVATE,
        null,
        null,
        null,
        FTPSTrustStore.FILE,
        serverCertificateKeystore.getAbsolutePath(),
        KeyStoreType.JKS,
        KEYSTORE_PASSWORD + "wrong"
    ));

    List<Stage.ConfigIssue> issues = initAndCheckIssue(
        connector,
        "CREDENTIALS",
        "conf.remoteConfig.ftpsTruststoreFile",
        Errors.REMOTE_14,
        "trust",
        serverCertificateKeystore.getAbsolutePath(),
        "Keystore was tampered with, or password was incorrect",
        null
    );
    Assert.assertEquals(1, issues.size());

    connector.close();
  }

  @Test
  public void testTrustStoreFileNotExist() throws Exception {
    String badFile = serverCertificateKeystore.getAbsolutePath() + "bad";

    RemoteConnector connector = getConnector(getBean(
        FTPSMode.EXPLICIT,
        FTPSDataChannelProtectionLevel.PRIVATE,
        null,
        null,
        null,
        FTPSTrustStore.FILE,
        badFile,
        KeyStoreType.JKS,
        KEYSTORE_PASSWORD
    ));

    List<Stage.ConfigIssue> issues = initAndCheckIssue(
        connector,
        "CREDENTIALS",
        "conf.remoteConfig.ftpsTruststoreFile",
        Errors.REMOTE_14,
        "trust",
        badFile,
        badFile + " (No such file or directory)",
        null
    );
    Assert.assertEquals(1, issues.size());

    connector.close();
  }

  @Test
  public void testTrustStoreTrustManagerFail() throws Exception {
    String originalValue = Security.getProperty("ssl.TrustManagerFactory.algorithm");
    try {
      // This'll cause the TrustManager to fail
      Security.setProperty("ssl.TrustManagerFactory.algorithm", "not-exist");

      RemoteConnector connector = getConnector(getBean(
          FTPSMode.EXPLICIT,
          FTPSDataChannelProtectionLevel.PRIVATE,
          null,
          null,
          null,
          FTPSTrustStore.FILE,
          serverCertificateKeystore.getAbsolutePath(),
          KeyStoreType.JKS,
          KEYSTORE_PASSWORD
      ));

      List<Stage.ConfigIssue> issues = initAndCheckIssue(
          connector,
          "CREDENTIALS",
          "conf.remoteConfig.ftpsTruststoreFile",
          Errors.REMOTE_15,
          "trust",
          "not-exist TrustManagerFactory not available",
          null
      );
      Assert.assertEquals(1, issues.size());

      connector.close();
    } finally {
      if (originalValue == null) {
        System.clearProperty("ssl.TrustManagerFactory.algorithm");
      } else {
        Security.setProperty("ssl.TrustManagerFactory.algorithm", originalValue);
      }
    }
  }

  @Test
  public void testTrustStoreJVM() throws Exception {
    RemoteConnector connector = getConnector(getBean(
        FTPSMode.EXPLICIT,
        FTPSDataChannelProtectionLevel.PRIVATE,
        null,
        null,
        null,
        FTPSTrustStore.JVM_DEFAULT,
        null,
        null,
        null
    ));

    // We can't connect successfully because the JVM truststore doesn't trust the FTP Server
    List<Stage.ConfigIssue> issues = initAndCheckIssue(
        connector,
        "SFTP/FTP/FTPS",
        "conf.remoteConfig.remoteAddress",
        Errors.REMOTE_11,
        getScheme() + "://localhost:" + port + "/",
        "Could not connect to FTP server on \"localhost\".",
        null
    );
    Assert.assertEquals(1, issues.size());

    connector.close();
  }

  @Test
  public void testTrustStoreFileJKS() throws Exception {
    RemoteConnector connector = getConnector(getBean(
        FTPSMode.EXPLICIT,
        FTPSDataChannelProtectionLevel.PRIVATE,
        null,
        null,
        null,
        FTPSTrustStore.FILE,
        serverCertificateKeystore.getAbsolutePath(),
        KeyStoreType.JKS,
        KEYSTORE_PASSWORD
    ));

    List<Stage.ConfigIssue> issues = initWithNoIssues(connector);
    Assert.assertEquals(0, issues.size());
    verifyConnection(connector);

    connector.close();
  }

  @Test
  public void testTrustStoreFilePKC12() throws Exception {
    super.after();
    setupFTPSServer(path, KeyStoreType.PKCS12, null, false);

    RemoteConnector connector = getConnector(getBean(
        FTPSMode.EXPLICIT,
        FTPSDataChannelProtectionLevel.PRIVATE,
        null,
        null,
        null,
        FTPSTrustStore.FILE,
        serverCertificateKeystore.getAbsolutePath(),
        KeyStoreType.PKCS12,
        KEYSTORE_PASSWORD
    ));

    List<Stage.ConfigIssue> issues = initWithNoIssues(connector);
    Assert.assertEquals(0, issues.size());
    verifyConnection(connector);

    connector.close();
  }

  @Test
  public void testTrustStoreFileReject() throws Exception {
    RemoteConnector connector = getConnector(getBean(
        FTPSMode.EXPLICIT,
        FTPSDataChannelProtectionLevel.PRIVATE,
        null,
        null,
        null,
        FTPSTrustStore.FILE,
        // Server cert not in Client's Truststore
        generateCertificateKeystore(KeyStoreType.JKS).getAbsolutePath(),
        KeyStoreType.JKS,
        KEYSTORE_PASSWORD
    ));

    List<Stage.ConfigIssue> issues = initAndCheckIssue(
        connector,
        "SFTP/FTP/FTPS",
        "conf.remoteConfig.remoteAddress",
        Errors.REMOTE_11,
        getScheme() + "://localhost:" + port + "/",
        "Could not connect to FTP server on \"localhost\".",
        null
    );
    Assert.assertEquals(1, issues.size());

    connector.close();
  }

  protected RemoteConfigBean getBean(
      FTPSMode mode,
      FTPSDataChannelProtectionLevel protLevel,
      String keystoreFile,
      KeyStoreType keystoreType,
      String keystorePassword,
      FTPSTrustStore truststoreProvider,
      String truststoreFile,
      KeyStoreType truststoreType,
      String truststorePassword
  ) {
    RemoteConfigBean configBean = getBean(
        getScheme() + "://localhost:" + port + "/",
        true,
        false,
        TESTUSER,
        TESTPASS,
        null,
        null,
        null,
        true,
        null
    );
    configBean.connection.ftpsMode = mode;
    configBean.connection.ftpsDataChannelProtectionLevel = protLevel;
    if (keystoreFile != null) {
      configBean.connection.credentials.useFTPSClientCert = true;
      configBean.ftpsClientCertKeystoreFile = keystoreFile;
      configBean.ftpsClientCertKeystoreType = keystoreType;
      configBean.ftpsClientCertKeystorePassword = () -> keystorePassword;
    } else {
      configBean.connection.credentials.useFTPSClientCert = false;
    }
    configBean.connection.credentials.ftpsTrustStoreProvider = truststoreProvider;
    if (truststoreProvider == FTPSTrustStore.FILE) {
      configBean.ftpsTruststoreFile = truststoreFile;
      configBean.ftpsTruststoreType = truststoreType;
      configBean.ftpsTruststorePassword = () -> truststorePassword;
    }
    return configBean;
  }

  private void ruinClientKeystoreToBreakKeyManager() throws Exception {
    KeyStore keyStore = KeyStore.getInstance(KeyStoreType.JKS.getJavaValue());
    try (InputStream fis = new FileInputStream(clientCertificateKeystore)) {
      keyStore.load(fis, KEYSTORE_PASSWORD.toCharArray());
    }
    // This changes the password for the first entry to be something else so the KeyManager will try the wrong password
    // Though we keep the keystore password itself intact
    String alias = keyStore.aliases().nextElement();
    keyStore.setKeyEntry(
        alias,
        keyStore.getKey(alias, KEYSTORE_PASSWORD.toCharArray()),
        "something else".toCharArray(),
        new Certificate[]{keyStore.getCertificate(alias)}
    );
    try (FileOutputStream fos = new FileOutputStream(clientCertificateKeystore)) {
      keyStore.store(fos, KEYSTORE_PASSWORD.toCharArray());
    }
  }
}


text:
/**
 * @ngdoc overview
 * @name auth.user
 * @description
 * The `ddsApp.faq` module which provides:
 *
 * - {@link ...}
 * - {@link ...}
 *
 * @requires resource
 */

/**
 * @ngdoc service
 * @name ddsApp.faq:FAQ
 * @description
 * Angular resource for handling communication with the api/posts route
 */

/**
 * @ngdoc service
 * @name ddsApp.faq:FAQService
 * @description
 * Service with function for dealing with faqs
 */

(function () {
	'use strict';

	angular
		.module('ddsApp.faq')
		.factory('FAQ', FAQ)
		.service('FAQService', FAQService);

	/**
	 * @ngdoc function
	 * @name ddsApp.faq:FAQ
	 * @description
	 * User resource constructor
	 *
	 * @param {Service} $resource The resource service to use
	 * @returns {Service} {@link ...}
	 */

	FAQ.$inject = ['$resource', 'LIBRARYAPPAPIURL'];

	function FAQ($resource, LIBRARYAPPAPIURL) {
		// factory members
		var apiURL = LIBRARYAPPAPIURL + '/faqs/:faq_id';

		var methods = {
			update: {
				method: 'PUT',
				params: { faq_id : '@id' }
			},
			get: {
				method: 'GET',
				params: { faq_id : '@id' }
			},
			query: {
				method: "GET",
				isArray: true
			}
		};

		return $resource(apiURL, {}, methods);
	}

	/**
	 * @ngdoc function
	 * @name ddsApp.faq:FAQService
	 * @description
	 * FAQService constructor
	 * AngularJS will instantiate a singleton by calling "new" on this function
	 *
	 * @param {Service} FAQ The resource provided
	 * @returns {Service} {@link ...}
	 */

	FAQService.$inject = ['FAQ'];

	function FAQService(FAQ) {

		return {
			create: create,
			update: update,
			remove: remove
		};

		/**
		 * @ngdoc function
		 * @name create
		 * @methodOf ddsApp.faq:FAQService
		 * @description
		 * Save a new faq
		 *
		 * @param {Object} faq The postData to save
		 * @param {Function} [callback] A callback
		 * @returns {Promise} A promise
		 */
		function create(faq, callback) {
			var cb = callback || angular.noop;

			return FAQ.create(faq,
				function (faq) {
					return cb(faq);
				},
				function (err) {
					return cb(err);
				}).$promise;
		}

		/**
		 * @ngdoc function
		 * @name remove
		 * @methodOf ddsApp.faq:FAQService
		 * @description
		 * Remove a faq
		 *
		 * @param {Object} faq The postData to remove
		 * @param {Function} [callback] A callback
		 * @return {Promise} A promise
		 */
		function remove(faq, callback) {
			var cb = callback || angular.noop;

			return FAQ.remove({id: faq._id},
				function (faq) {
					return cb(faq);
				},
				function (err) {
					return cb(faq);
				}).$promise;
		}

		/**
		 * @ngdoc function
		 * @name update
		 * @methodOf ddsApp.faq:FAQService
		 * @description
		 * Update a faq
		 *
		 * @param {Object} faq The postData to update
		 * @param {Function} [callback] A callback
		 * @return {Promise} A promise
		 */
		function update(faq, callback) {
			var cb = callback || angular.noop;

			return FAQ.update(faq,
				function (faq) {
					return cb(faq);
				},
				function (err) {
					return cb(err);
				}).$promise;
		}
	}

})();

redpajama_set_name: RedPajamaGithub


text:
package org.ms123.common.docbook.xom.html5;

import nu.xom.*;

public class Footer extends Base {
	public Footer() {
		super("footer");
	}
}


text:
class EventEmailSubscriber < ApplicationRecord
  include Geocodeable

  scope :unconfirmed, -> { where(confirmed_at: nil) }
  scope :subscribed, (lambda do
    where.not(confirmed_at: nil)
         .where(unsubscribed_at: nil)
  end)
  scope :unsubscribed, -> { where.not(unsubscribed_at: nil) }

  before_create :generate_unsubscribe_token
  before_create :generate_confirmation_token
  before_create :generate_link_tracking_token

  after_commit :trigger_rebuild

  validates :email, :location, presence: true
  validates :email,
            :unsubscribe_token,
            :confirmation_token,
            :link_tracking_token,
            uniqueness: true

  geocode_attrs address: :location,
                latitude: :latitude,
                longitude: :longitude,
                res_address: :parsed_address,
                city: :parsed_city,
                state: :parsed_state,
                state_code: :parsed_state_code,
                postal_code: :parsed_postal_code,
                country: :parsed_country,
                country_code: :parsed_country_code

  def self.stats
    filtered = subscribed

    {
      cities: filtered.distinct.count(:parsed_city),
      countries: filtered.distinct.count(:parsed_country)
    }
  end

  def generate_unsubscribe_token
    self.unsubscribe_token = SecureRandom.hex
  end

  def generate_confirmation_token
    self.confirmation_token = SecureRandom.hex
  end

  def generate_link_tracking_token
    self.link_tracking_token = SecureRandom.hex
  end

  private

  def trigger_rebuild
    RebuildHackathonsSiteJob.perform_later
  end
end


text:
About

Blog

Contact


text:
package com.drew.metadata.heif;

import com.drew.metadata.TagDescriptor;

public class HeifDescriptor extends TagDescriptor<HeifDirectory>
{

    public HeifDescriptor(HeifDirectory directory)
    {
        super(directory);
    }

    @Override
    public String getDescription(int tagType)
    {
        switch (tagType) {
            case HeifDirectory.TAG_IMAGE_WIDTH:
            case HeifDirectory.TAG_IMAGE_HEIGHT:
                return getPixelDescription(tagType);
            default:
                return super.getDescription(tagType);
        }
    }

    public String getPixelDescription(int tagType)
    {
        return _directory.getString(tagType) + " pixels";
    }
}


text:
package cc.psdev.heywifi;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class BootCompleteReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
            AlarmManagerService ams = new AlarmManagerService(context);
            ams.registerAlarmManager();
        }
    }
}


text:
package com.sequenceiq.cloudbreak.reactor.handler.cluster;

import javax.inject.Inject;

import org.springframework.stereotype.Component;

import com.sequenceiq.cloudbreak.eventbus.Event;
import com.sequenceiq.cloudbreak.eventbus.EventBus;
import com.sequenceiq.cloudbreak.reactor.api.event.cluster.PrepareClusterTerminationRequest;
import com.sequenceiq.cloudbreak.reactor.api.event.cluster.PrepareClusterTerminationResult;
import com.sequenceiq.cloudbreak.service.cluster.ClusterApiConnectors;
import com.sequenceiq.cloudbreak.service.stack.StackService;
import com.sequenceiq.flow.event.EventSelectorUtil;
import com.sequenceiq.flow.reactor.api.handler.EventHandler;

@Component
public class PrepareClusterTerminationHandler implements EventHandler<PrepareClusterTerminationRequest> {

    @Inject
    private EventBus eventBus;

    @Inject
    private ClusterApiConnectors clusterApiConnectors;

    @Inject
    private StackService stackService;

    @Override
    public String selector() {
        return EventSelectorUtil.selector(PrepareClusterTerminationRequest.class);
    }

    @Override
    public void accept(Event<PrepareClusterTerminationRequest> event) {
        PrepareClusterTerminationResult result;
        try {
            clusterApiConnectors.getConnector(stackService.getByIdWithListsInTransaction(event.getData().getResourceId()))
                    .clusterSecurityService().prepareSecurity();
            result = new PrepareClusterTerminationResult(event.getData());
        } catch (Exception e) {
            result = new PrepareClusterTerminationResult(e.getMessage(), e, event.getData());
        }
        eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
    }
}


text:
title: I.WaitUntil
link: WaitUntil
---
Recommended method of waiting in tests. Conditional wait using anonymous functions that either return `true` / `false` or throw an `Exception` when the condition has not been met. Useful when content on the page is loaded dynamically or changes state during interactions.

If the condition has not been met, a timed wait will be executed before testing the condition again. The duration if this wait is set in `Settings.DefaultWaitUntilThreadSleep`.

The condition must succeed within the time set in `Settings.DefaultWaitUntilTimeout` or the test will fail.

Important Note: Most actions have implicit WaitUntil functionality built-in. Before adding, be sure your test needs it.

```csharp
// WaitUntil element exists
I.WaitUntil(() => I.Assert.Exists("#searchBar")));

// WaitUntil element has attribute 'data-loaded'
I.WaitUntil(() =>
    I.Find("#searchBar")()
        .Attributes
        .Get("data-loaded") == "true"
);
```
```vbnet
// TODO - Visual Basic Code Sample
```


text:
from LinkedList import LinkedList

def is_palindrome(ll):
    fast = slow = ll.head
    stack = []

    while fast and fast.next:
        stack.append(slow.value)
        slow = slow.next
        fast = fast.next.next

    if fast:
        slow = slow.next

    while slow:
        top = stack.pop()

        if top != slow.value:
            return False

        slow = slow.next

    return True

ll_true = LinkedList([1, 2, 3, 4, 5, 4, 3, 2, 1])
print(is_palindrome(ll_true))
ll_false = LinkedList([1, 2, 3, 4, 5, 6, 7, 8, 9])
print(is_palindrome(ll_false))


text:
<?php

require('staff.inc.php');
require_once(INCLUDE_DIR.'class.file.php');
$h=trim($_GET['h']);
//basic checks
if(!$h  || strlen($h)!=64  //32*2
        || !($file=AttachmentFile::lookup(substr($h,0,32))) //first 32 is the file hash.
        || strcasecmp($h, $file->getDownloadHash())) //next 32 is file id + session hash.
    Http::response(404, 'Unknown or invalid file');

if ($_GET['s'] && is_numeric($_GET['s']))
    $file->display($_GET['s']);
else
    $file->display();
?>


text:
bool ArduboyAudio::audio_enabled = false;

void ArduboyAudio::on()
{
  audio_enabled = true;
}

bool ArduboyAudio::enabled()
{
  return audio_enabled;
}

void ArduboyAudio::off()
{
  audio_enabled = false;
}

void ArduboyAudio::saveOnOff()
{
  EEPROM.write(EEPROM_AUDIO_ON_OFF, audio_enabled);
}

void ArduboyAudio::begin()
{
  if (EEPROM.read(EEPROM_AUDIO_ON_OFF))
    on();
}


text:
All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 2.4.10 - 2016-05-09

### Added

- Nothing.

### Deprecated

- Nothing.

### Removed

- Nothing.

### Fixed

- [#28](https://github.com/zendframework/zend-mail/pull/28) and
  [#87](https://github.com/zendframework/zend-mail/pull/87) fix header value
  validation when headers wrap using the sequence \r\n\t; prior to this release,
  such sequences incorrectly marked a header value invalid.

## 2.4.8 - 2015-09-10

### Added

- Nothing.

### Deprecated

- Nothing.

### Removed

- Nothing.

### Fixed

- [#26](https://github.com/zendframework/zend-mail/pull/26) fixes the
  `ContentType` header to properly handle parameters with encoded values.
- [#11](https://github.com/zendframework/zend-mail/pull/11) fixes the
  behavior of the `Sender` header, ensuring it can handle domains that do not
  contain a TLD, as well as addresses referencing mailboxes (no domain).
- [#24](https://github.com/zendframework/zend-mail/pull/24) fixes parsing of
  mail messages that contain an initial blank line (prior to the headers), a
  situation observed in particular with GMail.


text:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <!--

        Licensed to the Apache Software Foundation (ASF) under one or more
        contributor license agreements.  See the NOTICE file distributed with
        this work for additional information regarding copyright ownership.
        The ASF licenses this file to You under the Apache License, Version 2.0
        (the "License"); you may not use this file except in compliance with
        the License.  You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

        Unless required by applicable law or agreed to in writing, software
        distributed under the License is distributed on an "AS IS" BASIS,
        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        See the License for the specific language governing permissions and
        limitations under the License.
    -->

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.apache.karaf.diagnostic</groupId>
        <artifactId>diagnostic</artifactId>
        <version>3.0.0-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>org.apache.karaf.diagnostic.core</artifactId>
    <packaging>bundle</packaging>
    <name>Apache Karaf :: Diagnostic :: Core</name>
    <description>Core implementation using Karaf diagnostic using the diagnostic common services</description>

    <properties>
        <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.apache.karaf</groupId>
            <artifactId>org.osgi.core</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.compendium</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.karaf.features</groupId>
            <artifactId>org.apache.karaf.features.core</artifactId>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>${project.basedir}/src/main/resources</directory>
                <includes>
                    <include>**/*</include>
                </includes>
            </resource>
            <resource>
                <directory>${project.basedir}/src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/*.info</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <configuration>
                    <instructions>
                        <Export-Package>
                        	${project.artifactId},
                        	${project.artifactId}.common
                       	</Export-Package>
                        <Import-Package>
                            *
                        </Import-Package>
                        <Private-Package>
                            org.apache.karaf.diagnostic.core.internal
                        </Private-Package>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>


text:
namespace DataSourceControls.Countries
{
    using System;
    using System.Collections.Generic;

    public partial class Town
    {
        public System.Guid Id { get; set; }
        public string Name { get; set; }
        public long Population { get; set; }
        public System.Guid CountryId { get; set; }

        public virtual Country Country { get; set; }
    }
}


text:
<BroadcastMonitor>
  <updated>2015-08-05T15:02:15</updated>
  <stationName>Radio 6</stationName>
  <Current>
    <startTime>2015-08-05T15:02:15</startTime>
    <itemId>1000080540:1241536</itemId>
    <titleId>216138247</titleId>
    <itemCode></itemCode>
    <itemReference></itemReference>
    <titleName>*** WEEK 32 PRE-TOTH AMY WINEHOUSE</titleName>
    <artistName></artistName>
    <albumName></albumName>
    <CategoryCode>688</CategoryCode>
    <CategoryName>ZENDERBREDE ACTIE</CategoryName>
    <itemDuration>11</itemDuration>
    <MultiMedia1></MultiMedia1>
    <MultiMedia2></MultiMedia2>
    <MultiMedia3></MultiMedia3>
    <MultiMedia4></MultiMedia4>
  </Current>
  <Next>
    <startTime>2015-08-05T15:02:22</startTime>
    <itemId>1000080540:1241848</itemId>
    <titleId>216138670</titleId>
    <itemCode>10598</itemCode>
    <itemReference></itemReference>
    <titleName>*** TOTH ZET 'M OP RUDY</titleName>
    <artistName></artistName>
    <albumName></albumName>
    <CategoryCode>758</CategoryCode>
    <CategoryName>HOOFD UUROPENERS</CategoryName>
    <itemDuration>13</itemDuration>
    <MultiMedia1></MultiMedia1>
    <MultiMedia2></MultiMedia2>
    <MultiMedia3></MultiMedia3>
    <MultiMedia4></MultiMedia4>
  </Next>
</BroadcastMonitor>


text:
epeg_memory_open() function
--SKIPIF--
<?php include 'skipif.inc'; ?>
--FILE--
<?php
echo 'OK'; // no test case for this function yet
?>
--EXPECT--
OK