I'm late to the party, but it can help other people find this question in the search.
Cross-authentication is best used, but this is not always possible. For example, you can act as a trusted third party to copy data from one organization to another, and none of them can be open to it.
The javax.security.auth.login.LoginContext class typically uses an external configuration file that can support multiple entries. This is a good approach if your devops support it, but there are many environments where this is not possible, for example, if you are deployed as a .war file on an application server. (Classic example: Your application autoscales on the AWS Elastic Beanstalk.)
In our case, we used the LoginContext constructor, which takes a Configuration object. We ourselves must store the necessary information, but we can cope with almost everything. (We can load and write our keytab file to a temporary directory and point to it in the Configuration object. Remember to destroy this file when your application exits!)
In this case, it is useful to remember that the Configuration object is a bag, and AppConfigurationEntry is information for a separate service.
Edited to add: you can specify various locations of the credential caching file (ccache) in your options. I can’t remember if the ccache files support more than one record, but that doesn’t hurt to specify different files.
source share