@AlexAlexon-4788, Thank you for sharing the details, but its still not clear as what type of application is this. Is this a WebService, or its a console application that is running on your server?
When you say that your application wont have an UI, by that I am going with an assumption that its a console app and for console app you can consider the following code samples: https://github.com/Azure-Samples/ms-identity-java-desktop/tree/master/
It has two samples in it:
- Username-Password-Flow
- Integrated-Windows-Auth-Flow
The username-password flow can be used with any OS platforms like Linux or Windows. In this sample you would find the following section in the file UsernamePasswordFlow.java
private final static String CLIENT_ID = "<client/app Id of the registered app in AAD>";
private final static String AUTHORITY = "https://login.microsoftonline.com/common/";
private final static Set<String> SCOPE = Collections.singleton("");
private final static String USER_NAME = "<user-name>>";
private final static String USER_PASSWORD = "<Password>";
If you see here there are two static attributes named as USER_NAME and USER_PASSWORD, so here you put the username and the password of the user who would be accessing the application and then you get an access-token issued by AAD for that user.
In the second sample "Integrated-Windows-Auth-Flow", you would only be required to add the username and using the Windows Integrated Auth i.e Kerberos and then fetching a access-token from AAD by submitting that kerberos token received earlier. In this case the users that are being used to authenticate must be synced to Azure AD via AD Connect so that same users identities can be found both on your on-prem infrastructure and in your Azure AD Tenant also.
Note: Both these samples uses MSAL4J that is the Microsoft Authentication Library for Java implementations.
Hope this helps.
In case you feel that the above assumption is not correct and you are using some other type of application, please do share the details about the type of application so that we can help further. Also, please do not forget to accept the response as Answer; if the above response helped in answering your query.