Coverage Report - org.apache.maven.wagon.providers.ssh.interactive.ConsoleInteractiveUserInfo
 
Classes in this File Line Coverage Branch Coverage Complexity
ConsoleInteractiveUserInfo
0% 
N/A 
1,667
 
 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 org.codehaus.plexus.components.interactivity.Prompter;
 20  
 import org.codehaus.plexus.components.interactivity.PrompterException;
 21  
 
 22  
 import java.util.Arrays;
 23  
 
 24  
 /**
 25  
  * Shows messages to System.out, and ask replies using an InputHandler
 26  
  *
 27  
  * @author Juan F. Codagnone
 28  
  * @since Sep 12, 2005
 29  
  */
 30  
 public class ConsoleInteractiveUserInfo
 31  
     implements InteractiveUserInfo
 32  
 {
 33  
     private Prompter prompter;
 34  
 
 35  
     public ConsoleInteractiveUserInfo()
 36  0
     {
 37  0
     }
 38  
 
 39  
     public ConsoleInteractiveUserInfo( Prompter prompter )
 40  0
     {
 41  0
         this.prompter = prompter;
 42  0
     }
 43  
 
 44  
     /**
 45  
      * @see InteractiveUserInfo#promptYesNo(String)
 46  
      */
 47  
     public boolean promptYesNo( String message )
 48  
     {
 49  
         String ret;
 50  
         try
 51  
         {
 52  0
             ret = prompter.prompt( message, Arrays.asList( new String[]{"yes", "no"} ) );
 53  
         }
 54  0
         catch ( PrompterException e )
 55  
         {
 56  
             // no op
 57  0
             ret = null;
 58  0
         }
 59  0
         return "yes".equalsIgnoreCase( ret );
 60  
     }
 61  
 
 62  
     /**
 63  
      * @see InteractiveUserInfo#showMessage(String)
 64  
      */
 65  
     public void showMessage( String message )
 66  
     {
 67  
         try
 68  
         {
 69  0
             prompter.showMessage( message );
 70  
         }
 71  0
         catch ( PrompterException e )
 72  
         {
 73  
             // no op
 74  0
         }
 75  0
     }
 76  
 
 77  
     public String promptPassword( String message )
 78  
     {
 79  
         try
 80  
         {
 81  0
             return prompter.promptForPassword( message );
 82  
         }
 83  0
         catch ( PrompterException e )
 84  
         {
 85  0
             return null;
 86  
         }
 87  
     }
 88  
 
 89  
     public String promptPassphrase( String message )
 90  
     {
 91  0
         return promptPassword( message );
 92  
     }
 93  
 }