What about this:

    if ("Password".equals(object.getBaseObject().getXClass(getXWikiContext()).get(fieldName).getClassType())) {

Note that when testing String equality is always better to put the string literal first to prevent a NPE.