-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
703 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/com/hierynomus/sshj/sftp/RemoteResourceFilterConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (C)2009 - SSHJ Contributors | ||
* | ||
* Licensed 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 com.hierynomus.sshj.sftp; | ||
|
||
import com.hierynomus.sshj.sftp.RemoteResourceSelector.Result; | ||
import net.schmizz.sshj.sftp.RemoteResourceFilter; | ||
|
||
public class RemoteResourceFilterConverter { | ||
|
||
public static RemoteResourceSelector selectorFrom(RemoteResourceFilter filter) { | ||
if (filter == null) { | ||
return RemoteResourceSelector.ALL; | ||
} | ||
|
||
return resource -> filter.accept(resource) ? Result.ACCEPT : Result.CONTINUE; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/com/hierynomus/sshj/sftp/RemoteResourceSelector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (C)2009 - SSHJ Contributors | ||
* | ||
* Licensed 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 com.hierynomus.sshj.sftp; | ||
|
||
import net.schmizz.sshj.sftp.RemoteResourceInfo; | ||
|
||
public interface RemoteResourceSelector { | ||
public static RemoteResourceSelector ALL = new RemoteResourceSelector() { | ||
@Override | ||
public Result select(RemoteResourceInfo resource) { | ||
return Result.ACCEPT; | ||
} | ||
}; | ||
|
||
enum Result { | ||
/** | ||
* Accept the remote resource and add it to the result. | ||
*/ | ||
ACCEPT, | ||
|
||
/** | ||
* Do not add the remote resource to the result and continue with the next. | ||
*/ | ||
CONTINUE, | ||
|
||
/** | ||
* Do not add the remote resource to the result and stop further execution. | ||
*/ | ||
BREAK; | ||
} | ||
|
||
/** | ||
* Decide whether the remote resource should be included in the result and whether execution should continue. | ||
*/ | ||
Result select(RemoteResourceInfo resource); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (C)2009 - SSHJ Contributors | ||
* | ||
* Licensed 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 net.schmizz.sshj.common; | ||
|
||
import java.io.IOException; | ||
import java.util.Base64; | ||
|
||
/** | ||
* <p>Wraps {@link java.util.Base64.Decoder} in order to wrap unchecked {@code IllegalArgumentException} thrown by | ||
* the default Java Base64 decoder here and there.</p> | ||
* | ||
* <p>Please use this class instead of {@link java.util.Base64.Decoder}.</p> | ||
*/ | ||
public class Base64Decoder { | ||
private Base64Decoder() { | ||
} | ||
|
||
public static byte[] decode(byte[] source) throws Base64DecodingException { | ||
try { | ||
return Base64.getDecoder().decode(source); | ||
} catch (IllegalArgumentException err) { | ||
throw new Base64DecodingException(err); | ||
} | ||
} | ||
|
||
public static byte[] decode(String src) throws Base64DecodingException { | ||
try { | ||
return Base64.getDecoder().decode(src); | ||
} catch (IllegalArgumentException err) { | ||
throw new Base64DecodingException(err); | ||
} | ||
} | ||
} |
Oops, something went wrong.