org.apache.sshd.server.ServerFactoryManager Java Examples
The following examples show how to use
org.apache.sshd.server.ServerFactoryManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WelcomeBannerTest.java From termd with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { sshd = setupTestServer(); PropertyResolverUtils.updateProperty(sshd, ServerFactoryManager.WELCOME_BANNER, WELCOME); sshd.start(); port = sshd.getPort(); }
Example #2
Source File: SinglePublicKeyAuthTest.java From termd with Apache License 2.0 | 5 votes |
@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(); }
Example #3
Source File: AsyncUserAuthService.java From aesh-readline with Apache License 2.0 | 5 votes |
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)); } }
Example #4
Source File: WelcomeBannerTest.java From termd with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { sshd = setupTestServer(); PropertyResolverUtils.updateProperty(sshd, ServerFactoryManager.WELCOME_BANNER, WELCOME); sshd.start(); port = sshd.getPort(); }
Example #5
Source File: SinglePublicKeyAuthTest.java From termd with Apache License 2.0 | 5 votes |
@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(); }
Example #6
Source File: AsyncUserAuthService.java From termd with Apache License 2.0 | 4 votes |
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<NamedFactory<UserAuth>>(factories); // Get authentication methods authMethods = new ArrayList<List<String>>(); String mths = PropertyResolverUtils.getString(s, ServerFactoryManager.AUTH_METHODS); if (GenericUtils.isEmpty(mths)) { for (NamedFactory<UserAuth> uaf : factories) { authMethods.add(new ArrayList<String>(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<String>(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)); } }
Example #7
Source File: AsyncUserAuthService.java From termd with Apache License 2.0 | 4 votes |
public ServerFactoryManager getFactoryManager() { return serverSession.getFactoryManager(); }
Example #8
Source File: AuthenticationTest.java From termd with Apache License 2.0 | 4 votes |
public TestSession(ServerFactoryManager server, IoSession ioSession) throws Exception { super(server, ioSession); }
Example #9
Source File: AsyncUserAuthService.java From aesh-readline with Apache License 2.0 | 4 votes |
private ServerFactoryManager getFactoryManager() { return session.getFactoryManager(); }
Example #10
Source File: AsyncUserAuthService.java From termd with Apache License 2.0 | 4 votes |
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)); } }
Example #11
Source File: AsyncUserAuthService.java From termd with Apache License 2.0 | 4 votes |
public ServerFactoryManager getFactoryManager() { return serverSession.getFactoryManager(); }
Example #12
Source File: AuthenticationTest.java From termd with Apache License 2.0 | 4 votes |
public TestSession(ServerFactoryManager server, IoSession ioSession) throws Exception { super(server, ioSession); }
Example #13
Source File: Server.java From sftpserver with Apache License 2.0 | 4 votes |
private void hackVersion() { PropertyResolverUtils.updateProperty(sshd, ServerFactoryManager.SERVER_IDENTIFICATION, "SSHD"); }