public void setUserStatus(Admin admin, String username, int status) throws AuthorizationDeniedException, FinderException, ApprovalException, WaitingForApprovalException { setUserStatusWithApprovalFlag(admin, username, status, true);
public void setUserStatus(Admin admin, String username, int status, boolean approvalflag) throws AuthorizationDeniedException, FinderException, ApprovalException, WaitingForApprovalException { debug(">setUserStatus(" + username + ", " + status + ")");  int caid = LogConstants.INTERNALCAID; try { UserDataPK pk = new UserDataPK(username); UserDataLocal data1 = home.findByPrimaryKey(pk); caid = data1.getCaId();  if (!authorizedToCA(admin, caid)) { logsession.log(admin, caid, LogEntry.MODULE_RA, new java.util.Date(), username, null, LogEntry.EVENT_ERROR_CHANGEDENDENTITY, "Administrator not authorized to change status of user with current CA."); throw new AuthorizationDeniedException("Administrator not authorized to set status to user with given CA."); }   if (getGlobalConfiguration(admin).getEnableEndEntityProfileLimitations()) { if (!authorizedToEndEntityProfile(admin, data1.getEndEntityProfileId(), AvailableAccessRules.EDIT_RIGHTS)) { logsession.log(admin, caid, LogEntry.MODULE_RA, new java.util.Date(), username, null, LogEntry.EVENT_ERROR_CHANGEDENDENTITY, "Administrator not authorized to change status"); throw new AuthorizationDeniedException("Administrator not authorized to edit user."); } }  if(approvalflag){  int numOfApprovalsRequired = getNumOfApprovalRequired(admin, CAInfo.REQ_APPROVAL_ADDEDITENDENTITY, caid); if (numOfApprovalsRequired > 0 && !ApprovalExecutorUtil.isCalledByClassNameOrExtRA("ChangeStatusEndEntityApprovalRequest")){ ChangeStatusEndEntityApprovalRequest ar = new ChangeStatusEndEntityApprovalRequest(username, data1.getStatus(), status ,  admin,null,numOfApprovalsRequired,data1.getCaId(),data1.getEndEntityProfileId()); approvalsession.addApprovalRequest(admin, ar); throw new WaitingForApprovalException("Edit Endity Action have been added for approval by authorized adminstrators"); } }   if(data1.getStatus() == UserDataConstants.STATUS_KEYRECOVERY && !(status == UserDataConstants.STATUS_KEYRECOVERY || status == UserDataConstants.STATUS_INPROCESS || status == UserDataConstants.STATUS_INITIALIZED)){ keyrecoverysession.unmarkUser(admin,username); }  data1.setStatus(status); data1.setTimeModified((new java.util.Date()).getTime()); logsession.log(admin, caid, LogEntry.MODULE_RA, new java.util.Date(), username, null, LogEntry.EVENT_INFO_CHANGEDENDENTITY, ("New status : " + status));  } catch (FinderException e) { logsession.log(admin, caid, LogEntry.MODULE_RA, new java.util.Date(), username, null, LogEntry.EVENT_ERROR_CHANGEDENDENTITY, "Couldn't find username in database."); throw e; }  debug("<setUserStatus(" + username + ", " + status + ")");
    public void setUserStatus(Admin admin, String username, int status) throws AuthorizationDeniedException, FinderException, ApprovalException, WaitingForApprovalException {       setUserStatusWithApprovalFlag(admin, username, status, true);    } // setUserStatus