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{
030    /** The default FileSystemConfigBuilder */
031    private static final DefaultFileSystemConfigBuilder BUILDER = new DefaultFileSystemConfigBuilder();
032
033    /**
034     * Gets the singleton builder.
035     *
036     * @return the singleton builder.
037     */
038    public static DefaultFileSystemConfigBuilder getInstance()
039    {
040        return BUILDER;
041    }
042
043    /**
044     * Sets the user authenticator to get authentication informations.
045     * @param opts The FileSystemOptions.
046     * @param userAuthenticator The UserAuthenticator.
047     * @throws FileSystemException if an error occurs setting the UserAuthenticator.
048     */
049    public void setUserAuthenticator(final FileSystemOptions opts, final UserAuthenticator userAuthenticator)
050            throws FileSystemException
051    {
052        setParam(opts, "userAuthenticator", userAuthenticator);
053    }
054
055    /**
056     * @see #setUserAuthenticator
057     * @param opts The FileSystemOptions.
058     * @return The UserAuthenticator.
059     */
060    public UserAuthenticator getUserAuthenticator(final FileSystemOptions opts)
061    {
062        return (UserAuthenticator) getParam(opts, "userAuthenticator");
063    }
064
065    /**
066     * Dummy class that implements FileSystem.
067     */
068    abstract static class DefaultFileSystem implements FileSystem
069    {
070    }
071
072    @Override
073    protected Class<? extends FileSystem> getConfigClass()
074    {
075        return DefaultFileSystem.class;
076    }
077}