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.impl;
018
019import org.apache.commons.vfs2.FileSystem;
020import org.apache.commons.vfs2.FileSystemConfigBuilder;
021import org.apache.commons.vfs2.FileSystemException;
022import org.apache.commons.vfs2.FileSystemOptions;
023import org.apache.commons.vfs2.UserAuthenticator;
024
025/**
026 * Default options usable for all file systems.
027 */
028public class DefaultFileSystemConfigBuilder extends FileSystemConfigBuilder {
029    /** The default FileSystemConfigBuilder */
030    private static final DefaultFileSystemConfigBuilder BUILDER = new DefaultFileSystemConfigBuilder();
031
032    /**
033     * Gets the singleton builder.
034     *
035     * @return the singleton builder.
036     */
037    public static DefaultFileSystemConfigBuilder getInstance() {
038        return BUILDER;
039    }
040
041    /**
042     * Sets the user authenticator to get authentication informations.
043     *
044     * @param opts The FileSystemOptions.
045     * @param userAuthenticator The UserAuthenticator.
046     * @throws FileSystemException if an error occurs setting the UserAuthenticator.
047     */
048    public void setUserAuthenticator(final FileSystemOptions opts, final UserAuthenticator userAuthenticator)
049            throws FileSystemException {
050        setParam(opts, "userAuthenticator", userAuthenticator);
051    }
052
053    /**
054     * @see #setUserAuthenticator
055     * @param opts The FileSystemOptions.
056     * @return The UserAuthenticator.
057     */
058    public UserAuthenticator getUserAuthenticator(final FileSystemOptions opts) {
059        return (UserAuthenticator) getParam(opts, "userAuthenticator");
060    }
061
062    /**
063     * Dummy class that implements FileSystem.
064     */
065    abstract static class DefaultFileSystem implements FileSystem {
066    }
067
068    @Override
069    protected Class<? extends FileSystem> getConfigClass() {
070        return DefaultFileSystem.class;
071    }
072}