/**
   * This method check to see if the user can create the account maintenance document and set the
   * user session
   *
   * @param String principalId
   * @return boolean
   */
  protected boolean isValidUser(String principalId) {

    PersonService personService = SpringContext.getBean(PersonService.class);
    if (principalId == null) {
      return false;
    }
    Person user = personService.getPerson(principalId);
    if (user == null) {
      return false;
    }
    DocumentAuthorizer documentAuthorizer = new MaintenanceDocumentAuthorizerBase();
    if (documentAuthorizer.canInitiate(
        SpringContext.getBean(MaintenanceDocumentDictionaryService.class)
            .getDocumentTypeName(Account.class),
        user)) {
      // set the user session so that the user name can be displayed in the saved document
      GlobalVariables.setUserSession(new UserSession(user.getPrincipalName()));
      return true;
    }

    LOG.error(
        KcUtils.getErrorMessage(
            KcConstants.AccountCreationService.ERROR_KC_DOCUMENT_INVALID_USER,
            new String[] {principalId}));

    return false;
  }
 @Override
 public boolean allowsNewOrCopyAction(String documentTypeName) {
   // TODO : to let it rendering 'create new' and 'edit'/'copy' button
   DocumentAuthorizer documentAuthorizer =
       getDocumentHelperService().getDocumentAuthorizer(documentTypeName);
   DocumentPresentationController documentPresentationController =
       getDocumentHelperService().getDocumentPresentationController(documentTypeName);
   // make sure this person is authorized to initiate
   Person currentUser = GlobalVariables.getUserSession().getPerson();
   return documentPresentationController.canInitiate(documentTypeName)
       && documentAuthorizer.canInitiate(documentTypeName, currentUser);
 }