docs: private void performDelegation(EJBMethodMetaData methodMetaData, Subject delegationSubject) {
          ArrayList<String> delUsers = new ArrayList<String>();
          String invalidUser = "";
          Set<WSCredential> publicCredentials = (delegationSubject == null ? null : delegationSubject.getPublicCredentials(WSCredential.class));
          Iterator<WSCredential> it = null;
          if (publicCredentials != null && (it = publicCredentials.iterator()) != null && it.hasNext()) {
              WSCredential credential = it.next();
              try {
                  extraAuditData.put("REALM", credential.getRealmName());
              } catch (CredentialExpiredException e) {
              } catch (CredentialDestroyedException e) {
              }
              try {
                  delUsers.add("user:" + credential.getRealmSecurityName());
              } catch (CredentialExpiredException e1) {
                  // TODO Auto-generated catch block
              } catch (CredentialDestroyedException e1) {
                  // TODO Auto-generated catch block
              }
          }
  
          String applicationName = getApplicationName(methodMetaData);
          String methodName = methodMetaData.getMethodName();//TODO: which API to call? methodInfo.getMethodSignature()+":"+methodInfo.getInterfaceType().getValue();
  
          if (auditManager != null && auditManager.getHttpServletRequest() != null) {
              extraAuditData.put("HTTP_SERVLET_REQUEST", auditManager.getHttpServletRequest());
          }
  
          extraAuditData.put("REASON_TYPE", "EJB");
  
          if (methodMetaData.isUseSystemPrincipal()) {
              // fail request because run-as-mode SYSTEM_IDENTITY is not supported on Liberty
              Tr.error(tc, "EJB_RUNAS_SYSTEM_NOT_SUPPORTED", methodName, applicationName);
              delUsers.add("EJB_RUNAS_SYSTEM");
              extraAuditData.put("DELEGATION_USERS_LIST", delUsers);
              Audit.audit(Audit.EventID.SECURITY_AUTHN_DELEGATION_01, extraAuditData, AuditConstants.FAILURE, Integer.valueOf(401));
              throw new EJBAccessDeniedException(TraceNLS.getFormattedMessage(this.getClass(),
                                                                              TraceConstants.MESSAGE_BUNDLE,
                                                                              "EJB_RUNAS_SYSTEM_NOT_SUPPORTED",
                                                                              new Object[] { methodName, applicationName },
                                                                              "CWWKS9405E: Authorization failed for EJB method"
                                                                                                                            + methodName
                                                                                                                            + " in the application "
                                                                                                                            + applicationName
                                                                                                                            + ". The run-as-mode of SYSTEM_IDENTITY specified in the ibm-ejb-jar-ext.xml is not supported and must be removed or replaced."));
  
          } else if (methodMetaData.isUseCallerPrincipal()) {
              if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                  Tr.debug(tc, "Returning without delegating because run-as-mode in ibm-ejb-jar-ext for " + methodName + " in " + applicationName + " is set to CALLER_IDENTITY.");
              }
              return;
          } else {
              String roleName = getRunAsRole(methodMetaData);
              extraAuditData.put("RUN_AS_ROLE", roleName);
              if (roleName != null) {
                  try {
                      SecurityService securityService = securityServiceRef.getService();
                      AuthenticationService authService = securityService.getAuthenticationService();
                      delegationSubject = authService.delegate(roleName, getApplicationName(methodMetaData));
  
                      if (delegationSubject != null) {
                          String buff = delegationSubject.toString();
                          if (buff != null) {
                              int a = buff.indexOf("accessId");
                              if (a != -1) {
                                  buff = buff.substring(a + 9);
                                  a = buff.indexOf(",");
                                  if (a != -1) {
                                      buff = buff.substring(0, a);
                                      delUsers.add(buff);
                                  }
                              }
  
                          }
                      } else {
                          invalidUser = authService.getInvalidDelegationUser();
                          delUsers.add(invalidUser);
                      }
                      extraAuditData.put("DELEGATION_USERS_LIST", delUsers);
                      if (delegationSubject != null) {
                          Audit.audit(Audit.EventID.SECURITY_AUTHN_DELEGATION_01, extraAuditData, AuditConstants.SUCCESS, Integer.valueOf(200));
                      } else {
                          Audit.audit(Audit.EventID.SECURITY_AUTHN_DELEGATION_01, extraAuditData, AuditConstants.FAILURE, Integer.valueOf(401));
  
                      }
  
                  } catch (IllegalArgumentException e) {
                      if (delegationSubject != null) {
                          String buff = delegationSubject.toString();
                          if (buff != null) {
                              int a = buff.indexOf("accessId");
                              if (a != -1) {
                                  buff = buff.substring(a + 9);
                                  a = buff.indexOf(",");
                                  if (a != -1) {
                                      buff = buff.substring(0, a);
                                      delUsers.add(buff);
                                  }
                              }
  
                          }
                      } else {
                          SecurityService securityService = securityServiceRef.getService();
                          AuthenticationService authService = securityService.getAuthenticationService();
                          invalidUser = authService.getInvalidDelegationUser();
                          delUsers.add(invalidUser);
                          extraAuditData.put("DELEGATION_USERS_LIST", delUsers);
                      }
  
                      Audit.audit(Audit.EventID.SECURITY_AUTHN_DELEGATION_01, extraAuditData, AuditConstants.FAILURE, Integer.valueOf(401));
  
                      if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                          Tr.debug(tc, "Exception performing delegation.", e);
                      }
                  }
              }
          }
  
          if (delegationSubject != null) {
              subjectManager.setInvocationSubject(delegationSubject);
          }
      }