baiglin opened a new issue, #880: URL: https://github.com/apache/mina-sshd/issues/880
### Description Hi Thomas, I have a question regarding the AttributeRepository context that we can pass while connecting the ssh session. It is a bit confusing from the Java doc to which session it is attached to. I opened a previous ticket where https://github.com/apache/mina-sshd/issues/439 where I needed to override at runtime the different algorithms that we could potentially used to customize them. Thanks to you I managed to do it thanks to listeners SessionListener#sessionCreated(Session session), but after some code changes I saw this AttributeRepository and tried to something more generic to pass my attribute directly from there instead of tryin to match the host and port of the ClientSession. private MyConfig sshdConfiguration; @Override public void sessionCreated(Session session) { InetSocketAddress remoteAddress = (InetSocketAddress)session.getIoSession().getRemoteAddress(); LOG.info("User name {}", session.getUsername()); if (remoteAddress.getHostName().equals(sshdConfiguration.getHost()) && remoteAddress.getPort() == sshdConfiguration.getPort()) { // The do something } } So instead I tried @Override public void sessionCreated(Session session) { LOG.info("User name {}", session.getUsername()); // Not working SshdConfiguration attribute = session.getAttribute(SshdConfiguration.SSHD_CONFIGURATION_ATTRIBUTE_KEY); // Working attribute = ((AttributeRepository)session.getIoSession().getAttribute(AttributeRepository.class)).getAttribute( SshdConfiguration.SSHD_CONFIGURATION_ATTRIBUTE_KEY); } My question is, am I doing good doing this way. Also Why not attached attributes directly to the Session object created directly ? Many Thanks. ### Motivation it would really simplify to pass contextual information when creating a new session. In our application we cannot set default algorithms for all our clients and need to be really flexible regarding the algorithms used. ### Alternatives considered _No response_ ### Additional context _No response_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
