docs: private void setCredential(Subject subject, WSPrincipal principal) throws CredentialException {
          String securityName = principal.getName();
          Hashtable<String, ?> customProperties = getUniqueIdHashtableFromSubject(subject);
          if (customProperties == null || customProperties.isEmpty()) {
              UserRegistryService urService = userRegistryServiceRef.getService();
              if (urService != null) {
                  String urType = urService.getUserRegistryType();
                  if ("WIM".equalsIgnoreCase(urType) || "LDAP".equalsIgnoreCase(urType)) {
                      try {
                          securityName = urService.getUserRegistry().getUserDisplayName(securityName);
                      } catch (Exception e) {
                          //do nothing
                      }
                  }
              }
          }
          if (securityName == null || securityName.length() == 0) {
              securityName = principal.getName();
          }
          String accessId = principal.getAccessId();
  
          String customRealm = null;
          String realm = null;
          String uniqueName = null;
  
          if (customProperties != null) {
              customRealm = (String) customProperties.get(AttributeNameConstants.WSCREDENTIAL_REALM);
          }
  
          if (customRealm != null) {
              realm = customRealm;
              String[] parts = accessId.split(realm + "/");
              if (parts != null && parts.length == 2)
                  uniqueName = parts[1];
          } else {
              realm = AccessIdUtil.getRealm(accessId);
              uniqueName = AccessIdUtil.getUniqueId(accessId);
          }
          if (AccessIdUtil.isServerAccessId(accessId)) {
              // Create a server WSCredential
              setCredential(null, subject, realm, securityName, uniqueName, null, accessId, null, null);
          } else {
              CredentialsService cs = credentialsServiceRef.getService();
              String unauthenticatedUserid = cs.getUnauthenticatedUserid();
  
              if (securityName != null && unauthenticatedUserid != null &&
                  securityName.equals(unauthenticatedUserid)) {
                  // Create an unauthenticated WSCredential
                  setCredential(unauthenticatedUserid, subject, realm, securityName, uniqueName, null, null, null, null);
              } else if (AccessIdUtil.isUserAccessId(accessId)) {
                  // Create a user WSCredential
                  createUserWSCredential(subject, securityName, accessId, realm, uniqueName, unauthenticatedUserid);
              }
          }
      }