103. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 2/7/2017 12:14:10 PM Eastern Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

103.1 Files compared

# Location File Last Modified
1 cpss.zip\cpss\src\test\java\gov\va\cpss\sftp MockSftpServer.java Wed Feb 1 21:07:28 2017 UTC
2 cpss.zip\cpss\src\test\java\gov\va\cpss\sftp MockSftpServer.java Mon Feb 6 16:37:06 2017 UTC

103.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 258
Changed 1 2
Inserted 0 0
Removed 0 0

103.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

103.4 Active regular expressions

No regular expressions were active.

103.5 Comparison detail

  1   package go v.va.cpss. sftp;
  2  
  3   import jav a.io.File;
  4   import jav a.nio.file .Paths;
  5   import jav a.util.Arr ays;
  6   import jav a.util.Sca nner;
  7  
  8   import org .apache.lo g4j.Logger ;
  9   import org .apache.ss hd.common. NamedFacto ry;
  10   import org .apache.ss hd.common. file.virtu alfs.Virtu alFileSyst emFactory;
  11   import org .apache.ss hd.server. Command;
  12   import org .apache.ss hd.server. SshServer;
  13   import org .apache.ss hd.server. auth.passw ord.Passwo rdAuthenti cator;
  14   import org .apache.ss hd.server. auth.pubke y.AcceptAl lPublickey Authentica tor;
  15   import org .apache.ss hd.server. keyprovide r.SimpleGe neratorHos tKeyProvid er;
  16   import org .apache.ss hd.server. scp.ScpCom mandFactor y;
  17   import org .apache.ss hd.server. session.Se rverSessio n;
  18   import org .apache.ss hd.server. subsystem. sftp.SftpS ubsystemFa ctory;
  19   import org .springfra mework.tes t.context. ContextCon figuration ;
  20  
  21   /**
  22    * Mock Te st SFTP Se rver.
  23    * 
  24    * @author   DN S      D N S
  25    */
  26   @ContextCo nfiguratio n(location s = { "/te st-context .xml" })
  27   public cla ss MockSft pServer {
  28  
  29           pr ivate stat ic final L ogger logg er = Logge r.getLogge r(MockSftp Server.cla ss.getCano nicalName( ));
  30  
  31           pr ivate stat ic final S tring LOCA L_SFTP_SER VER_ROOT =  "C:\\Temp \\SFTPROOT ";
  32  
  33           pr ivate SshS erver sshd ;
  34  
  35           pu blic void  start(Stri ng userInp ut) throws  Exception  {
  36  
  37                    Syst em.out.pri ntln("Star ting Mock  SFTP Serve r...");
  38  
  39                    sshd  = SshServ er.setUpDe faultServe r();
  40                    sshd .setPort(2 2);
  41                    sshd .setKeyPai rProvider( new Simple GeneratorH ostKeyProv ider(new F ile("hostk ey.ser"))) ;
  42                    if(u serInput.e quals("5") )
  43                    {
  44                             sshd.s etPublicke yAuthentic ator(Accep tAllPublic keyAuthent icator.INS TANCE);
  45                    }
  46                    if(u serInput.e quals("4") )
  47                    {
  48                             sshd.s etPassword Authentica tor(new Pa sswordAuth enticator( ) {
  49                                      public b oolean aut henticate( String use rname, Str ing passwo rd, Server Session se ssion) {
  50                                               logger.inf o("SFTP De tected Log in: " + us ername);
  51                                               return tru e;
  52                                      }
  53                             });
  54                    }
  55  
  56                    ScpC ommandFact ory myComm andFactory  = new Scp CommandFac tory() {
  57                             public  Command c reateComma nd(String  command) {
  58                                      logger.i nfo("SFTP  Processing  Command:  " + comman d);
  59                                      return n ull;
  60                             }
  61                    };
  62                    sshd .setComman dFactory(m yCommandFa ctory);
  63  
  64                    sshd .setSubsys temFactori es(Arrays. <NamedFact ory<Comman d>> asList (new SftpS ubsystemFa ctory()));
  65  
  66                    sshd .setFileSy stemFactor y(new Virt ualFileSys temFactory (Paths.get (LOCAL_SFT P_SERVER_R OOT)));
  67  
  68                    sshd .start();
  69           }
  70  
  71           pu blic void  stop() thr ows Except ion {
  72                    Syst em.out.pri ntln("Stop ping Mock  SFTP Serve r...");
  73                    sshd .stop();
  74           }
  75  
  76           pu blic stati c void mai n(String a rgs[]) {
  77  
  78                    Mock SftpServer  mockServe r = new Mo ckSftpServ er();
  79  
  80                    try  {
  81                    
  82                             String  userInput  =      pi ckLogin();
  83                             
  84                             mockSe rver.start (userInput );
  85  
  86                             mockSe rver.run() ;
  87  
  88                             mockSe rver.stop( );
  89  
  90                    } ca tch (Excep tion e) {
  91                             System .err.print ln("Unexpe cted excep tion runni ng Mock SF TP Server:  " + e.get Message()) ;
  92                    }
  93           }
  94  
  95           pr ivate fina l void run () {
  96                    Stri ng input =  "0";
  97                    Scan ner keyboa rd = new S canner(Sys tem.in);
  98                    whil e (!input. equals("1" )) {
  99                             System .out.print ln("input  = " + inpu t);
  100                             System .out.print ln("Press  1 to stop" );
  101                             try {
  102                                      input =  keyboard.n ext();
  103                             } catc h (Excepti on e) {
  104                                      System.e rr.println ("Invalid  Input Dete cted");
  105                                      input =  "0";
  106                             }
  107                    }
  108                    keyb oard.close ();
  109                    Syst em.out.pri ntln("Shut ting down  ftp server .");
  110           }
  111           
  112           pr ivate stat ic String  pickLogin( )
  113           {
  114                    Stri ng userInp ut ="3";
  115                    Scan ner keyboa rd = new S canner(Sys tem.in);
  116                    whil e (userInp ut.equals( "3")) {
  117                    try  {
  118                             System .out.print ln("Please  Enter 4 f or passwor d Authenti cation or  Enter 5 fo r Private  Key Authen tication") ;
  119                             userIn put = keyb oard.next( );
  120                             System .out.print ln("User I nput is: "  + userInp ut);
  121                    } ca tch (Excep tion e) {
  122                             System .err.print ln("Invali d Input De tected Pas sword Will  Be Used") ;
  123                             userIn put = "4";
  124                    }
  125                    }
  126                    
  127                    retu rn userInp ut;
  128           }
  129  
  130   }