Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help to create authorization header for url & #27

Closed
mikeyg123 opened this issue Dec 10, 2020 · 4 comments
Closed

Help to create authorization header for url & #27

mikeyg123 opened this issue Dec 10, 2020 · 4 comments
Milestone

Comments

@mikeyg123
Copy link

Hi
I would like to use SpengoClient to create a context and create a header that I can use with an arbitrary HttpConnection or websocket connection
However the SpnegoClient constructor which takes LoginConfig supplier is protected. This makes it very awkward.

Could you make this public?
Or perhaps provide a utility method which takes a config section name and a url and returns the token authorization header string.

This is my extremely brittle workaround which will obviously have problems with modules

private static SpnegoClient spnegoClientForLogin(String s) throws ReflectiveOperationException {
    Constructor<SpnegoClient> ctor = SpnegoClient.class.getDeclaredConstructor(Callable.class);
    ctor.setAccessible(true);
    return ctor.newInstance((Callable<LoginContext>) () -> {
        try {
            return new LoginContext(s);
        } catch (LoginException e) {
            throw new RuntimeException(e);
        }
    });
}

 String authHeader = spnegoClientForLogin(sectionName).createContext(url).createTokenAsAuthorizationHeader();

Thank you

@bedrin
Copy link
Owner

bedrin commented Feb 25, 2021

Hi there!

Sorry - I've missed your question.

I can make it public. Just want to understand the use case.
Why cannot you use one of static mathods like SpnegoClient.loginWithUsernameAndPassword() or SpnegoClient.loginWithKeyTab() ?

Kerb4J was designed to hide the complexity of Kerberos by providing plain SpnegoClient / SpengoContext interfaces.
Why do you want to provide LoginContext ?

Cheers,
Dima.

@mikeyg123
Copy link
Author

mikeyg123 commented Mar 5, 2021

Hi Thanks for your reply
I am provided with a jaas style login config file specified by the java.security.auth.login.config system property. This file has a particular named section which I need to use. The jaas file may require me to use either the user's ticket cache or a particular keytab file and principal.
Without parsing the jaas config myself I don't know which of the above methods to call.

I do certainly appreciate your efforts to hide the complexity here.

Regards
MikeG

@bedrin bedrin added this to the 0.1.1 milestone May 31, 2021
bedrin added a commit that referenced this issue May 31, 2021
…ogin-context

issues/27 create SpnetClient with explicit LoginContext
@bedrin
Copy link
Owner

bedrin commented May 31, 2021

Merged to develop. Fixed in 0.1.1

@bedrin bedrin closed this as completed May 31, 2021
@bedrin
Copy link
Owner

bedrin commented Jun 1, 2021

0.1.1 pushed to Maven central

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants