On 05.08.21 08:02 , Sheshu Vadrevu wrote:
Have implemented both ServerUserAuthService and Factory too.
But session.getUsername() is always null. So I am not able to set this
property to different values for different users.
Could you please show me a way to get the username.
Thank you for your suggestions.
*public* *abstract* *class* ECGServerUserAuthService *extends*
ServerUserAuthService {
*protected**static**final*String */PASSWORD_AUTHENTICATION/*= "password";
*protected**static**final*String */PUBLICKEY_AUTHENTICATION/*= "publickey";
*public* ECGServerUserAuthService(Session s) *throws* IOException {
*super*(s);
String username = s.getUsername();
*/log/*.info("username: "+username);
}
@Override
*public*Map<String, Object> getProperties() {
ServerSession serverSession = *super*.getServerSession();
Map<String, Object> properties = *super*.getProperties();
properties.put("auth-methods", String./join/(",
",getRequiredAuthentications()));
*return*properties;
}
*public* *abstract* String[] getRequiredAuthentications();
}
Of course session.getUserName() will be null in the constructor: the
session is not authenticated yet. Only when a SSH_MSG_USERAUTH_REQUEST
comes in you can get the username *from the request*. (Still before that
user is authenticated -- but you could use it to decide then which
authentications to permit or require.) So on the first
SSH_MSG_USERAUTH_REQUEST for the "none" authentication you could set the
expected authentications and then return them in the reply to the client.
HTH,
Thomas
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org