GitHub PullRequestReviewCommentEvent at 2014-04-09 00:17:09
Repository: knox
Actor: ekohlwey
Payload: {"comment":{"url":"https://api.github.com/repos/ekohlwey/knox/pulls/comments/11418152","id":11418152,"diff_hunk":"@@ -1,35 +1,182 @@\n package org.apache.hadoop.gateway.ssh;\n \n+import java.io.File;\n+import java.io.IOException;\n+import java.text.ParseException;\n+import java.util.Arrays;\n+import java.util.Date;\n+import java.util.List;\n+import java.util.Map;\n+\n import org.apache.directory.server.annotations.CreateKdcServer;\n import org.apache.directory.server.annotations.CreateLdapServer;\n import org.apache.directory.server.annotations.CreateTransport;\n import org.apache.directory.server.core.annotations.ApplyLdifFiles;\n+import org.apache.directory.server.core.annotations.CreateDS;\n+import org.apache.directory.server.core.annotations.CreatePartition;\n import org.apache.directory.server.core.integ.FrameworkRunner;\n-import org.apache.directory.server.kerberos.kdc.AbstractKerberosITest;\n+import org.apache.directory.server.core.kerberos.KeyDerivationInterceptor;\n import org.apache.directory.server.kerberos.kdc.AbstractKnoxKerberosITest;\n+import org.apache.directory.server.kerberos.shared.crypto.encryption.KerberosKeyFactory;\n+import org.apache.directory.server.kerberos.shared.keytab.Keytab;\n+import org.apache.directory.server.kerberos.shared.keytab.KeytabEntry;\n import org.apache.directory.server.protocol.shared.transport.TcpTransport;\n+import org.apache.directory.shared.kerberos.KerberosTime;\n+import org.apache.directory.shared.kerberos.KerberosUtils;\n import org.apache.directory.shared.kerberos.codec.types.EncryptionType;\n+import org.apache.directory.shared.kerberos.components.EncryptionKey;\n import org.apache.directory.shared.kerberos.crypto.checksum.ChecksumType;\n+import org.apache.hadoop.gateway.topology.Provider;\n+import org.apache.hadoop.gateway.topology.Topology;\n+import org.apache.sshd.ClientChannel;\n+import org.apache.sshd.ClientSession;\n+import org.apache.sshd.SshClient;\n+import org.apache.sshd.client.future.ConnectFuture;\n+import org.apache.sshd.common.util.NoCloseOutputStream;\n import org.junit.Before;\n-import org.junit.BeforeClass;\n+import org.junit.Rule;\n import org.junit.Test;\n+import org.junit.rules.TemporaryFolder;\n import org.junit.runner.RunWith;\n \n @RunWith(FrameworkRunner.class)\n+@CreateDS(name = \"KerberosUdpIT-class\",\n+  partitions = {\n+    @CreatePartition(name = \"example\", suffix = \"dc=example,dc=com\")},\n+    additionalInterceptors = { KeyDerivationInterceptor.class })\n @CreateLdapServer(transports = { @CreateTransport(protocol = \"LDAP\") })\n @CreateKdcServer(transports = { @CreateTransport(protocol = \"TCP\", port = 6086) })\n @ApplyLdifFiles(\"org/apache/directory/server/kerberos/kdc/KerberosIT.ldif\")\n public class SSHDeploymentContributorTest extends AbstractKnoxKerberosITest {\n+  \n+  public static final String PRINCIPLE = LDAP_SERVICE_NAME + \"/\" + USER_UID + \"@\" + REALM;\n+  public static final String COMMAND = \"help\";\n+  public static final Integer PORT = 6087;\n+\n+  @Rule\n+  public TemporaryFolder testFolder = new TemporaryFolder();\n+  \n+  private class TestProvider extends Provider {\n+    \n+    @Override\n+    public Topology getTopology() {\n+      Topology topology = new Topology();\n+      topology.setName(\"Test Topology\");\n+      return topology;\n+    }\n+\n+    public File generateKeytab() {\n+      \n+      Keytab keytab = Keytab.getInstance();\n+      File keytabFile = null;\n+      \n+      try { \n+        keytabFile = testFolder.newFile();\n+        long principalType = 1;\n+        Date date = null;\n+  \n+        synchronized (KerberosUtils.UTC_DATE_FORMAT) {\n+          try {\n+            date = KerberosUtils.UTC_DATE_FORMAT.parse(\"20070217235745Z\");\n+          } catch (ParseException e) {\n+            e.printStackTrace();\n+          }\n+        }\n+  \n+        KerberosTime timeStamp = new KerberosTime(date.getTime());\n+  \n+        Map<EncryptionType, EncryptionKey> keys = KerberosKeyFactory\n+            .getKerberosKeys(PRINCIPLE, USER_PASSWORD);\n+  \n+        KeytabEntry keytabEntry = new KeytabEntry(\n+            PRINCIPLE, \n+            principalType,\n+            timeStamp, \n+            (byte) 1, \n+            keys.get(EncryptionType.DES_CBC_MD5));\n+        \n+        List<KeytabEntry> entry = Arrays.asList(keytabEntry);\n+        \n+        keytab.setEntries(entry);\n+        \n+        keytab.write(keytabFile);\n+      } catch (IOException e) {\n+        throw new RuntimeException(\"Could not generate keytab.\", e);\n+      }\n+      \n+      return keytabFile;\n+    }\n+  }\n+\n+  private class SSHProviderConfigurer implements ProviderConfigurer {\n+    @Override\n+    public SSHConfiguration configure(Provider provider) {\n+      TestProvider keytabProv = (TestProvider) provider;\n+      return new SSHConfiguration(PORT, \"~/.ssh\", keytabProv.generateKeytab().getAbsolutePath(),\n+          PRINCIPLE, 0);\n+    }\n+  }\n \n   @Before\n   public void populateBasicKDC() throws Throwable {\n-    setupEnv(new KnoxObtainTicketParameters(TcpTransport.class,\n-        EncryptionType.DES3_CBC_SHA1, ChecksumType.HMAC_SHA1_DES3));\n+    setupEnv(new KnoxObtainTicketParameters(\n+        TcpTransport.class,\n+        EncryptionType.DES3_CBC_SHA1, \n+        ChecksumType.HMAC_SHA1_DES3));\n   }\n \n   @Test\n   public void testConnection() throws Throwable {\n \n+    ProviderConfigurer configurer = new SSHProviderConfigurer();","path":"gateway-provider-mina-sshd/src/test/java/org/apache/hadoop/gateway/ssh/SSHDeploymentContributorTest.java","position":135,"original_position":135,"commit_id":"27b3ad0392ee831178055db66599c62f834c6529","original_commit_id":"27b3ad0392ee831178055db66599c62f834c6529","user":{"login":"ekohlwey","id":472537,"avatar_url":"https://avatars.githubusercontent.com/u/472537?","gravatar_id":"b1bdb06b00ebff0f70a594a525061931","url":"https://api.github.com/users/ekohlwey","html_url":"https://github.com/ekohlwey","followers_url":"https://api.github.com/users/ekohlwey/followers","following_url":"https://api.github.com/users/ekohlwey/following{/other_user}","gists_url":"https://api.github.com/users/ekohlwey/gists{/gist_id}","starred_url":"https://api.github.com/users/ekohlwey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ekohlwey/subscriptions","organizations_url":"https://api.github.com/users/ekohlwey/orgs","repos_url":"https://api.github.com/users/ekohlwey/repos","events_url":"https://api.github.com/users/ekohlwey/events{/privacy}","received_events_url":"https://api.github.com/users/ekohlwey/received_events","type":"User","site_admin":false},"body":"just mock this.","created_at":"2014-04-09T00:17:09Z","updated_at":"2014-04-09T00:17:09Z","html_url":"https://github.com/ekohlwey/knox/pull/1#discussion_r11418152","pull_request_url":"https://api.github.com/repos/ekohlwey/knox/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/ekohlwey/knox/pulls/comments/11418152"},"html":{"href":"https://github.com/ekohlwey/knox/pull/1#discussion_r11418152"},"pull_request":{"href":"https://api.github.com/repos/ekohlwey/knox/pulls/1"}}}}