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    /**
031     * Constructs a new instance.
032     */
033    public TrustEveryoneUserInfo() {
034        // empty
035    }
036
037    @Override
038    public String getPassphrase() {
039        return null;
040    }
041
042    @Override
043    public String getPassword() {
044        return null;
045    }
046
047    @Override
048    public boolean promptPassphrase(final String s) {
049        log.info(s + " - Answer: False");
050        return false;
051    }
052
053    @Override
054    public boolean promptPassword(final String s) {
055        log.info(s + " - Answer: False");
056        return false;
057    }
058
059    @Override
060    public boolean promptYesNo(final String s) {
061        log.debug(s + " - Answer: Yes");
062
063        // trust
064        return true;
065    }
066
067    @Override
068    public void showMessage(final String s) {
069        log.debug(s);
070    }
071}