private IdSearchResults searchIdentity(IdType idType,String userTokenID,boolean populate) throws IdRepoException, SSOException {
  if (DEBUG.messageEnabled()) {
    DEBUG.message("In searchAutehnticatedUser: idType " + idType);
    DEBUG.message("In getUserProfile : Search for user " + userTokenID);
  }
  IdSearchResults searchResults=null;
  Set returnSet=mergeSet(aliasAttrNames,USER_ATTRIBUTES);
  int maxResults=2;
  int maxTime=0;
  String pattern;
  Map avPairs;
  boolean isRecursive=true;
  IdSearchControl idsc=new IdSearchControl();
  idsc.setRecursive(isRecursive);
  idsc.setTimeOut(maxTime);
  if (populate) {
    idsc.setAllReturnAttributes(true);
  }
 else {
    idsc.setReturnAttributes(returnSet);
  }
  if (DEBUG.messageEnabled()) {
    DEBUG.message("alias attr=" + aliasAttrNames + ", attr="+ USER_ATTRIBUTES+ ",merge="+ returnSet);
  }
  if (DEBUG.messageEnabled()) {
    DEBUG.message("Search for Identity " + userTokenID);
  }
  Set result=Collections.EMPTY_SET;
  try {
    idsc.setMaxResults(0);
    searchResults=amIdRepo.searchIdentities(idType,userTokenID,idsc);
    if (searchResults != null) {
      result=searchResults.getSearchResults();
    }
  }
 catch (  SSOException sso) {
    if (DEBUG.messageEnabled()) {
      DEBUG.message("SSOException Error searching Identity " + " with username " + sso.getMessage());
    }
  }
catch (  IdRepoException e) {
    if (DEBUG.messageEnabled()) {
      DEBUG.message("IdRepoException : Error searching " + " Identities with username : " + e.getMessage());
    }
  }
  if (result.isEmpty() && (aliasAttrNames != null) && (!aliasAttrNames.isEmpty())) {
    if (DEBUG.messageEnabled()) {
      DEBUG.message("No identity found, try Alias attrname.");
    }
    pattern="*";
    avPairs=toAvPairMap(aliasAttrNames,userTokenID);
    if (DEBUG.messageEnabled()) {
      DEBUG.message("Search for Filter (avPairs) :" + avPairs);
      DEBUG.message("userTokenID : " + userTokenID);
      DEBUG.message("userDN : " + userDN);
      DEBUG.message("idType :" + idType);
      DEBUG.message("pattern :" + pattern);
      DEBUG.message("isRecursive :" + isRecursive);
      DEBUG.message("maxResults :" + maxResults);
      DEBUG.message("maxTime :" + maxTime);
      DEBUG.message("returnSet :" + returnSet);
    }
    Set resultAlias=Collections.EMPTY_SET;
    try {
      idsc.setMaxResults(maxResults);
      idsc.setSearchModifiers(IdSearchOpModifier.OR,avPairs);
      searchResults=amIdRepo.searchIdentities(idType,pattern,idsc);
      if (searchResults != null) {
        resultAlias=searchResults.getSearchResults();
      }
      if ((resultAlias.isEmpty()) && (userDN != null) && (!userDN.equalsIgnoreCase(userTokenID))) {
        avPairs=toAvPairMap(aliasAttrNames,userDN);
        if (DEBUG.messageEnabled()) {
          DEBUG.message("Search for Filter (avPairs) " + "with userDN : " + avPairs);
        }
        idsc.setMaxResults(maxResults);
        idsc.setSearchModifiers(IdSearchOpModifier.OR,avPairs);
        searchResults=amIdRepo.searchIdentities(idType,pattern,idsc);
      }
    }
 catch (    SSOException sso) {
      if (DEBUG.messageEnabled()) {
        DEBUG.message("SSOException : Error searching " + "Identities with aliasattrname : " + sso.getMessage());
      }
    }
catch (    IdRepoException e) {
      if (DEBUG.messageEnabled()) {
        DEBUG.message("IdRepoException : Error searching " + "Identities : " + e.getMessage());
      }
    }
  }
  return searchResults;
}

private IdSearchResults searchIdentity ( IdType idType , String userTokenID , boolean populate ) throws IdRepoException , SSOException { if ( DEBUG . messageEnabled ( ) ) { DEBUG . message ( "In searchAutehnticatedUser: idType " + idType ) ; DEBUG . message ( "In getUserProfile : Search for user " + userTokenID ) ; } IdSearchResults searchResults = null ; Set returnSet = mergeSet ( aliasAttrNames , USER_ATTRIBUTES ) ; int maxResults = 2 ; int maxTime = 0 ; String pattern ; Map avPairs ; boolean isRecursive = true ; IdSearchControl idsc = new IdSearchControl ( ) ; idsc . setRecursive ( isRecursive ) ; idsc . setTimeOut ( maxTime ) ; if ( populate ) { idsc . setAllReturnAttributes ( true ) ; } else { idsc . setReturnAttributes ( returnSet ) ; } if ( DEBUG . messageEnabled ( ) ) { DEBUG . message ( "alias attr=" + aliasAttrNames + ", attr=" + USER_ATTRIBUTES + ",merge=" + returnSet ) ; } if ( DEBUG . messageEnabled ( ) ) { DEBUG . message ( "Search for Identity " + userTokenID ) ; } Set result = Collections . EMPTY_SET ; try { idsc . setMaxResults ( 0 ) ; searchResults = amIdRepo . searchIdentities ( idType , userTokenID , idsc ) ; if ( searchResults != null ) { result = searchResults . getSearchResults ( ) ; } } catch ( SSOException sso ) { if ( DEBUG . messageEnabled ( ) ) { DEBUG . message ( "SSOException Error searching Identity " + " with username " + sso . getMessage ( ) ) ; } } catch ( IdRepoException e ) { if ( DEBUG . messageEnabled ( ) ) { DEBUG . message ( "IdRepoException : Error searching " + " Identities with username : " + e . getMessage ( ) ) ; } } if ( result . isEmpty ( ) && ( aliasAttrNames != null ) && ( ! aliasAttrNames . isEmpty ( ) ) ) { if ( DEBUG . messageEnabled ( ) ) { DEBUG . message ( "No identity found, try Alias attrname." ) ; } pattern = "*" ; avPairs = toAvPairMap ( aliasAttrNames , userTokenID ) ; if ( DEBUG . messageEnabled ( ) ) { DEBUG . message ( "Search for Filter (avPairs) :" + avPairs ) ; DEBUG . message ( "userTokenID : " + userTokenID ) ; DEBUG . message ( "userDN : " + userDN ) ; DEBUG . message ( "idType :" + idType ) ; DEBUG . message ( "pattern :" + pattern ) ; DEBUG . message ( "isRecursive :" + isRecursive ) ; DEBUG . message ( "maxResults :" + maxResults ) ; DEBUG . message ( "maxTime :" + maxTime ) ; DEBUG . message ( "returnSet :" + returnSet ) ; } Set resultAlias = Collections . EMPTY_SET ; try { idsc . setMaxResults ( maxResults ) ; idsc . setSearchModifiers ( IdSearchOpModifier . OR , avPairs ) ; searchResults = amIdRepo . searchIdentities ( idType , pattern , idsc ) ; if ( searchResults != null ) { resultAlias = searchResults . getSearchResults ( ) ; } if ( ( resultAlias . isEmpty ( ) ) && ( userDN != null ) && ( ! userDN . equalsIgnoreCase ( userTokenID ) ) ) { avPairs = toAvPairMap ( aliasAttrNames , userDN ) ; if ( DEBUG . messageEnabled ( ) ) { DEBUG . message ( "Search for Filter (avPairs) " + "with userDN : " + avPairs ) ; } idsc . setMaxResults ( maxResults ) ; idsc . setSearchModifiers ( IdSearchOpModifier . OR , avPairs ) ; searchResults = amIdRepo . searchIdentities ( idType , pattern , idsc ) ; } } catch ( SSOException sso ) { if ( DEBUG . messageEnabled ( ) ) { DEBUG . message ( "SSOException : Error searching " + "Identities with aliasattrname : " + sso . getMessage ( ) ) ; } } catch ( IdRepoException e ) { if ( DEBUG . messageEnabled ( ) ) { DEBUG . message ( "IdRepoException : Error searching " + "Identities : " + e . getMessage ( ) ) ; } } } return searchResults ; }
search for identities given the identity type , identity name use common method from lazyconfig . authd for getidentity
