Coverage Report - org.apache.maven.wagon.providers.ssh.interactive.ConsoleInteractiveUserInfo
 
Classes in this File Line Coverage Branch Coverage Complexity
ConsoleInteractiveUserInfo
0 %
0/18
N/A
1,667
 
 1  
 package org.apache.maven.wagon.providers.ssh.interactive;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *   http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import org.codehaus.plexus.components.interactivity.Prompter;
 23  
 import org.codehaus.plexus.components.interactivity.PrompterException;
 24  
 
 25  
 import java.util.Arrays;
 26  
 
 27  
 /**
 28  
  * Shows messages to System.out, and ask replies using an InputHandler
 29  
  *
 30  
  * @author Juan F. Codagnone
 31  
  * @since Sep 12, 2005
 32  
  * 
 33  
  * @plexus.component role="org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo"
 34  
  *    instantiation-strategy="per-lookup"
 35  
  */
 36  
 public class ConsoleInteractiveUserInfo
 37  
     implements InteractiveUserInfo
 38  
 {
 39  
     /**
 40  
      * @plexus.requirement role-hint="default"
 41  
      */
 42  
     private Prompter prompter;
 43  
 
 44  
     public ConsoleInteractiveUserInfo()
 45  0
     {
 46  0
     }
 47  
 
 48  
     public ConsoleInteractiveUserInfo( Prompter prompter )
 49  0
     {
 50  0
         this.prompter = prompter;
 51  0
     }
 52  
 
 53  
     /**
 54  
      * @see InteractiveUserInfo#promptYesNo(String)
 55  
      */
 56  
     public boolean promptYesNo( String message )
 57  
     {
 58  
         String ret;
 59  
         try
 60  
         {
 61  0
             ret = prompter.prompt( message, Arrays.asList( new String[]{"yes", "no"} ) );
 62  
         }
 63  0
         catch ( PrompterException e )
 64  
         {
 65  
             // no op
 66  0
             ret = null;
 67  0
         }
 68  0
         return "yes".equalsIgnoreCase( ret );
 69  
     }
 70  
 
 71  
     /**
 72  
      * @see InteractiveUserInfo#showMessage(String)
 73  
      */
 74  
     public void showMessage( String message )
 75  
     {
 76  
         try
 77  
         {
 78  0
             prompter.showMessage( message );
 79  
         }
 80  0
         catch ( PrompterException e )
 81  
         {
 82  
             // no op
 83  0
         }
 84  0
     }
 85  
 
 86  
     public String promptPassword( String message )
 87  
     {
 88  
         try
 89  
         {
 90  0
             return prompter.promptForPassword( message );
 91  
         }
 92  0
         catch ( PrompterException e )
 93  
         {
 94  0
             return null;
 95  
         }
 96  
     }
 97  
 
 98  
     public String promptPassphrase( String message )
 99  
     {
 100  0
         return promptPassword( message );
 101  
     }
 102  
 }