本文整理汇总了Java中org.apache.sshd.server.ServerFactoryManager类的典型用法代码示例。如果您正苦于以下问题:Java ServerFactoryManager类的具体用法?Java ServerFactoryManager怎么用?Java ServerFactoryManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ServerFactoryManager类属于org.apache.sshd.server包,在下文中一共展示了ServerFactoryManager类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AsyncUserAuthService
import org.apache.sshd.server.ServerFactoryManager; //导入依赖的package包/类
public AsyncUserAuthService(Session s) throws SshException {
ValidateUtils.checkTrue(s instanceof ServerSession, "Server side service used on client side");
if (s.isAuthenticated()) {
throw new SshException("Session already authenticated");
}
this.session = (ServerSession) s;
maxAuthRequests = session.getIntProperty(ServerFactoryManager.MAX_AUTH_REQUESTS, DEFAULT_MAX_AUTH_REQUESTS);
ServerFactoryManager manager = getFactoryManager();
userAuthFactories = new ArrayList<>(manager.getUserAuthFactories());
// Get authentication methods
authMethods = new ArrayList<>();
String mths = FactoryManagerUtils.getString(manager, ServerFactoryManager.AUTH_METHODS);
if (GenericUtils.isEmpty(mths)) {
for (NamedFactory<UserAuth> uaf : manager.getUserAuthFactories()) {
authMethods.add(new ArrayList<>(Collections.singletonList(uaf.getName())));
}
}
else {
for (String mthl : mths.split("\\s")) {
authMethods.add(new ArrayList<>(Arrays.asList(mthl.split(","))));
}
}
// Verify all required methods are supported
for (List<String> l : authMethods) {
for (String m : l) {
NamedFactory<UserAuth> factory = NamedResource.Utils.findByName(m, String.CASE_INSENSITIVE_ORDER, userAuthFactories);
if (factory == null) {
throw new SshException("Configured method is not supported: " + m);
}
}
}
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("Authorized authentication methods: "+ NamedResource.Utils.getNames(userAuthFactories));
}
}
示例2: setUp
import org.apache.sshd.server.ServerFactoryManager; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
sshd = setupTestServer();
PropertyResolverUtils.updateProperty(sshd, ServerFactoryManager.WELCOME_BANNER, WELCOME);
sshd.start();
port = sshd.getPort();
}
示例3: setUp
import org.apache.sshd.server.ServerFactoryManager; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
sshd = setupTestServer();
PropertyResolverUtils.updateProperty(sshd, ServerFactoryManager.AUTH_METHODS, UserAuthPublicKeyFactory.NAME);
sshd.setPublickeyAuthenticator(new PublickeyAuthenticator() {
@SuppressWarnings("synthetic-access")
@Override
public boolean authenticate(String username, PublicKey key, ServerSession session) {
return delegate.authenticate(username, key, session);
}
});
sshd.start();
port = sshd.getPort();
}
示例4: getFactoryManager
import org.apache.sshd.server.ServerFactoryManager; //导入依赖的package包/类
private ServerFactoryManager getFactoryManager() {
return session.getFactoryManager();
}
示例5: AsyncUserAuthService
import org.apache.sshd.server.ServerFactoryManager; //导入依赖的package包/类
public AsyncUserAuthService(Session s) throws SshException {
ValidateUtils.checkTrue(s instanceof ServerSession, "Server side service used on client side");
if (s.isAuthenticated()) {
throw new SshException("Session already authenticated");
}
serverSession = (ServerSession) s;
maxAuthRequests = PropertyResolverUtils.getIntProperty(s, ServerAuthenticationManager.MAX_AUTH_REQUESTS, ServerAuthenticationManager.DEFAULT_MAX_AUTH_REQUESTS);
List<NamedFactory<UserAuth>> factories = ValidateUtils.checkNotNullAndNotEmpty(
serverSession.getUserAuthFactories(), "No user auth factories for %s", s);
userAuthFactories = new ArrayList<>(factories);
// Get authentication methods
authMethods = new ArrayList<>();
String mths = PropertyResolverUtils.getString(s, ServerFactoryManager.AUTH_METHODS);
if (GenericUtils.isEmpty(mths)) {
for (NamedFactory<UserAuth> uaf : factories) {
authMethods.add(new ArrayList<>(Collections.singletonList(uaf.getName())));
}
} else {
if (log.isDebugEnabled()) {
log.debug("ServerUserAuthService({}) using configured methods={}", s, mths);
}
for (String mthl : mths.split("\\s")) {
authMethods.add(new ArrayList<>(Arrays.asList(GenericUtils.split(mthl, ','))));
}
}
// Verify all required methods are supported
for (List<String> l : authMethods) {
for (String m : l) {
NamedFactory<UserAuth> factory = NamedResource.Utils.findByName(m, String.CASE_INSENSITIVE_ORDER, userAuthFactories);
if (factory == null) {
throw new SshException("Configured method is not supported: " + m);
}
}
}
if (log.isDebugEnabled()) {
log.debug("ServerUserAuthService({}) authorized authentication methods: {}",
s, NamedResource.Utils.getNames(userAuthFactories));
}
}
示例6: getFactoryManager
import org.apache.sshd.server.ServerFactoryManager; //导入依赖的package包/类
public ServerFactoryManager getFactoryManager() {
return serverSession.getFactoryManager();
}
示例7: TestSession
import org.apache.sshd.server.ServerFactoryManager; //导入依赖的package包/类
public TestSession(ServerFactoryManager server, IoSession ioSession) throws Exception {
super(server, ioSession);
}
示例8: hackVersion
import org.apache.sshd.server.ServerFactoryManager; //导入依赖的package包/类
private void hackVersion() {
PropertyResolverUtils.updateProperty(sshd, ServerFactoryManager.SERVER_IDENTIFICATION, "SSHD");
}