docs: @Override
      public Authentication authenticate(Authentication authentication) throws AuthenticationException {
          CWFAuthenticationDetails details = (CWFAuthenticationDetails) authentication.getDetails();
          String username = (String) authentication.getPrincipal();
          String password = (String) authentication.getCredentials();
          String domain = null;
          
          if (log.isDebugEnabled()) {
              log.debug("User: " + username);
              log.debug("Details, RA: " + details == null ? "null" : details.getRemoteAddress());
          }
          
          if (username != null && username.contains("\\")) {
              String pcs[] = username.split("\\\\", 2);
              domain = pcs[0];
              username = pcs.length > 1 ? pcs[1] : null;
          }
          
          ISecurityDomain securityDomain = SecurityDomainRegistry.getSecurityDomain(domain);
          
          if (username == null || password == null || securityDomain == null) {
              throw new BadCredentialsException("Missing security credentials.");
          }
          
          IUser user = securityDomain.authenticate(username, password);
          details.setDetail("user", user);
          Set<String> mergedAuthorities = mergeAuthorities(securityDomain.getGrantedAuthorities(user),
              systemGrantedAuthorities);
          List<GrantedAuthority> userAuthorities = new ArrayList<>();
          
          for (String authority : mergedAuthorities) {
              if (!authority.isEmpty()) {
                  userAuthorities.add(new SimpleGrantedAuthority(authority));
              }
          }
          
          User principal = new User(username, password, true, true, true, true, userAuthorities);
          authentication = new UsernamePasswordAuthenticationToken(principal, principal.getPassword(),
                  principal.getAuthorities());
          ((UsernamePasswordAuthenticationToken) authentication).setDetails(details);
          return authentication;
      }