Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Expired password management on aix

Help
mariag
2008-12-11
2013-05-28
  • mariag
    mariag
    2008-12-11

    Hello,
    I'm looking for a way to notify my application if the password used to establish the ssh connection is expired.
    This is the source of code I've at the moment:
    ...............
    package com.ibm.tivoli.websphere.customSecurity.sample;

    import com.jcraft.jsch.JSch;
    import com.jcraft.jsch.JSchException;
    import com.jcraft.jsch.Session;

    public class TestSSH {

    private final int TIMEOUT = 1500;
    public boolean openSshConnection(String user, String password) {

    Session session = null;
    try {
    JSch jsch = new JSch();
    session = jsch.getSession(user, "r22p02.tod.torolab.ibm.com", 22);
    session.setTimeout(TIMEOUT);
    com.jcraft.jsch.UserInfo ui = new TpmUserInfo(password);
    session.setUserInfo(ui);
    session.connect();
    } catch (JSchException e) { 
    System.out.println("Authentication error opening ssh session on port" + 22);
    System.out.println("Reason: "
    + e.getMessage());
    return false;
    } finally {

    if (session != null)
    session.disconnect();
    }
    return true;
    }
    /**
    * @param args
    */
    public static void main(String[] args) {
    try {
    TestSSH osim = new TestSSH();
    osim.openSshConnection("admin", "Pwd");
    } catch (Exception ex) {
    System.out.println ("Exception: " + ex.getMessage());
    }

    }

    }
    .......................

    I'd like to modify it in some how to add the logic to throw an exception if the: SSH_MSG_USERAUTH_PASSWD_CHANGEREQ is returned.
    (something similar to what is done in the UserAuthPassword class).
    Any help is appreciated...

    Thanks in advance
    Maria