public void changePassword ( String newPassword ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { if ( ! connection ( ) . isSecureConnection ( ) && ! allowSensitiveOperationOverInsecureConnection ) { throw new IllegalStateException ( "Changing password over insecure connection." ) ; } Map < String , String > map = new HashMap <> ( ) ; map . put ( "username" , connection ( ) . getUser ( ) . getLocalpart ( ) . toString ( ) ) ; map . put ( "password" , newPassword ) ; Registration reg = new Registration ( map ) ; reg . setType ( IQ . Type . set ) ; reg . setTo ( connection ( ) . getXMPPServiceDomain ( ) ) ; createStanzaCollectorAndSend ( reg ) . nextResultOrThrow ( ) ; }
Changes the password of the currently logged - in account . This operation can only be performed after a successful login operation has been completed . Not all servers support changing passwords ; an XMPPException will be thrown when that is the case .