You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2016/02/23 17:38:27 UTC
[7/8] mina-sshd git commit: Fixed Maven bundle plugin warnings
"Export XXX, has 1, private references [XXX]"
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/AbstractOpenSSHStatCommandExtension.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/AbstractOpenSSHStatCommandExtension.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/AbstractOpenSSHStatCommandExtension.java
new file mode 100644
index 0000000..70550ee
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/AbstractOpenSSHStatCommandExtension.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.client.subsystem.sftp.extensions.openssh.helpers;
+
+import java.io.IOException;
+import java.io.StreamCorruptedException;
+import java.util.Map;
+
+import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
+import org.apache.sshd.client.subsystem.sftp.SftpClient;
+import org.apache.sshd.client.subsystem.sftp.extensions.helpers.AbstractSftpClientExtension;
+import org.apache.sshd.client.subsystem.sftp.extensions.openssh.OpenSSHStatExtensionInfo;
+import org.apache.sshd.common.util.buffer.Buffer;
+import org.apache.sshd.common.util.buffer.BufferUtils;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public abstract class AbstractOpenSSHStatCommandExtension extends AbstractSftpClientExtension {
+ protected AbstractOpenSSHStatCommandExtension(String name, SftpClient client, RawSftpClient raw, Map<String, byte[]> extensions) {
+ super(name, client, raw, extensions);
+ }
+
+ protected OpenSSHStatExtensionInfo doGetStat(Object target) throws IOException {
+ Buffer buffer = getCommandBuffer(target);
+ putTarget(buffer, target);
+
+ if (log.isDebugEnabled()) {
+ log.debug("doGetStat({})[{}]", getName(),
+ (target instanceof CharSequence) ? target : BufferUtils.toHex(BufferUtils.EMPTY_HEX_SEPARATOR, (byte[]) target));
+ }
+
+ buffer = checkExtendedReplyBuffer(receive(sendExtendedCommand(buffer)));
+ if (buffer == null) {
+ throw new StreamCorruptedException("Missing extended reply data");
+ }
+
+ return new OpenSSHStatExtensionInfo(buffer);
+ }
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/OpenSSHFsyncExtensionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/OpenSSHFsyncExtensionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/OpenSSHFsyncExtensionImpl.java
new file mode 100644
index 0000000..cafb600
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/OpenSSHFsyncExtensionImpl.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.client.subsystem.sftp.extensions.openssh.helpers;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
+import org.apache.sshd.client.subsystem.sftp.SftpClient;
+import org.apache.sshd.client.subsystem.sftp.SftpClient.Handle;
+import org.apache.sshd.client.subsystem.sftp.extensions.helpers.AbstractSftpClientExtension;
+import org.apache.sshd.client.subsystem.sftp.extensions.openssh.OpenSSHFsyncExtension;
+import org.apache.sshd.common.subsystem.sftp.extensions.openssh.FsyncExtensionParser;
+import org.apache.sshd.common.util.NumberUtils;
+import org.apache.sshd.common.util.buffer.Buffer;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class OpenSSHFsyncExtensionImpl extends AbstractSftpClientExtension implements OpenSSHFsyncExtension {
+ public OpenSSHFsyncExtensionImpl(SftpClient client, RawSftpClient raw, Map<String, byte[]> extensions) {
+ super(FsyncExtensionParser.NAME, client, raw, extensions);
+ }
+
+ @Override
+ public void fsync(Handle fileHandle) throws IOException {
+ byte[] handle = fileHandle.getIdentifier();
+ Buffer buffer = getCommandBuffer((Integer.SIZE / Byte.SIZE) + NumberUtils.length(handle));
+ buffer.putBytes(handle);
+ sendAndCheckExtendedCommandStatus(buffer);
+ }
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/OpenSSHStatHandleExtensionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/OpenSSHStatHandleExtensionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/OpenSSHStatHandleExtensionImpl.java
new file mode 100644
index 0000000..de5f780
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/OpenSSHStatHandleExtensionImpl.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.client.subsystem.sftp.extensions.openssh.helpers;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
+import org.apache.sshd.client.subsystem.sftp.SftpClient;
+import org.apache.sshd.client.subsystem.sftp.SftpClient.Handle;
+import org.apache.sshd.client.subsystem.sftp.extensions.openssh.OpenSSHStatExtensionInfo;
+import org.apache.sshd.client.subsystem.sftp.extensions.openssh.OpenSSHStatHandleExtension;
+import org.apache.sshd.common.subsystem.sftp.extensions.openssh.FstatVfsExtensionParser;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class OpenSSHStatHandleExtensionImpl extends AbstractOpenSSHStatCommandExtension implements OpenSSHStatHandleExtension {
+ public OpenSSHStatHandleExtensionImpl(SftpClient client, RawSftpClient raw, Map<String, byte[]> extensions) {
+ super(FstatVfsExtensionParser.NAME, client, raw, extensions);
+ }
+
+ @Override
+ public OpenSSHStatExtensionInfo stat(Handle handle) throws IOException {
+ return doGetStat(handle.getIdentifier());
+ }
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/OpenSSHStatPathExtensionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/OpenSSHStatPathExtensionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/OpenSSHStatPathExtensionImpl.java
new file mode 100644
index 0000000..1cf3956
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/OpenSSHStatPathExtensionImpl.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.client.subsystem.sftp.extensions.openssh.helpers;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
+import org.apache.sshd.client.subsystem.sftp.SftpClient;
+import org.apache.sshd.client.subsystem.sftp.extensions.openssh.OpenSSHStatExtensionInfo;
+import org.apache.sshd.client.subsystem.sftp.extensions.openssh.OpenSSHStatPathExtension;
+import org.apache.sshd.common.subsystem.sftp.extensions.openssh.StatVfsExtensionParser;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class OpenSSHStatPathExtensionImpl extends AbstractOpenSSHStatCommandExtension implements OpenSSHStatPathExtension {
+ public OpenSSHStatPathExtensionImpl(SftpClient client, RawSftpClient raw, Map<String, byte[]> extensions) {
+ super(StatVfsExtensionParser.NAME, client, raw, extensions);
+ }
+
+ @Override
+ public OpenSSHStatExtensionInfo stat(String path) throws IOException {
+ return doGetStat(path);
+ }
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/AbstractOpenSSHStatCommandExtension.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/AbstractOpenSSHStatCommandExtension.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/AbstractOpenSSHStatCommandExtension.java
deleted file mode 100644
index 0deca28..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/AbstractOpenSSHStatCommandExtension.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.sshd.client.subsystem.sftp.extensions.openssh.impl;
-
-import java.io.IOException;
-import java.io.StreamCorruptedException;
-import java.util.Map;
-
-import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
-import org.apache.sshd.client.subsystem.sftp.SftpClient;
-import org.apache.sshd.client.subsystem.sftp.extensions.impl.AbstractSftpClientExtension;
-import org.apache.sshd.client.subsystem.sftp.extensions.openssh.OpenSSHStatExtensionInfo;
-import org.apache.sshd.common.util.buffer.Buffer;
-import org.apache.sshd.common.util.buffer.BufferUtils;
-
-/**
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public abstract class AbstractOpenSSHStatCommandExtension extends AbstractSftpClientExtension {
- protected AbstractOpenSSHStatCommandExtension(String name, SftpClient client, RawSftpClient raw, Map<String, byte[]> extensions) {
- super(name, client, raw, extensions);
- }
-
- protected OpenSSHStatExtensionInfo doGetStat(Object target) throws IOException {
- Buffer buffer = getCommandBuffer(target);
- putTarget(buffer, target);
-
- if (log.isDebugEnabled()) {
- log.debug("doGetStat({})[{}]", getName(),
- (target instanceof CharSequence) ? target : BufferUtils.toHex(BufferUtils.EMPTY_HEX_SEPARATOR, (byte[]) target));
- }
-
- buffer = checkExtendedReplyBuffer(receive(sendExtendedCommand(buffer)));
- if (buffer == null) {
- throw new StreamCorruptedException("Missing extended reply data");
- }
-
- return new OpenSSHStatExtensionInfo(buffer);
- }
-}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHFsyncExtensionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHFsyncExtensionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHFsyncExtensionImpl.java
deleted file mode 100644
index c650c78..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHFsyncExtensionImpl.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.sshd.client.subsystem.sftp.extensions.openssh.impl;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
-import org.apache.sshd.client.subsystem.sftp.SftpClient;
-import org.apache.sshd.client.subsystem.sftp.SftpClient.Handle;
-import org.apache.sshd.client.subsystem.sftp.extensions.impl.AbstractSftpClientExtension;
-import org.apache.sshd.client.subsystem.sftp.extensions.openssh.OpenSSHFsyncExtension;
-import org.apache.sshd.common.subsystem.sftp.extensions.openssh.FsyncExtensionParser;
-import org.apache.sshd.common.util.NumberUtils;
-import org.apache.sshd.common.util.buffer.Buffer;
-
-/**
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public class OpenSSHFsyncExtensionImpl extends AbstractSftpClientExtension implements OpenSSHFsyncExtension {
- public OpenSSHFsyncExtensionImpl(SftpClient client, RawSftpClient raw, Map<String, byte[]> extensions) {
- super(FsyncExtensionParser.NAME, client, raw, extensions);
- }
-
- @Override
- public void fsync(Handle fileHandle) throws IOException {
- byte[] handle = fileHandle.getIdentifier();
- Buffer buffer = getCommandBuffer((Integer.SIZE / Byte.SIZE) + NumberUtils.length(handle));
- buffer.putBytes(handle);
- sendAndCheckExtendedCommandStatus(buffer);
- }
-}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHStatHandleExtensionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHStatHandleExtensionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHStatHandleExtensionImpl.java
deleted file mode 100644
index b7ce4d8..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHStatHandleExtensionImpl.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.sshd.client.subsystem.sftp.extensions.openssh.impl;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
-import org.apache.sshd.client.subsystem.sftp.SftpClient;
-import org.apache.sshd.client.subsystem.sftp.SftpClient.Handle;
-import org.apache.sshd.client.subsystem.sftp.extensions.openssh.OpenSSHStatExtensionInfo;
-import org.apache.sshd.client.subsystem.sftp.extensions.openssh.OpenSSHStatHandleExtension;
-import org.apache.sshd.common.subsystem.sftp.extensions.openssh.FstatVfsExtensionParser;
-
-/**
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public class OpenSSHStatHandleExtensionImpl extends AbstractOpenSSHStatCommandExtension implements OpenSSHStatHandleExtension {
- public OpenSSHStatHandleExtensionImpl(SftpClient client, RawSftpClient raw, Map<String, byte[]> extensions) {
- super(FstatVfsExtensionParser.NAME, client, raw, extensions);
- }
-
- @Override
- public OpenSSHStatExtensionInfo stat(Handle handle) throws IOException {
- return doGetStat(handle.getIdentifier());
- }
-}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHStatPathExtensionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHStatPathExtensionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHStatPathExtensionImpl.java
deleted file mode 100644
index f22242d..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHStatPathExtensionImpl.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.sshd.client.subsystem.sftp.extensions.openssh.impl;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
-import org.apache.sshd.client.subsystem.sftp.SftpClient;
-import org.apache.sshd.client.subsystem.sftp.extensions.openssh.OpenSSHStatExtensionInfo;
-import org.apache.sshd.client.subsystem.sftp.extensions.openssh.OpenSSHStatPathExtension;
-import org.apache.sshd.common.subsystem.sftp.extensions.openssh.StatVfsExtensionParser;
-
-/**
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public class OpenSSHStatPathExtensionImpl extends AbstractOpenSSHStatCommandExtension implements OpenSSHStatPathExtension {
- public OpenSSHStatPathExtensionImpl(SftpClient client, RawSftpClient raw, Map<String, byte[]> extensions) {
- super(StatVfsExtensionParser.NAME, client, raw, extensions);
- }
-
- @Override
- public OpenSSHStatExtensionInfo stat(String path) throws IOException {
- return doGetStat(path);
- }
-}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/common/BaseBuilder.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/BaseBuilder.java b/sshd-core/src/main/java/org/apache/sshd/common/BaseBuilder.java
index ca8802f..1c1703c 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/BaseBuilder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/BaseBuilder.java
@@ -33,7 +33,7 @@ import org.apache.sshd.common.file.FileSystemFactory;
import org.apache.sshd.common.file.nativefs.NativeFileSystemFactory;
import org.apache.sshd.common.forward.DefaultTcpipForwarderFactory;
import org.apache.sshd.common.forward.TcpipForwarderFactory;
-import org.apache.sshd.common.impl.AbstractFactoryManager;
+import org.apache.sshd.common.helpers.AbstractFactoryManager;
import org.apache.sshd.common.kex.BuiltinDHFactories;
import org.apache.sshd.common.kex.KeyExchange;
import org.apache.sshd.common.mac.BuiltinMacs;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/common/config/SshConfigFileReader.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/config/SshConfigFileReader.java b/sshd-core/src/main/java/org/apache/sshd/common/config/SshConfigFileReader.java
index 63b3711..211b1fb 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/config/SshConfigFileReader.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/config/SshConfigFileReader.java
@@ -47,7 +47,7 @@ import org.apache.sshd.common.cipher.Cipher;
import org.apache.sshd.common.compression.BuiltinCompressions;
import org.apache.sshd.common.compression.Compression;
import org.apache.sshd.common.compression.CompressionFactory;
-import org.apache.sshd.common.impl.AbstractFactoryManager;
+import org.apache.sshd.common.helpers.AbstractFactoryManager;
import org.apache.sshd.common.kex.BuiltinDHFactories;
import org.apache.sshd.common.kex.DHFactory;
import org.apache.sshd.common.kex.KeyExchange;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/common/global/AbstractOpenSshHostKeysHandler.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/global/AbstractOpenSshHostKeysHandler.java b/sshd-core/src/main/java/org/apache/sshd/common/global/AbstractOpenSshHostKeysHandler.java
index d4ca673..523aa2c 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/global/AbstractOpenSshHostKeysHandler.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/global/AbstractOpenSshHostKeysHandler.java
@@ -27,7 +27,7 @@ import java.util.LinkedList;
import org.apache.sshd.common.config.keys.KeyUtils;
import org.apache.sshd.common.session.ConnectionService;
import org.apache.sshd.common.session.Session;
-import org.apache.sshd.common.session.impl.AbstractConnectionServiceRequestHandler;
+import org.apache.sshd.common.session.helpers.AbstractConnectionServiceRequestHandler;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.buffer.keys.BufferPublicKeyParser;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/common/helpers/AbstractFactoryManager.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/helpers/AbstractFactoryManager.java b/sshd-core/src/main/java/org/apache/sshd/common/helpers/AbstractFactoryManager.java
new file mode 100644
index 0000000..51cb5e2
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/helpers/AbstractFactoryManager.java
@@ -0,0 +1,389 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sshd.common.helpers;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.sshd.agent.SshAgentFactory;
+import org.apache.sshd.common.AttributeStore;
+import org.apache.sshd.common.Factory;
+import org.apache.sshd.common.FactoryManager;
+import org.apache.sshd.common.NamedFactory;
+import org.apache.sshd.common.PropertyResolver;
+import org.apache.sshd.common.PropertyResolverUtils;
+import org.apache.sshd.common.ServiceFactory;
+import org.apache.sshd.common.SyspropsMapWrapper;
+import org.apache.sshd.common.channel.Channel;
+import org.apache.sshd.common.channel.ChannelListener;
+import org.apache.sshd.common.channel.RequestHandler;
+import org.apache.sshd.common.config.VersionProperties;
+import org.apache.sshd.common.file.FileSystemFactory;
+import org.apache.sshd.common.forward.TcpipForwarderFactory;
+import org.apache.sshd.common.io.DefaultIoServiceFactoryFactory;
+import org.apache.sshd.common.io.IoServiceFactory;
+import org.apache.sshd.common.io.IoServiceFactoryFactory;
+import org.apache.sshd.common.kex.AbstractKexFactoryManager;
+import org.apache.sshd.common.random.Random;
+import org.apache.sshd.common.session.ConnectionService;
+import org.apache.sshd.common.session.ReservedSessionMessagesHandler;
+import org.apache.sshd.common.session.SessionListener;
+import org.apache.sshd.common.session.helpers.AbstractSessionFactory;
+import org.apache.sshd.common.session.helpers.SessionTimeoutListener;
+import org.apache.sshd.common.util.EventListenerUtils;
+import org.apache.sshd.common.util.ValidateUtils;
+import org.apache.sshd.common.util.threads.ThreadUtils;
+import org.apache.sshd.server.forward.ForwardingFilter;
+
+/**
+ * TODO Add javadoc
+ *
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public abstract class AbstractFactoryManager extends AbstractKexFactoryManager implements FactoryManager {
+
+ protected IoServiceFactoryFactory ioServiceFactoryFactory;
+ protected IoServiceFactory ioServiceFactory;
+ protected Factory<Random> randomFactory;
+ protected List<NamedFactory<Channel>> channelFactories;
+ protected SshAgentFactory agentFactory;
+ protected ScheduledExecutorService executor;
+ protected boolean shutdownExecutor;
+ protected TcpipForwarderFactory tcpipForwarderFactory;
+ protected ForwardingFilter tcpipForwardingFilter;
+ protected FileSystemFactory fileSystemFactory;
+ protected List<ServiceFactory> serviceFactories;
+ protected List<RequestHandler<ConnectionService>> globalRequestHandlers;
+ protected SessionTimeoutListener sessionTimeoutListener;
+ protected ScheduledFuture<?> timeoutListenerFuture;
+ protected final Collection<SessionListener> sessionListeners = new CopyOnWriteArraySet<>();
+ protected final SessionListener sessionListenerProxy;
+ protected final Collection<ChannelListener> channelListeners = new CopyOnWriteArraySet<>();
+ protected final ChannelListener channelListenerProxy;
+
+ private final Map<String, Object> properties = new ConcurrentHashMap<>();
+ private final Map<AttributeKey<?>, Object> attributes = new ConcurrentHashMap<>();
+ private PropertyResolver parentResolver = SyspropsMapWrapper.SYSPROPS_RESOLVER;
+ private ReservedSessionMessagesHandler reservedSessionMessagesHandler;
+
+ protected AbstractFactoryManager() {
+ ClassLoader loader = getClass().getClassLoader();
+ sessionListenerProxy = EventListenerUtils.proxyWrapper(SessionListener.class, loader, sessionListeners);
+ channelListenerProxy = EventListenerUtils.proxyWrapper(ChannelListener.class, loader, channelListeners);
+ }
+
+ @Override
+ public IoServiceFactory getIoServiceFactory() {
+ synchronized (ioServiceFactoryFactory) {
+ if (ioServiceFactory == null) {
+ ioServiceFactory = ioServiceFactoryFactory.create(this);
+ }
+ }
+ return ioServiceFactory;
+ }
+
+ public IoServiceFactoryFactory getIoServiceFactoryFactory() {
+ return ioServiceFactoryFactory;
+ }
+
+ public void setIoServiceFactoryFactory(IoServiceFactoryFactory ioServiceFactory) {
+ this.ioServiceFactoryFactory = ioServiceFactory;
+ }
+
+ @Override
+ public Factory<Random> getRandomFactory() {
+ return randomFactory;
+ }
+
+ public void setRandomFactory(Factory<Random> randomFactory) {
+ this.randomFactory = randomFactory;
+ }
+
+ @Override
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getAttribute(AttributeKey<T> key) {
+ return (T) attributes.get(ValidateUtils.checkNotNull(key, "No key"));
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T setAttribute(AttributeKey<T> key, T value) {
+ return (T) attributes.put(
+ ValidateUtils.checkNotNull(key, "No key"),
+ ValidateUtils.checkNotNull(value, "No value"));
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T removeAttribute(AttributeKey<T> key) {
+ return (T) attributes.remove(ValidateUtils.checkNotNull(key, "No key"));
+ }
+
+ @Override
+ public <T> T resolveAttribute(AttributeKey<T> key) {
+ return AttributeStore.Utils.resolveAttribute(this, key);
+ }
+
+ @Override
+ public PropertyResolver getParentPropertyResolver() {
+ return parentResolver;
+ }
+
+ public void setParentPropertyResolver(PropertyResolver parent) {
+ parentResolver = parent;
+ }
+
+ @Override
+ public String getVersion() {
+ return PropertyResolverUtils.getStringProperty(VersionProperties.getVersionProperties(), "sshd-version", DEFAULT_VERSION).toUpperCase();
+ }
+
+ @Override
+ public List<NamedFactory<Channel>> getChannelFactories() {
+ return channelFactories;
+ }
+
+ public void setChannelFactories(List<NamedFactory<Channel>> channelFactories) {
+ this.channelFactories = channelFactories;
+ }
+
+ public int getNioWorkers() {
+ int nb = PropertyResolverUtils.getIntProperty(this, NIO_WORKERS, DEFAULT_NIO_WORKERS);
+ if (nb > 0) {
+ return nb;
+ } else { // it may have been configured to a negative value
+ return DEFAULT_NIO_WORKERS;
+ }
+ }
+
+ public void setNioWorkers(int nioWorkers) {
+ if (nioWorkers > 0) {
+ PropertyResolverUtils.updateProperty(this, NIO_WORKERS, nioWorkers);
+ } else {
+ PropertyResolverUtils.updateProperty(this, NIO_WORKERS, null);
+ }
+ }
+
+ @Override
+ public SshAgentFactory getAgentFactory() {
+ return agentFactory;
+ }
+
+ public void setAgentFactory(SshAgentFactory agentFactory) {
+ this.agentFactory = agentFactory;
+ }
+
+ @Override
+ public ScheduledExecutorService getScheduledExecutorService() {
+ return executor;
+ }
+
+ public void setScheduledExecutorService(ScheduledExecutorService executor) {
+ setScheduledExecutorService(executor, false);
+ }
+
+ public void setScheduledExecutorService(ScheduledExecutorService executor, boolean shutdownExecutor) {
+ this.executor = executor;
+ this.shutdownExecutor = shutdownExecutor;
+ }
+
+ @Override
+ public TcpipForwarderFactory getTcpipForwarderFactory() {
+ return tcpipForwarderFactory;
+ }
+
+ public void setTcpipForwarderFactory(TcpipForwarderFactory tcpipForwarderFactory) {
+ this.tcpipForwarderFactory = tcpipForwarderFactory;
+ }
+
+ @Override
+ public ForwardingFilter getTcpipForwardingFilter() {
+ return tcpipForwardingFilter;
+ }
+
+ public void setTcpipForwardingFilter(ForwardingFilter tcpipForwardingFilter) {
+ this.tcpipForwardingFilter = tcpipForwardingFilter;
+ }
+
+ @Override
+ public FileSystemFactory getFileSystemFactory() {
+ return fileSystemFactory;
+ }
+
+ public void setFileSystemFactory(FileSystemFactory fileSystemFactory) {
+ this.fileSystemFactory = fileSystemFactory;
+ }
+
+ @Override
+ public List<ServiceFactory> getServiceFactories() {
+ return serviceFactories;
+ }
+
+ public void setServiceFactories(List<ServiceFactory> serviceFactories) {
+ this.serviceFactories = serviceFactories;
+ }
+
+ @Override
+ public List<RequestHandler<ConnectionService>> getGlobalRequestHandlers() {
+ return globalRequestHandlers;
+ }
+
+ public void setGlobalRequestHandlers(List<RequestHandler<ConnectionService>> globalRequestHandlers) {
+ this.globalRequestHandlers = globalRequestHandlers;
+ }
+
+ @Override
+ public ReservedSessionMessagesHandler getReservedSessionMessagesHandler() {
+ return reservedSessionMessagesHandler;
+ }
+
+ @Override
+ public void setReservedSessionMessagesHandler(ReservedSessionMessagesHandler handler) {
+ reservedSessionMessagesHandler = handler;
+ }
+
+ @Override
+ public void addSessionListener(SessionListener listener) {
+ ValidateUtils.checkNotNull(listener, "addSessionListener(%s) null instance", this);
+ // avoid race conditions on notifications while manager is being closed
+ if (!isOpen()) {
+ log.warn("addSessionListener({})[{}] ignore registration while manager is closing", this, listener);
+ return;
+ }
+
+ if (this.sessionListeners.add(listener)) {
+ log.trace("addSessionListener({})[{}] registered", this, listener);
+ } else {
+ log.trace("addSessionListener({})[{}] ignored duplicate", this, listener);
+ }
+ }
+
+ @Override
+ public void removeSessionListener(SessionListener listener) {
+ if (this.sessionListeners.remove(listener)) {
+ log.trace("removeSessionListener({})[{}] removed", this, listener);
+ } else {
+ log.trace("removeSessionListener({})[{}] not registered", this, listener);
+ }
+ }
+
+ @Override
+ public SessionListener getSessionListenerProxy() {
+ return sessionListenerProxy;
+ }
+
+ @Override
+ public void addChannelListener(ChannelListener listener) {
+ ValidateUtils.checkNotNull(listener, "addChannelListener(%s) null instance", this);
+ // avoid race conditions on notifications while manager is being closed
+ if (!isOpen()) {
+ log.warn("addChannelListener({})[{}] ignore registration while session is closing", this, listener);
+ return;
+ }
+
+ if (this.channelListeners.add(listener)) {
+ log.trace("addChannelListener({})[{}] registered", this, listener);
+ } else {
+ log.trace("addChannelListener({})[{}] ignored duplicate", this, listener);
+ }
+ }
+
+ @Override
+ public void removeChannelListener(ChannelListener listener) {
+ if (this.channelListeners.remove(listener)) {
+ log.trace("removeChannelListener({})[{}] removed", this, listener);
+ } else {
+ log.trace("removeChannelListener({})[{}] not registered", this, listener);
+ }
+ }
+
+ @Override
+ public ChannelListener getChannelListenerProxy() {
+ return channelListenerProxy;
+ }
+
+ protected void setupSessionTimeout(final AbstractSessionFactory<?, ?> sessionFactory) {
+ // set up the the session timeout listener and schedule it
+ sessionTimeoutListener = createSessionTimeoutListener();
+ addSessionListener(sessionTimeoutListener);
+
+ timeoutListenerFuture = getScheduledExecutorService()
+ .scheduleAtFixedRate(sessionTimeoutListener, 1, 1, TimeUnit.SECONDS);
+ }
+
+ protected void removeSessionTimeout(final AbstractSessionFactory<?, ?> sessionFactory) {
+ stopSessionTimeoutListener(sessionFactory);
+ }
+
+ protected SessionTimeoutListener createSessionTimeoutListener() {
+ return new SessionTimeoutListener();
+ }
+
+ protected void stopSessionTimeoutListener(final AbstractSessionFactory<?, ?> sessionFactory) {
+ // cancel the timeout monitoring task
+ if (timeoutListenerFuture != null) {
+ try {
+ timeoutListenerFuture.cancel(true);
+ } finally {
+ timeoutListenerFuture = null;
+ }
+ }
+
+ // remove the sessionTimeoutListener completely; should the SSH server/client be restarted, a new one
+ // will be created.
+ if (sessionTimeoutListener != null) {
+ try {
+ removeSessionListener(sessionTimeoutListener);
+ } finally {
+ sessionTimeoutListener = null;
+ }
+ }
+ }
+
+ protected void checkConfig() {
+ ValidateUtils.checkNotNullAndNotEmpty(getKeyExchangeFactories(), "KeyExchangeFactories not set");
+
+ if (getScheduledExecutorService() == null) {
+ setScheduledExecutorService(
+ ThreadUtils.newSingleThreadScheduledExecutor(this.toString() + "-timer"),
+ true);
+ }
+
+ ValidateUtils.checkNotNullAndNotEmpty(getCipherFactories(), "CipherFactories not set");
+ ValidateUtils.checkNotNullAndNotEmpty(getCompressionFactories(), "CompressionFactories not set");
+ ValidateUtils.checkNotNullAndNotEmpty(getMacFactories(), "MacFactories not set");
+
+ ValidateUtils.checkNotNull(getRandomFactory(), "RandomFactory not set");
+
+ if (getIoServiceFactoryFactory() == null) {
+ setIoServiceFactoryFactory(new DefaultIoServiceFactoryFactory());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/common/impl/AbstractFactoryManager.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/impl/AbstractFactoryManager.java b/sshd-core/src/main/java/org/apache/sshd/common/impl/AbstractFactoryManager.java
deleted file mode 100644
index 9e35391..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/common/impl/AbstractFactoryManager.java
+++ /dev/null
@@ -1,389 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.sshd.common.impl;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArraySet;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.sshd.agent.SshAgentFactory;
-import org.apache.sshd.common.AttributeStore;
-import org.apache.sshd.common.Factory;
-import org.apache.sshd.common.FactoryManager;
-import org.apache.sshd.common.NamedFactory;
-import org.apache.sshd.common.PropertyResolver;
-import org.apache.sshd.common.PropertyResolverUtils;
-import org.apache.sshd.common.ServiceFactory;
-import org.apache.sshd.common.SyspropsMapWrapper;
-import org.apache.sshd.common.channel.Channel;
-import org.apache.sshd.common.channel.ChannelListener;
-import org.apache.sshd.common.channel.RequestHandler;
-import org.apache.sshd.common.config.VersionProperties;
-import org.apache.sshd.common.file.FileSystemFactory;
-import org.apache.sshd.common.forward.TcpipForwarderFactory;
-import org.apache.sshd.common.io.DefaultIoServiceFactoryFactory;
-import org.apache.sshd.common.io.IoServiceFactory;
-import org.apache.sshd.common.io.IoServiceFactoryFactory;
-import org.apache.sshd.common.kex.AbstractKexFactoryManager;
-import org.apache.sshd.common.random.Random;
-import org.apache.sshd.common.session.ConnectionService;
-import org.apache.sshd.common.session.ReservedSessionMessagesHandler;
-import org.apache.sshd.common.session.SessionListener;
-import org.apache.sshd.common.session.impl.AbstractSessionFactory;
-import org.apache.sshd.common.session.impl.SessionTimeoutListener;
-import org.apache.sshd.common.util.EventListenerUtils;
-import org.apache.sshd.common.util.ValidateUtils;
-import org.apache.sshd.common.util.threads.ThreadUtils;
-import org.apache.sshd.server.forward.ForwardingFilter;
-
-/**
- * TODO Add javadoc
- *
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public abstract class AbstractFactoryManager extends AbstractKexFactoryManager implements FactoryManager {
-
- protected IoServiceFactoryFactory ioServiceFactoryFactory;
- protected IoServiceFactory ioServiceFactory;
- protected Factory<Random> randomFactory;
- protected List<NamedFactory<Channel>> channelFactories;
- protected SshAgentFactory agentFactory;
- protected ScheduledExecutorService executor;
- protected boolean shutdownExecutor;
- protected TcpipForwarderFactory tcpipForwarderFactory;
- protected ForwardingFilter tcpipForwardingFilter;
- protected FileSystemFactory fileSystemFactory;
- protected List<ServiceFactory> serviceFactories;
- protected List<RequestHandler<ConnectionService>> globalRequestHandlers;
- protected SessionTimeoutListener sessionTimeoutListener;
- protected ScheduledFuture<?> timeoutListenerFuture;
- protected final Collection<SessionListener> sessionListeners = new CopyOnWriteArraySet<>();
- protected final SessionListener sessionListenerProxy;
- protected final Collection<ChannelListener> channelListeners = new CopyOnWriteArraySet<>();
- protected final ChannelListener channelListenerProxy;
-
- private final Map<String, Object> properties = new ConcurrentHashMap<>();
- private final Map<AttributeKey<?>, Object> attributes = new ConcurrentHashMap<>();
- private PropertyResolver parentResolver = SyspropsMapWrapper.SYSPROPS_RESOLVER;
- private ReservedSessionMessagesHandler reservedSessionMessagesHandler;
-
- protected AbstractFactoryManager() {
- ClassLoader loader = getClass().getClassLoader();
- sessionListenerProxy = EventListenerUtils.proxyWrapper(SessionListener.class, loader, sessionListeners);
- channelListenerProxy = EventListenerUtils.proxyWrapper(ChannelListener.class, loader, channelListeners);
- }
-
- @Override
- public IoServiceFactory getIoServiceFactory() {
- synchronized (ioServiceFactoryFactory) {
- if (ioServiceFactory == null) {
- ioServiceFactory = ioServiceFactoryFactory.create(this);
- }
- }
- return ioServiceFactory;
- }
-
- public IoServiceFactoryFactory getIoServiceFactoryFactory() {
- return ioServiceFactoryFactory;
- }
-
- public void setIoServiceFactoryFactory(IoServiceFactoryFactory ioServiceFactory) {
- this.ioServiceFactoryFactory = ioServiceFactory;
- }
-
- @Override
- public Factory<Random> getRandomFactory() {
- return randomFactory;
- }
-
- public void setRandomFactory(Factory<Random> randomFactory) {
- this.randomFactory = randomFactory;
- }
-
- @Override
- public Map<String, Object> getProperties() {
- return properties;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getAttribute(AttributeKey<T> key) {
- return (T) attributes.get(ValidateUtils.checkNotNull(key, "No key"));
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T setAttribute(AttributeKey<T> key, T value) {
- return (T) attributes.put(
- ValidateUtils.checkNotNull(key, "No key"),
- ValidateUtils.checkNotNull(value, "No value"));
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T removeAttribute(AttributeKey<T> key) {
- return (T) attributes.remove(ValidateUtils.checkNotNull(key, "No key"));
- }
-
- @Override
- public <T> T resolveAttribute(AttributeKey<T> key) {
- return AttributeStore.Utils.resolveAttribute(this, key);
- }
-
- @Override
- public PropertyResolver getParentPropertyResolver() {
- return parentResolver;
- }
-
- public void setParentPropertyResolver(PropertyResolver parent) {
- parentResolver = parent;
- }
-
- @Override
- public String getVersion() {
- return PropertyResolverUtils.getStringProperty(VersionProperties.getVersionProperties(), "sshd-version", DEFAULT_VERSION).toUpperCase();
- }
-
- @Override
- public List<NamedFactory<Channel>> getChannelFactories() {
- return channelFactories;
- }
-
- public void setChannelFactories(List<NamedFactory<Channel>> channelFactories) {
- this.channelFactories = channelFactories;
- }
-
- public int getNioWorkers() {
- int nb = PropertyResolverUtils.getIntProperty(this, NIO_WORKERS, DEFAULT_NIO_WORKERS);
- if (nb > 0) {
- return nb;
- } else { // it may have been configured to a negative value
- return DEFAULT_NIO_WORKERS;
- }
- }
-
- public void setNioWorkers(int nioWorkers) {
- if (nioWorkers > 0) {
- PropertyResolverUtils.updateProperty(this, NIO_WORKERS, nioWorkers);
- } else {
- PropertyResolverUtils.updateProperty(this, NIO_WORKERS, null);
- }
- }
-
- @Override
- public SshAgentFactory getAgentFactory() {
- return agentFactory;
- }
-
- public void setAgentFactory(SshAgentFactory agentFactory) {
- this.agentFactory = agentFactory;
- }
-
- @Override
- public ScheduledExecutorService getScheduledExecutorService() {
- return executor;
- }
-
- public void setScheduledExecutorService(ScheduledExecutorService executor) {
- setScheduledExecutorService(executor, false);
- }
-
- public void setScheduledExecutorService(ScheduledExecutorService executor, boolean shutdownExecutor) {
- this.executor = executor;
- this.shutdownExecutor = shutdownExecutor;
- }
-
- @Override
- public TcpipForwarderFactory getTcpipForwarderFactory() {
- return tcpipForwarderFactory;
- }
-
- public void setTcpipForwarderFactory(TcpipForwarderFactory tcpipForwarderFactory) {
- this.tcpipForwarderFactory = tcpipForwarderFactory;
- }
-
- @Override
- public ForwardingFilter getTcpipForwardingFilter() {
- return tcpipForwardingFilter;
- }
-
- public void setTcpipForwardingFilter(ForwardingFilter tcpipForwardingFilter) {
- this.tcpipForwardingFilter = tcpipForwardingFilter;
- }
-
- @Override
- public FileSystemFactory getFileSystemFactory() {
- return fileSystemFactory;
- }
-
- public void setFileSystemFactory(FileSystemFactory fileSystemFactory) {
- this.fileSystemFactory = fileSystemFactory;
- }
-
- @Override
- public List<ServiceFactory> getServiceFactories() {
- return serviceFactories;
- }
-
- public void setServiceFactories(List<ServiceFactory> serviceFactories) {
- this.serviceFactories = serviceFactories;
- }
-
- @Override
- public List<RequestHandler<ConnectionService>> getGlobalRequestHandlers() {
- return globalRequestHandlers;
- }
-
- public void setGlobalRequestHandlers(List<RequestHandler<ConnectionService>> globalRequestHandlers) {
- this.globalRequestHandlers = globalRequestHandlers;
- }
-
- @Override
- public ReservedSessionMessagesHandler getReservedSessionMessagesHandler() {
- return reservedSessionMessagesHandler;
- }
-
- @Override
- public void setReservedSessionMessagesHandler(ReservedSessionMessagesHandler handler) {
- reservedSessionMessagesHandler = handler;
- }
-
- @Override
- public void addSessionListener(SessionListener listener) {
- ValidateUtils.checkNotNull(listener, "addSessionListener(%s) null instance", this);
- // avoid race conditions on notifications while manager is being closed
- if (!isOpen()) {
- log.warn("addSessionListener({})[{}] ignore registration while manager is closing", this, listener);
- return;
- }
-
- if (this.sessionListeners.add(listener)) {
- log.trace("addSessionListener({})[{}] registered", this, listener);
- } else {
- log.trace("addSessionListener({})[{}] ignored duplicate", this, listener);
- }
- }
-
- @Override
- public void removeSessionListener(SessionListener listener) {
- if (this.sessionListeners.remove(listener)) {
- log.trace("removeSessionListener({})[{}] removed", this, listener);
- } else {
- log.trace("removeSessionListener({})[{}] not registered", this, listener);
- }
- }
-
- @Override
- public SessionListener getSessionListenerProxy() {
- return sessionListenerProxy;
- }
-
- @Override
- public void addChannelListener(ChannelListener listener) {
- ValidateUtils.checkNotNull(listener, "addChannelListener(%s) null instance", this);
- // avoid race conditions on notifications while manager is being closed
- if (!isOpen()) {
- log.warn("addChannelListener({})[{}] ignore registration while session is closing", this, listener);
- return;
- }
-
- if (this.channelListeners.add(listener)) {
- log.trace("addChannelListener({})[{}] registered", this, listener);
- } else {
- log.trace("addChannelListener({})[{}] ignored duplicate", this, listener);
- }
- }
-
- @Override
- public void removeChannelListener(ChannelListener listener) {
- if (this.channelListeners.remove(listener)) {
- log.trace("removeChannelListener({})[{}] removed", this, listener);
- } else {
- log.trace("removeChannelListener({})[{}] not registered", this, listener);
- }
- }
-
- @Override
- public ChannelListener getChannelListenerProxy() {
- return channelListenerProxy;
- }
-
- protected void setupSessionTimeout(final AbstractSessionFactory<?, ?> sessionFactory) {
- // set up the the session timeout listener and schedule it
- sessionTimeoutListener = createSessionTimeoutListener();
- addSessionListener(sessionTimeoutListener);
-
- timeoutListenerFuture = getScheduledExecutorService()
- .scheduleAtFixedRate(sessionTimeoutListener, 1, 1, TimeUnit.SECONDS);
- }
-
- protected void removeSessionTimeout(final AbstractSessionFactory<?, ?> sessionFactory) {
- stopSessionTimeoutListener(sessionFactory);
- }
-
- protected SessionTimeoutListener createSessionTimeoutListener() {
- return new SessionTimeoutListener();
- }
-
- protected void stopSessionTimeoutListener(final AbstractSessionFactory<?, ?> sessionFactory) {
- // cancel the timeout monitoring task
- if (timeoutListenerFuture != null) {
- try {
- timeoutListenerFuture.cancel(true);
- } finally {
- timeoutListenerFuture = null;
- }
- }
-
- // remove the sessionTimeoutListener completely; should the SSH server/client be restarted, a new one
- // will be created.
- if (sessionTimeoutListener != null) {
- try {
- removeSessionListener(sessionTimeoutListener);
- } finally {
- sessionTimeoutListener = null;
- }
- }
- }
-
- protected void checkConfig() {
- ValidateUtils.checkNotNullAndNotEmpty(getKeyExchangeFactories(), "KeyExchangeFactories not set");
-
- if (getScheduledExecutorService() == null) {
- setScheduledExecutorService(
- ThreadUtils.newSingleThreadScheduledExecutor(this.toString() + "-timer"),
- true);
- }
-
- ValidateUtils.checkNotNullAndNotEmpty(getCipherFactories(), "CipherFactories not set");
- ValidateUtils.checkNotNullAndNotEmpty(getCompressionFactories(), "CompressionFactories not set");
- ValidateUtils.checkNotNullAndNotEmpty(getMacFactories(), "MacFactories not set");
-
- ValidateUtils.checkNotNull(getRandomFactory(), "RandomFactory not set");
-
- if (getIoServiceFactoryFactory() == null) {
- setIoServiceFactoryFactory(new DefaultIoServiceFactoryFactory());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/common/kex/dh/AbstractDHKeyExchange.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/kex/dh/AbstractDHKeyExchange.java b/sshd-core/src/main/java/org/apache/sshd/common/kex/dh/AbstractDHKeyExchange.java
index 3da8692..ad92d2f 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/kex/dh/AbstractDHKeyExchange.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/kex/dh/AbstractDHKeyExchange.java
@@ -23,7 +23,7 @@ import org.apache.sshd.common.digest.Digest;
import org.apache.sshd.common.kex.KeyExchange;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.session.SessionHolder;
-import org.apache.sshd.common.session.impl.AbstractSession;
+import org.apache.sshd.common.session.helpers.AbstractSession;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.logging.AbstractLoggingBean;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpHelper.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpHelper.java b/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpHelper.java
index f415db3..09ea724 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpHelper.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpHelper.java
@@ -46,9 +46,9 @@ import java.util.concurrent.TimeUnit;
import org.apache.sshd.common.SshException;
import org.apache.sshd.common.file.util.MockPath;
import org.apache.sshd.common.scp.ScpTransferEventListener.FileOperation;
-import org.apache.sshd.common.scp.impl.DefaultScpFileOpener;
-import org.apache.sshd.common.scp.impl.LocalFileScpSourceStreamResolver;
-import org.apache.sshd.common.scp.impl.LocalFileScpTargetStreamResolver;
+import org.apache.sshd.common.scp.helpers.DefaultScpFileOpener;
+import org.apache.sshd.common.scp.helpers.LocalFileScpSourceStreamResolver;
+import org.apache.sshd.common.scp.helpers.LocalFileScpTargetStreamResolver;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.session.SessionHolder;
import org.apache.sshd.common.util.GenericUtils;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/common/scp/helpers/DefaultScpFileOpener.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/scp/helpers/DefaultScpFileOpener.java b/sshd-core/src/main/java/org/apache/sshd/common/scp/helpers/DefaultScpFileOpener.java
new file mode 100644
index 0000000..cdf39d4
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/scp/helpers/DefaultScpFileOpener.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.common.scp.helpers;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.OpenOption;
+import java.nio.file.Path;
+import java.util.Arrays;
+
+import org.apache.sshd.common.scp.ScpFileOpener;
+import org.apache.sshd.common.session.Session;
+import org.apache.sshd.common.util.logging.AbstractLoggingBean;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class DefaultScpFileOpener extends AbstractLoggingBean implements ScpFileOpener {
+ public static final DefaultScpFileOpener INSTANCE = new DefaultScpFileOpener();
+
+ public DefaultScpFileOpener() {
+ super();
+ }
+
+ @Override
+ public InputStream openRead(Session session, Path file, OpenOption... options) throws IOException {
+ if (log.isDebugEnabled()) {
+ log.debug("openRead({}) file={}, options={}",
+ session, file, Arrays.toString(options));
+ }
+
+ return Files.newInputStream(file, options);
+ }
+
+ @Override
+ public OutputStream openWrite(Session session, Path file, OpenOption... options) throws IOException {
+ if (log.isDebugEnabled()) {
+ log.debug("openWrite({}) file={}, options={}",
+ session, file, Arrays.toString(options));
+ }
+
+ return Files.newOutputStream(file, options);
+ }
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/common/scp/helpers/LocalFileScpSourceStreamResolver.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/scp/helpers/LocalFileScpSourceStreamResolver.java b/sshd-core/src/main/java/org/apache/sshd/common/scp/helpers/LocalFileScpSourceStreamResolver.java
new file mode 100644
index 0000000..0c2196e
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/scp/helpers/LocalFileScpSourceStreamResolver.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.common.scp.helpers;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.OpenOption;
+import java.nio.file.Path;
+import java.nio.file.attribute.BasicFileAttributeView;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.nio.file.attribute.PosixFilePermission;
+import java.util.Collection;
+import java.util.Set;
+
+import org.apache.sshd.common.scp.ScpFileOpener;
+import org.apache.sshd.common.scp.ScpSourceStreamResolver;
+import org.apache.sshd.common.scp.ScpTimestamp;
+import org.apache.sshd.common.session.Session;
+import org.apache.sshd.common.util.ValidateUtils;
+import org.apache.sshd.common.util.io.IoUtils;
+import org.apache.sshd.common.util.logging.AbstractLoggingBean;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class LocalFileScpSourceStreamResolver extends AbstractLoggingBean implements ScpSourceStreamResolver {
+ protected final Path path;
+ protected final ScpFileOpener opener;
+ protected final Path name;
+ protected final Set<PosixFilePermission> perms;
+ protected final long size;
+ protected final ScpTimestamp time;
+
+ public LocalFileScpSourceStreamResolver(Path path, ScpFileOpener opener) throws IOException {
+ this.path = ValidateUtils.checkNotNull(path, "No path specified");
+ this.opener = (opener == null) ? DefaultScpFileOpener.INSTANCE : opener;
+ this.name = path.getFileName();
+ this.perms = IoUtils.getPermissions(path);
+
+ BasicFileAttributes basic = Files.getFileAttributeView(path, BasicFileAttributeView.class).readAttributes();
+ this.size = basic.size();
+ this.time = new ScpTimestamp(basic.lastModifiedTime().toMillis(), basic.lastAccessTime().toMillis());
+ }
+
+ @Override
+ public String getFileName() throws IOException {
+ return name.toString();
+ }
+
+ @Override
+ public Collection<PosixFilePermission> getPermissions() throws IOException {
+ return perms;
+ }
+
+ @Override
+ public ScpTimestamp getTimestamp() throws IOException {
+ return time;
+ }
+
+ @Override
+ public long getSize() throws IOException {
+ return size;
+ }
+
+ @Override
+ public Path getEventListenerFilePath() {
+ return path;
+ }
+
+ @Override
+ public InputStream resolveSourceStream(Session session, OpenOption... options) throws IOException {
+ return opener.openRead(session, getEventListenerFilePath(), options);
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(getEventListenerFilePath());
+ }
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/common/scp/helpers/LocalFileScpTargetStreamResolver.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/scp/helpers/LocalFileScpTargetStreamResolver.java b/sshd-core/src/main/java/org/apache/sshd/common/scp/helpers/LocalFileScpTargetStreamResolver.java
new file mode 100644
index 0000000..5a97ca1
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/scp/helpers/LocalFileScpTargetStreamResolver.java
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.common.scp.helpers;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.StreamCorruptedException;
+import java.nio.file.AccessDeniedException;
+import java.nio.file.Files;
+import java.nio.file.LinkOption;
+import java.nio.file.OpenOption;
+import java.nio.file.Path;
+import java.nio.file.attribute.BasicFileAttributeView;
+import java.nio.file.attribute.FileTime;
+import java.nio.file.attribute.PosixFilePermission;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.sshd.common.scp.ScpFileOpener;
+import org.apache.sshd.common.scp.ScpTargetStreamResolver;
+import org.apache.sshd.common.scp.ScpTimestamp;
+import org.apache.sshd.common.session.Session;
+import org.apache.sshd.common.util.io.IoUtils;
+import org.apache.sshd.common.util.logging.AbstractLoggingBean;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class LocalFileScpTargetStreamResolver extends AbstractLoggingBean implements ScpTargetStreamResolver {
+ protected final Path path;
+ protected final ScpFileOpener opener;
+ protected final Boolean status;
+ private Path file;
+
+ public LocalFileScpTargetStreamResolver(Path path, ScpFileOpener opener) throws IOException {
+ LinkOption[] linkOptions = IoUtils.getLinkOptions(false);
+ this.status = IoUtils.checkFileExists(path, linkOptions);
+ if (status == null) {
+ throw new AccessDeniedException("Receive target file path existence status cannot be determined: " + path);
+ }
+
+ this.path = path;
+ this.opener = (opener == null) ? DefaultScpFileOpener.INSTANCE : opener;
+ }
+
+ @Override
+ public OutputStream resolveTargetStream(Session session, String name, long length,
+ Set<PosixFilePermission> perms, OpenOption... options) throws IOException {
+ if (file != null) {
+ throw new StreamCorruptedException("resolveTargetStream(" + name + ")[" + perms + "] already resolved: " + file);
+ }
+
+ LinkOption[] linkOptions = IoUtils.getLinkOptions(false);
+ if (status && Files.isDirectory(path, linkOptions)) {
+ String localName = name.replace('/', File.separatorChar); // in case we are running on Windows
+ file = path.resolve(localName);
+ } else if (status && Files.isRegularFile(path, linkOptions)) {
+ file = path;
+ } else if (!status) {
+ Path parent = path.getParent();
+
+ Boolean parentStatus = IoUtils.checkFileExists(parent, linkOptions);
+ if (parentStatus == null) {
+ throw new AccessDeniedException("Receive file parent (" + parent + ") existence status cannot be determined for " + path);
+ }
+
+ if (parentStatus && Files.isDirectory(parent, linkOptions)) {
+ file = path;
+ }
+ }
+
+ if (file == null) {
+ throw new IOException("Can not write to " + path);
+ }
+
+ Boolean fileStatus = IoUtils.checkFileExists(file, linkOptions);
+ if (fileStatus == null) {
+ throw new AccessDeniedException("Receive file existence status cannot be determined: " + file);
+ }
+
+ if (fileStatus) {
+ if (Files.isDirectory(file, linkOptions)) {
+ throw new IOException("File is a directory: " + file);
+ }
+
+ if (!Files.isWritable(file)) {
+ throw new IOException("Can not write to file: " + file);
+ }
+ }
+
+ if (log.isTraceEnabled()) {
+ log.trace("resolveTargetStream(" + name + "): " + file);
+ }
+
+ return opener.openWrite(session, file, options);
+ }
+
+ @Override
+ public Path getEventListenerFilePath() {
+ if (file == null) {
+ return path;
+ } else {
+ return file;
+ }
+ }
+
+ @Override
+ public void postProcessReceivedData(String name, boolean preserve, Set<PosixFilePermission> perms, ScpTimestamp time) throws IOException {
+ if (file == null) {
+ throw new StreamCorruptedException("postProcessReceivedData(" + name + ")[" + perms + "] No currently resolved data");
+ }
+
+ if (preserve) {
+ updateFileProperties(name, file, perms, time);
+ }
+ }
+
+ protected void updateFileProperties(String name, Path path, Set<PosixFilePermission> perms, ScpTimestamp time) throws IOException {
+ if (log.isTraceEnabled()) {
+ log.trace("updateFileProperties(" + name + ")[" + path + "] permissions: " + perms);
+ }
+ IoUtils.setPermissions(path, perms);
+
+ if (time != null) {
+ BasicFileAttributeView view = Files.getFileAttributeView(path, BasicFileAttributeView.class);
+ FileTime lastModified = FileTime.from(time.getLastModifiedTime(), TimeUnit.MILLISECONDS);
+ FileTime lastAccess = FileTime.from(time.getLastAccessTime(), TimeUnit.MILLISECONDS);
+ if (log.isTraceEnabled()) {
+ log.trace("updateFileProperties(" + name + ")[" + path + "] last-modified=" + lastModified + ", last-access=" + lastAccess);
+ }
+
+ view.setTimes(lastModified, lastAccess, null);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(getEventListenerFilePath());
+ }
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/common/scp/impl/DefaultScpFileOpener.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/scp/impl/DefaultScpFileOpener.java b/sshd-core/src/main/java/org/apache/sshd/common/scp/impl/DefaultScpFileOpener.java
deleted file mode 100644
index 0545185..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/common/scp/impl/DefaultScpFileOpener.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.sshd.common.scp.impl;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.file.Files;
-import java.nio.file.OpenOption;
-import java.nio.file.Path;
-import java.util.Arrays;
-
-import org.apache.sshd.common.scp.ScpFileOpener;
-import org.apache.sshd.common.session.Session;
-import org.apache.sshd.common.util.logging.AbstractLoggingBean;
-
-/**
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public class DefaultScpFileOpener extends AbstractLoggingBean implements ScpFileOpener {
- public static final DefaultScpFileOpener INSTANCE = new DefaultScpFileOpener();
-
- public DefaultScpFileOpener() {
- super();
- }
-
- @Override
- public InputStream openRead(Session session, Path file, OpenOption... options) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug("openRead({}) file={}, options={}",
- session, file, Arrays.toString(options));
- }
-
- return Files.newInputStream(file, options);
- }
-
- @Override
- public OutputStream openWrite(Session session, Path file, OpenOption... options) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug("openWrite({}) file={}, options={}",
- session, file, Arrays.toString(options));
- }
-
- return Files.newOutputStream(file, options);
- }
-}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/common/scp/impl/LocalFileScpSourceStreamResolver.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/scp/impl/LocalFileScpSourceStreamResolver.java b/sshd-core/src/main/java/org/apache/sshd/common/scp/impl/LocalFileScpSourceStreamResolver.java
deleted file mode 100644
index 9a3a5c3..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/common/scp/impl/LocalFileScpSourceStreamResolver.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.sshd.common.scp.impl;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.OpenOption;
-import java.nio.file.Path;
-import java.nio.file.attribute.BasicFileAttributeView;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.nio.file.attribute.PosixFilePermission;
-import java.util.Collection;
-import java.util.Set;
-
-import org.apache.sshd.common.scp.ScpFileOpener;
-import org.apache.sshd.common.scp.ScpSourceStreamResolver;
-import org.apache.sshd.common.scp.ScpTimestamp;
-import org.apache.sshd.common.session.Session;
-import org.apache.sshd.common.util.ValidateUtils;
-import org.apache.sshd.common.util.io.IoUtils;
-import org.apache.sshd.common.util.logging.AbstractLoggingBean;
-
-/**
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public class LocalFileScpSourceStreamResolver extends AbstractLoggingBean implements ScpSourceStreamResolver {
- protected final Path path;
- protected final ScpFileOpener opener;
- protected final Path name;
- protected final Set<PosixFilePermission> perms;
- protected final long size;
- protected final ScpTimestamp time;
-
- public LocalFileScpSourceStreamResolver(Path path, ScpFileOpener opener) throws IOException {
- this.path = ValidateUtils.checkNotNull(path, "No path specified");
- this.opener = (opener == null) ? DefaultScpFileOpener.INSTANCE : opener;
- this.name = path.getFileName();
- this.perms = IoUtils.getPermissions(path);
-
- BasicFileAttributes basic = Files.getFileAttributeView(path, BasicFileAttributeView.class).readAttributes();
- this.size = basic.size();
- this.time = new ScpTimestamp(basic.lastModifiedTime().toMillis(), basic.lastAccessTime().toMillis());
- }
-
- @Override
- public String getFileName() throws IOException {
- return name.toString();
- }
-
- @Override
- public Collection<PosixFilePermission> getPermissions() throws IOException {
- return perms;
- }
-
- @Override
- public ScpTimestamp getTimestamp() throws IOException {
- return time;
- }
-
- @Override
- public long getSize() throws IOException {
- return size;
- }
-
- @Override
- public Path getEventListenerFilePath() {
- return path;
- }
-
- @Override
- public InputStream resolveSourceStream(Session session, OpenOption... options) throws IOException {
- return opener.openRead(session, getEventListenerFilePath(), options);
- }
-
- @Override
- public String toString() {
- return String.valueOf(getEventListenerFilePath());
- }
-}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/common/scp/impl/LocalFileScpTargetStreamResolver.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/scp/impl/LocalFileScpTargetStreamResolver.java b/sshd-core/src/main/java/org/apache/sshd/common/scp/impl/LocalFileScpTargetStreamResolver.java
deleted file mode 100644
index 7d1b78b..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/common/scp/impl/LocalFileScpTargetStreamResolver.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.sshd.common.scp.impl;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.StreamCorruptedException;
-import java.nio.file.AccessDeniedException;
-import java.nio.file.Files;
-import java.nio.file.LinkOption;
-import java.nio.file.OpenOption;
-import java.nio.file.Path;
-import java.nio.file.attribute.BasicFileAttributeView;
-import java.nio.file.attribute.FileTime;
-import java.nio.file.attribute.PosixFilePermission;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.sshd.common.scp.ScpFileOpener;
-import org.apache.sshd.common.scp.ScpTargetStreamResolver;
-import org.apache.sshd.common.scp.ScpTimestamp;
-import org.apache.sshd.common.session.Session;
-import org.apache.sshd.common.util.io.IoUtils;
-import org.apache.sshd.common.util.logging.AbstractLoggingBean;
-
-/**
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public class LocalFileScpTargetStreamResolver extends AbstractLoggingBean implements ScpTargetStreamResolver {
- protected final Path path;
- protected final ScpFileOpener opener;
- protected final Boolean status;
- private Path file;
-
- public LocalFileScpTargetStreamResolver(Path path, ScpFileOpener opener) throws IOException {
- LinkOption[] linkOptions = IoUtils.getLinkOptions(false);
- this.status = IoUtils.checkFileExists(path, linkOptions);
- if (status == null) {
- throw new AccessDeniedException("Receive target file path existence status cannot be determined: " + path);
- }
-
- this.path = path;
- this.opener = (opener == null) ? DefaultScpFileOpener.INSTANCE : opener;
- }
-
- @Override
- public OutputStream resolveTargetStream(Session session, String name, long length,
- Set<PosixFilePermission> perms, OpenOption... options) throws IOException {
- if (file != null) {
- throw new StreamCorruptedException("resolveTargetStream(" + name + ")[" + perms + "] already resolved: " + file);
- }
-
- LinkOption[] linkOptions = IoUtils.getLinkOptions(false);
- if (status && Files.isDirectory(path, linkOptions)) {
- String localName = name.replace('/', File.separatorChar); // in case we are running on Windows
- file = path.resolve(localName);
- } else if (status && Files.isRegularFile(path, linkOptions)) {
- file = path;
- } else if (!status) {
- Path parent = path.getParent();
-
- Boolean parentStatus = IoUtils.checkFileExists(parent, linkOptions);
- if (parentStatus == null) {
- throw new AccessDeniedException("Receive file parent (" + parent + ") existence status cannot be determined for " + path);
- }
-
- if (parentStatus && Files.isDirectory(parent, linkOptions)) {
- file = path;
- }
- }
-
- if (file == null) {
- throw new IOException("Can not write to " + path);
- }
-
- Boolean fileStatus = IoUtils.checkFileExists(file, linkOptions);
- if (fileStatus == null) {
- throw new AccessDeniedException("Receive file existence status cannot be determined: " + file);
- }
-
- if (fileStatus) {
- if (Files.isDirectory(file, linkOptions)) {
- throw new IOException("File is a directory: " + file);
- }
-
- if (!Files.isWritable(file)) {
- throw new IOException("Can not write to file: " + file);
- }
- }
-
- if (log.isTraceEnabled()) {
- log.trace("resolveTargetStream(" + name + "): " + file);
- }
-
- return opener.openWrite(session, file, options);
- }
-
- @Override
- public Path getEventListenerFilePath() {
- if (file == null) {
- return path;
- } else {
- return file;
- }
- }
-
- @Override
- public void postProcessReceivedData(String name, boolean preserve, Set<PosixFilePermission> perms, ScpTimestamp time) throws IOException {
- if (file == null) {
- throw new StreamCorruptedException("postProcessReceivedData(" + name + ")[" + perms + "] No currently resolved data");
- }
-
- if (preserve) {
- updateFileProperties(name, file, perms, time);
- }
- }
-
- protected void updateFileProperties(String name, Path path, Set<PosixFilePermission> perms, ScpTimestamp time) throws IOException {
- if (log.isTraceEnabled()) {
- log.trace("updateFileProperties(" + name + ")[" + path + "] permissions: " + perms);
- }
- IoUtils.setPermissions(path, perms);
-
- if (time != null) {
- BasicFileAttributeView view = Files.getFileAttributeView(path, BasicFileAttributeView.class);
- FileTime lastModified = FileTime.from(time.getLastModifiedTime(), TimeUnit.MILLISECONDS);
- FileTime lastAccess = FileTime.from(time.getLastAccessTime(), TimeUnit.MILLISECONDS);
- if (log.isTraceEnabled()) {
- log.trace("updateFileProperties(" + name + ")[" + path + "] last-modified=" + lastModified + ", last-access=" + lastAccess);
- }
-
- view.setTimes(lastModified, lastAccess, null);
- }
- }
-
- @Override
- public String toString() {
- return String.valueOf(getEventListenerFilePath());
- }
-}