Coverage Report - org.apache.maven.wagon.providers.ssh.interactive.TraditionalUIKeyboardInteractive
 
Classes in this File Line Coverage Branch Coverage Complexity
TraditionalUIKeyboardInteractive
0% 
0% 
1,5
 
 1  
 package org.apache.maven.wagon.providers.ssh.interactive;
 2  
 
 3  
 /*
 4  
  * Copyright 2001-2005 The Apache Software Foundation.
 5  
  *
 6  
  * Licensed under the Apache License, Version 2.0 (the "License");
 7  
  * you may not use this file except in compliance with the License.
 8  
  * You may obtain a copy of the License at
 9  
  *
 10  
  *      http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 
 19  
 import com.jcraft.jsch.UIKeyboardInteractive;
 20  
 import org.apache.maven.wagon.authentication.AuthenticationInfo;
 21  
 
 22  
 /**
 23  
  * A conservative <code>UIKeyboardInteractive</code> that avoids real
 24  
  * user interaction :). This implementation expects only one prompt with the
 25  
  * word password in it.
 26  
  * <p/>
 27  
  * <code>UIKeyboardInteractive</code> are usefull when you don't use user with
 28  
  * password authentication with a server that use keyboard-interactive and
 29  
  * doesn't allow password method <code>PasswordAuthentication no</code>.
 30  
  *
 31  
  * @author Juan F. Codagnone
 32  
  * @since Sep 21, 2005
 33  
  */
 34  
 public class TraditionalUIKeyboardInteractive
 35  
     implements UIKeyboardInteractive
 36  
 {
 37  
     private final AuthenticationInfo authInfo;
 38  
 
 39  
     public TraditionalUIKeyboardInteractive( AuthenticationInfo authInfo )
 40  0
     {
 41  0
         this.authInfo = authInfo;
 42  0
     }
 43  
 
 44  
     /**
 45  
      * @see UIKeyboardInteractive#promptKeyboardInteractive(String, String,
 46  
      *      String, String[], boolean[])
 47  
      */
 48  
     public String[] promptKeyboardInteractive( String destination, String name, String instruction, String[] prompt,
 49  
                                                boolean[] echo )
 50  
     {
 51  
 
 52  
         String[] ret;
 53  
 
 54  0
         if ( prompt.length == echo.length && prompt.length == 1 && !echo[0] &&
 55  
             prompt[0].toLowerCase().indexOf( "password" ) > -1 )
 56  
         {
 57  
 
 58  0
             ret = new String[1];
 59  0
             ret[0] = authInfo.getPassword();
 60  0
         }
 61  
         else
 62  
         {
 63  
             // jsch-0.1.21/examples/UserAuthKI.java returns null to cancel
 64  0
             ret = null;
 65  
         }
 66  
 
 67  0
         return ret;
 68  
     }
 69  
 }