class CmServiceKeytabRequestFactory {

    public ServiceKeytabRequest create(Stack stack, GatewayConfig primaryGatewayConfig) {
        ServiceKeytabRequest request = new ServiceKeytabRequest();
        request.setEnvironmentCrn(stack.getEnvironmentCrn());
        request.setClusterCrn(stack.getResourceCrn());
        String fqdn = primaryGatewayConfig.getHostname();
        request.setServerHostName(fqdn);
        String hostname = StringUtils.substringBefore(fqdn, ".");
        if (!fqdn.equals(hostname)) {
            request.setServerHostNameAlias(hostname);
        }
        request.setServiceName("CM");
        request.setDoNotRecreateKeytab(Boolean.TRUE);
        RoleRequest roleRequest = new RoleRequest();
        roleRequest.setRoleName("hadoopadminrole-" + stack.getName());
        roleRequest.setPrivileges(Set.of("Service Administrators", "Certificate Administrators", "CA Administrator"));
        request.setRoleRequest(roleRequest);
        return request;
    }

}