public void authorize ( String user , String password ) throws IOException , ServerException { Reply userReply = null ; try { userReply = controlChannel . exchange ( new Command ( "USER" , user ) ) ; } catch ( FTPReplyParseException rpe ) { throw ServerException . embedFTPReplyParseException ( rpe ) ; } if ( Reply . isPositiveIntermediate ( userReply ) ) { Reply passReply = null ; try { passReply = controlChannel . exchange ( new Command ( "PASS" , password ) ) ; } catch ( FTPReplyParseException rpe ) { throw ServerException . embedFTPReplyParseException ( rpe ) ; } if ( ! Reply . isPositiveCompletion ( passReply ) ) { throw ServerException . embedUnexpectedReplyCodeException ( new UnexpectedReplyCodeException ( passReply ) , "Bad password." ) ; } // i'm logged in } else if ( Reply . isPositiveCompletion ( userReply ) ) { // i'm logged in } else { throw ServerException . embedUnexpectedReplyCodeException ( new UnexpectedReplyCodeException ( userReply ) , "Bad user." ) ; } this . session . authorized = true ; this . username = user ; }
Performs user authorization with specified user and password .