jaas/src/main/java/com/yubico/jaas/impl/YubikeyToUserLDAPMap.java
public boolean is_right_user(String username, String publicId) {
        log.trace("In is_right_user()");
        if (!this.verify_yubikey_owner) {
            log.debug("YubiKey owner verification disabled, returning 'true'");
            return true;
        }
        String ykuser = null;
        try {
            SearchFilter filter = new SearchFilter("({0}={1})", new String[]{this.publicid_attribute, publicId});
            log.debug("Searching for YubiKey publicId with filter: {}", filter.toString());
            Iterator<SearchResult> results = ldap.search(filter, new String[]{this.username_attribute});
            if (results.hasNext()) {
                Attributes results_attributes = results.next().getAttributes();
                log.debug("Found attributes: {}", results_attributes.toString());
                ykuser = results_attributes.get(this.username_attribute).get().toString();
            } else {
                log.debug("No search results");
            }
        } catch (NamingException ex) {
            log.error(ex.getMessage(), ex);
            return false;
        }
        if (ykuser != null) {
            if (!ykuser.equals(username)) {
                log.info("YubiKey " + publicId + " registered to user {}, NOT {}", ykuser, username);
                return false;
            } else {
                log.info("YubiKey " + publicId + " registered to user {}", ykuser);
                return true;
            }
        } else {
            log.info("No record of YubiKey {} found. Returning 'false'.", publicId);
            return false;
        }
    }
public boolean is_right_user(String username, String publicId) {
        log.trace("In is_right_user()");
        if (!this.verify_yubikey_owner) {
            log.debug("YubiKey owner verification disabled, returning 'true'");
            return true;
        }
        String ykuser = null;
        try {
            SearchFilter filter = new SearchFilter("({0}={1})", new String[]{this.publicid_attribute, publicId});
            log.debug("Searching for YubiKey publicId with filter: {}", filter.toString());
            Iterator<SearchResult> results = ldap.search(filter, new String[]{this.username_attribute});
            if (results.hasNext()) {
                Attributes results_attributes = results.next().getAttributes();
                log.debug("Found attributes: {}", results_attributes.toString());
                ykuser = results_attributes.get(this.username_attribute).get().toString();
            } else {
                log.debug("No search results");
            }
        } catch (NamingException ex) {
            log.error(ex.getMessage(), ex);
            return false;
        }
        if (ykuser != null) {
            if (!ykuser.equals(username)) {
                log.info("YubiKey " + publicId + " registered to user {}, NOT {}", ykuser, username);
                return false;
            } else {
                log.info("YubiKey " + publicId + " registered to user {}", ykuser);
                return true;
            }
        } else {
            log.info("No record of YubiKey {} found. Returning 'false'.", publicId);
            return false;
        }
    }
public boolean is_right_user ( String username , String publicId ) { log . trace ( "In is_right_user()" ) ; if ( ! this . verify_yubikey_owner ) { log . debug ( "YubiKey owner verification disabled, returning 'true'" ) ; return true ; } String ykuser = null ; try { SearchFilter filter = new SearchFilter ( "({0}={1})" , new String [ ] { this . publicid_attribute , publicId } ) ; log . debug ( "Searching for YubiKey publicId with filter: {}" , filter . toString ( ) ) ; Iterator < SearchResult > results = ldap . search ( filter , new String [ ] { this . username_attribute } ) ; if ( results . hasNext ( ) ) { Attributes results_attributes = results . next ( ) . getAttributes ( ) ; log . debug ( "Found attributes: {}" , results_attributes . toString ( ) ) ; ykuser = results_attributes . get ( this . username_attribute ) . get ( ) . toString ( ) ; } else { log . debug ( "No search results" ) ; } } catch ( NamingException ex ) { log . error ( ex . getMessage ( ) , ex ) ; return false ; } if ( ykuser != null ) { if ( ! ykuser . equals ( username ) ) { log . info ( "YubiKey " + publicId + " registered to user {}, NOT {}" , ykuser , username ) ; return false ; } else { log . info ( "YubiKey " + publicId + " registered to user {}" , ykuser ) ; return true ; } } else { log . info ( "No record of YubiKey {} found. Returning 'false'." , publicId ) ; return false ; } }
{@inheritDoc}
{