001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.vfs2.provider.sftp; 018 019import org.apache.commons.logging.Log; 020import org.apache.commons.logging.LogFactory; 021 022import com.jcraft.jsch.UserInfo; 023 024/** 025 * Helper class to trust a new host. 026 */ 027public class TrustEveryoneUserInfo implements UserInfo { 028 private static final Log log = LogFactory.getLog(TrustEveryoneUserInfo.class); 029 030 @Override 031 public String getPassphrase() { 032 return null; 033 } 034 035 @Override 036 public String getPassword() { 037 return null; 038 } 039 040 @Override 041 public boolean promptPassword(final String s) { 042 log.info(s + " - Answer: False"); 043 return false; 044 } 045 046 @Override 047 public boolean promptPassphrase(final String s) { 048 log.info(s + " - Answer: False"); 049 return false; 050 } 051 052 @Override 053 public boolean promptYesNo(final String s) { 054 log.debug(s + " - Answer: Yes"); 055 056 // trust 057 return true; 058 } 059 060 @Override 061 public void showMessage(final String s) { 062 log.debug(s); 063 } 064}