class TokenCreationService {

    public String createJwtTokenWithoutCredentials(String user) {
        boolean isZosmfUsedAndAvailable = false;
        try {
            isZosmfUsedAndAvailable = providers.isZosfmUsed() && providers.isZosmfAvailable();
        } catch (AuthenticationServiceException ex) {
            // Intentionally do nothing. The issue is logged deeper.
        }

        if (isZosmfUsedAndAvailable) {
            try {
                String passTicket = passTicketService.generate(user, zosmfApplId);
                return ((TokenAuthentication) zosmfAuthenticationProvider.authenticate(new UsernamePasswordAuthenticationToken(user, passTicket)))
                    .getCredentials();
            } catch (IRRPassTicketGenerationException e) {
                throw new AuthenticationTokenException("Problem with generating PassTicket");
            }
        } else {
            final String domain = "security-domain";
            final String jwtTokenString = authenticationService.createJwtToken(user, domain, null);
            return authenticationService.createTokenAuthentication(user, jwtTokenString).getCredentials();
        }
    }

}