Coverage Report - org.apache.maven.wagon.providers.ssh.TestPasswordAuthenticator
 
Classes in this File Line Coverage Branch Coverage Complexity
TestPasswordAuthenticator
0 %
0/5
0 %
0/4
1,333
TestPasswordAuthenticator$PasswordAuthenticatorRequest
0 %
0/10
N/A
1,333
 
 1  
 package org.apache.maven.wagon.providers.ssh;
 2  
 /*
 3  
  * Licensed to the Apache Software Foundation (ASF) under one
 4  
  * or more contributor license agreements.  See the NOTICE file
 5  
  * distributed with this work for additional information
 6  
  * regarding copyright ownership.  The ASF licenses this file
 7  
  * to you under the Apache License, Version 2.0 (the
 8  
  * "License"); you may not use this file except in compliance
 9  
  * with the License.  You may obtain a copy of the License at
 10  
  *
 11  
  *   http://www.apache.org/licenses/LICENSE-2.0
 12  
  *
 13  
  * Unless required by applicable law or agreed to in writing,
 14  
  * software distributed under the License is distributed on an
 15  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 16  
  * KIND, either express or implied.  See the License for the
 17  
  * specific language governing permissions and limitations
 18  
  * under the License.
 19  
  */
 20  
 
 21  
 import org.apache.sshd.server.PasswordAuthenticator;
 22  
 import org.apache.sshd.server.session.ServerSession;
 23  
 import org.codehaus.plexus.util.StringUtils;
 24  
 
 25  
 import java.util.ArrayList;
 26  
 import java.util.List;
 27  
 
 28  
 /**
 29  
  * @author Olivier Lamy
 30  
  */
 31  0
 public class TestPasswordAuthenticator
 32  
     implements PasswordAuthenticator
 33  
 {
 34  0
     public List<PasswordAuthenticatorRequest> passwordAuthenticatorRequests =
 35  
         new ArrayList<PasswordAuthenticatorRequest>();
 36  
 
 37  
     public boolean authenticate( String username, String password, ServerSession session )
 38  
     {
 39  0
         passwordAuthenticatorRequests.add( new PasswordAuthenticatorRequest( username, password ) );
 40  0
         return StringUtils.equals( username, TestData.getUserName() ) && StringUtils.equals( password,
 41  
                                                                                              TestData.getUserPassword() );
 42  
     }
 43  
 
 44  0
     public static class PasswordAuthenticatorRequest
 45  
     {
 46  
         public String username;
 47  
 
 48  
         public String password;
 49  
 
 50  
         public PasswordAuthenticatorRequest( String username, String password )
 51  0
         {
 52  0
             this.username = username;
 53  0
             this.password = password;
 54  0
         }
 55  
 
 56  
         @Override
 57  
         public String toString()
 58  
         {
 59  0
             final StringBuilder sb = new StringBuilder();
 60  0
             sb.append( "PasswordAuthenticatorRequest" );
 61  0
             sb.append( "{username='" ).append( username ).append( '\'' );
 62  0
             sb.append( ", password='" ).append( password ).append( '\'' );
 63  0
             sb.append( '}' );
 64  0
             return sb.toString();
 65  
         }
 66  
     }
 67  
 }