filestore.java

来自「这是linux下ssl vpn的实现程序」· Java 代码 · 共 41 行

JAVA
41
字号
package com.sslexplorer.vfs.store.file;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.sslexplorer.security.SessionInfo;
import com.sslexplorer.vfs.NetworkPlace;
import com.sslexplorer.vfs.utils.URI;
import com.sslexplorer.vfs.utils.URI.MalformedURIException;
import com.sslexplorer.vfs.webdav.AbstractNetworkPlaceMount;
import com.sslexplorer.vfs.webdav.AbstractNetworkPlaceStore;

public class FileStore extends AbstractNetworkPlaceStore {
    final static Log log = LogFactory.getLog(FileStore.class);

    public FileStore() {
        this("file");
    }

    public FileStore(String storeName) {
        super(storeName, "UTF-8");
    }

    public String validateUserEnteredPath(String path) throws IllegalArgumentException {
        try {
            URI uri = new URI(path);
            if (uri.getScheme() == null || uri.getScheme().equals("file") || (uri.getScheme().length() == 1 && uri.getScheme().charAt(0) >= 'a' && uri.getScheme().charAt(0) <= 'z') ) {
                return "file";
            }
        } catch (MalformedURIException e) {
            if (!path.startsWith("\\\\")) {
                return "file";
            }
        }
        throw new IllegalArgumentException();
    }

    protected AbstractNetworkPlaceMount createMount(NetworkPlace networkPlace, SessionInfo session) throws Exception {
        return new FileMount(networkPlace, this);
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?