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.ftps;
018
019import org.apache.commons.vfs2.FileName;
020import org.apache.commons.vfs2.FileSystem;
021import org.apache.commons.vfs2.FileSystemConfigBuilder;
022import org.apache.commons.vfs2.FileSystemException;
023import org.apache.commons.vfs2.FileSystemOptions;
024import org.apache.commons.vfs2.provider.GenericFileName;
025import org.apache.commons.vfs2.provider.ftp.FtpFileProvider;
026
027/**
028 * A provider for FTP file systems.
029 *
030 * NOTE: Most of the heavy lifting for FTPS is done by the org.apache.commons.vfs2.provider.ftp package since they both
031 * use commons-net package
032 *
033 * @since 2.0
034 */
035public class FtpsFileProvider extends FtpFileProvider {
036
037    /**
038     * Constructs a new instance.
039     */
040    public FtpsFileProvider() {
041    }
042
043    /**
044     * Creates the file system.
045     *
046     * @return a new FileSystem, never null.
047     */
048    @Override
049    protected FileSystem doCreateFileSystem(final FileName name, final FileSystemOptions fileSystemOptions)
050            throws FileSystemException {
051        // Create the file system
052        final GenericFileName rootName = (GenericFileName) name;
053        final FtpsClientWrapper ftpClient = new FtpsClientWrapper(rootName, fileSystemOptions);
054        return new FtpsFileSystem(rootName, ftpClient, fileSystemOptions);
055    }
056
057    @Override
058    public FileSystemConfigBuilder getConfigBuilder() {
059        return FtpsFileSystemConfigBuilder.getInstance();
060    }
061}