/* (non-Javadoc)
@see com.tvd12.ezyfox.core.entities.ApiZone#getUserByName(java.lang.String)
553012
@SuppressWarnings("unchecked")
    @Override
	public <T extends ApiUser> T getUserByName(String username) {
	    User sfsUser = getZone().getUserByName(username);
        if(sfsUser != null && sfsUser.containsProperty(APIKey.USER))
            return (T) sfsUser.getProperty(APIKey.USER);
        return null;
	}
517118
@Override
    public Integer getPortalUserId(String userName) {
        final List<Integer> results =
                this.jdbcOperations.queryForList(
                        "SELECT USER_ID FROM UP_USER WHERE USER_NAME=?", Integer.class, userName);
        return DataAccessUtils.singleResult(results);
    }
1300935
@Override
    public String getUsernameFromQuery(final Map<String, List<Object>> query) {
        final List<Object> usernameAttributeValues = query.get(this.usernameAttribute);

        if (usernameAttributeValues == null || usernameAttributeValues.size() == 0) {
            return null;
        }

        final Object firstValue = usernameAttributeValues.get(0);
        if (firstValue == null) {
            return null;
        }

        final String username = StringUtils.trimToNull(String.valueOf(firstValue));
        if (username == null || username.contains(IPersonAttributeDao.WILDCARD)) {
            return null;
        }

        return username;
    }
1185918
private String getUserAccessId(String userName) {

        try {
            SecurityService securityService = securityServiceRef.getService();
            UserRegistryService userRegistryService = securityService.getUserRegistryService();
            UserRegistry userRegistry = userRegistryService.getUserRegistry();
            String realm = userRegistry.getRealm();
            String uniqueId = userRegistry.getUniqueUserId(userName);
            return AccessIdUtil.createAccessId(AccessIdUtil.TYPE_USER, realm, uniqueId);
        } catch (EntryNotFoundException e) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Caught exception getting the access id for "
                             + userName + ": " + e);
            }
        } catch (RegistryException e) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Caught exception getting the access id for "
                             + userName + ": " + e);
            }
        }
        return null;
    }
880834
public OvhCustomerUser serviceName_dedicatedHorizon_customerUser_username_GET(String serviceName, String username) throws IOException {
		String qPath = "/horizonView/{serviceName}/dedicatedHorizon/customerUser/{username}";
		StringBuilder sb = path(qPath, serviceName, username);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhCustomerUser.class);
	}
95649
@SuppressWarnings({ "squid:S1166" })
    private static UserDetails loadUserByUsername(final String username) {
        final UserDetailsService userDetailsService = SpringContextHelper.getBean(UserDetailsService.class);
        try {
            return userDetailsService.loadUserByUsername(username);
        } catch (final UsernameNotFoundException e) {
            return new User(username, "", Collections.emptyList());
        }
    }
1346371
public User getUser(String userName) {
        User result = null;
        for (User item : getUsersList()) {
            if (item.getName().equals(userName)) {
                result = item;
            }
        }
        return result;
    }
975489
public String getUser() {
    if (user != null) {
      return user;
    }
    return urlParser != null ? urlParser.getUsername() : null;
  }
885585
@SuppressWarnings("unchecked")
    public UserInfo getUserInfo(String username) throws Exception {

        String pwdCredential = getUserCredentials(username);

        if (pwdCredential == null) {
            return null;
        }

        pwdCredential = convertCredentialLdapToJetty(pwdCredential);
        pwdCredential = decodeBase64EncodedPwd(pwdCredential);
        Credential credential = Credential.getCredential(pwdCredential);
        List roles = getUserRoles(_rootContext, username);

        return new UserInfo(username, credential, roles);
    }
331693
private String getSimpleUsername(String username) {
        int lastSlash = username.lastIndexOf('\\');
        if (lastSlash > -1) {
            username = username.substring(lastSlash + 1);
        }

        return username;
    }
1308769
private static String getCurrentUserName() {
        Authentication a = SecurityContextHolder.getContext().getAuthentication();
        if (a == null) return null;
        org.springframework.security.core.userdetails.User u =
                (org.springframework.security.core.userdetails.User)
                        a.getPrincipal();
        if (u == null) return null;
        return u.getUsername();
    }
231931
@Override
    public IPersonAttributes getSelf(ExternalContext externalContext) {

        final PortletRequest portletRequest = (PortletRequest) externalContext.getNativeRequest();
        final String username = portletRequest.getRemoteUser();

        return this.personAttributeDao.getPerson(username);
    }
932652
public String getUserName(boolean notAlternateUser) 
  {
    if (tc.isEntryEnabled()) 
       SibTr.entry(tc, "getUserName", 
         new Object[]{new Boolean(notAlternateUser)});
                   
    String userName = null;
    
    if(!notAlternateUser // this catches the case where we want the
                         // user associated with the subject
       && isAlternateUserBased())                             
    {       
      userName = alternateUser;
    }
    else if(isSubjectBased())
    {     
      if(authorisationUtils != null)
      {
        userName = authorisationUtils.getUserName(subject);
      }      
    }
    else if(isUserIdBased())
    {       
      userName = userId;
    }
    else if(isMsgBased())
    {       
      userName = msg.getSecurityUserid();
    }
 
    if (tc.isEntryEnabled()) 
       SibTr.exit(tc, "getUserName", userName);        
    return userName;
  }
661040
private PortalUser getPortalUser(final String userName) {
        return jdbcOperations.execute(
                (ConnectionCallback<PortalUser>)
                        con -> {
                            PortalUser portalUser = null;
                            PreparedStatement pstmt = null;

                            try {
                                String query = "SELECT USER_ID FROM UP_USER WHERE USER_NAME=?";

                                pstmt = con.prepareStatement(query);
                                pstmt.setString(1, userName);

                                ResultSet rs = null;
                                try {
                                    if (log.isDebugEnabled())
                                        log.debug(
                                                "RDBMUserIdentityStore::getPortalUID(userName="
                                                        + userName
                                                        + "): "
                                                        + query);
                                    rs = pstmt.executeQuery();
                                    if (rs.next()) {
                                        portalUser = new PortalUser();
                                        portalUser.setUserId(rs.getInt("USER_ID"));
                                        portalUser.setUserName(userName);
                                    }
                                } finally {
                                    try {
                                        if (rs != null) {
                                            rs.close();
                                        }
                                    } catch (Exception e) {
                                    }
                                }
                            } finally {
                                try {
                                    if (pstmt != null) {
                                        pstmt.close();
                                    }
                                } catch (Exception e) {
                                }
                            }

                            return portalUser;
                        });
    }
354282
protected ApplicationUser findApplicationUser(final String userName) {
        return queryResultsCache.execute(new Callable<ApplicationUser>() {
            @Override
            public ApplicationUser call() throws Exception {
                return findApplicationUserNoCache(userName);
            }
        }, TenantedAuthorizationFacetDefault.class, "findApplicationUser", userName);
    }
108941
@Nullable
  @OverrideOnDemand
  protected IUser getUserOfLoginName (@Nullable final String sLoginName)
  {
    return PhotonSecurityManager.getUserMgr ().getUserOfLoginName (sLoginName);
  }
776799
@Override
    protected List<IPersonAttributes> getPeopleForQuery(QueryBuilder queryBuilder, String queryUserName) {

        final String currentUserName = currentUserProvider.getCurrentUserName();
        ;
        if (currentUserName == null) {
            this.logger.warn("A null name was returned by the currentUserProvider, returning null.");
            return Collections.emptyList();
        }

        if (currentUserName.equals(queryUserName)) {
            if (this.logger.isDebugEnabled()) {
                this.logger.debug("Adding attributes from the SAMLCredential for user " + currentUserName);
            }

            Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
            if (authentication != null) {
                SAMLCredential credential = (SAMLCredential) authentication.getCredentials();

                if (credential != null) {

                    // Provide some optional, TRACE-level logging for what we found
                    if (logger.isTraceEnabled()) {
                        StringBuilder msg = new StringBuilder();
                        msg.append("Credential obtained!");
                        for (Attribute a : credential.getAttributes()) {
                            msg.append("\n    a.getName()=").append(a.getName())
                                    .append("\n    a.getFriendlyName()=").append(a.getFriendlyName());
                            for (XMLObject xmlo : a.getAttributeValues()) {
                                    String str = extractStringValue(xmlo);
                                    msg.append("\n        value="+str);
                            }
                        }
                        logger.trace(msg.toString());
                    }

                    // Marshall what we found into an (unmapped) IPersonAttributes object
                    final Map<String, List<Object>> attributes = new HashMap<>();
                    for (Attribute a : credential.getAttributes()) {
                        List<Object> list = new ArrayList<Object>();
                        for (XMLObject xmlo : a.getAttributeValues()) {
                            String str = extractStringValue(xmlo);
                            if (str != null) {
                                list.add(str);
                            }
                        }
                        attributes.put(a.getName(), list);
                    }
                    final IPersonAttributes personAttributes = new CaseInsensitiveNamedPersonImpl(currentUserName, attributes);
                    return Collections.singletonList(personAttributes);
                }

            }
        } else {
            // Optionally log the fact that we _didn't_ add attributes
            if (logger.isTraceEnabled()) {
                logger.trace("Skipping this DAO because "
                        + "!currentUserName.equals(queryUserName);  currentUserName="
                        + currentUserName + ", queryUserName=" + queryUserName);
            }
        }

        return Collections.emptyList();

    }