Access the full course here: javabrains.io/courses/javaee_... Let's implement Basic Auth by using a Security Request Filter and have clients login using a user ID and password.
Hi, This is great video about basic auth mechanism for rest api, I am looking for oAuth with Rest API not only me, more people are looking for oAuth mechanism. thanks.
Hi Sir, What will happen if more then one filter class are available in same application, as you said every request will go through the filter class first? kindly reply
Sometime decoded value does not appear properly because there is extra space after replacing first string of Authentication header (Basic dXNlcjpwYXNzd29yZA==). ----------------------------------------- Using a Trim function after replace. authTok=authTok.replaceFirst(AUTHORIZATION_HEAD_PREF, ""); authTok = authTok.trim();
Hi Koushik, I was following this tutorial and came across one small thing. You forgot to mention that SecurityFilter should be annotated with 'Provider'. The request will not be intercepted by our SecurityFilter without 'Provider' annotation.
For some reason I am not getting the decoded value if I use this import org.glassfish.jersey.internal.util.Base64, the decoded value appears like this ������������, I tried multiple times... So I used apache commons codec jar instead here's the dependencies that needs to be added to add to pom.xml commons-codec commons-codec 1.9 and I modified the code something like this String authToken = authHeader.get(0); authToken = authToken.replaceFirst(AUTHORIZATION_HEADER_PREFIX, ""); byte[] decodeBase64 = Base64.decodeBase64(authToken); String decodedToken = new String(decodeBase64, "UTF-8"); StringTokenizer tokenier = new StringTokenizer(decodedToken, ":"); String userName = tokenier.nextToken(); String password = tokenier.nextToken(); and it worked.
Decoded value does not appear because there is extra space after replacing first string of Authentication header (Basic dXNlcjpwYXNzd29yZA==). ----------------------------------------- Using a Trim function after replace works. authTok=authTok.replaceFirst(AUTHORIZATION_HEAD_PREF, ""); authTok = authTok.trim();
Some how its not working for me... is there any thing need to add web.xml or pom.xml. My api is working but not asking for authentication.. Please help .. thanks in advance
Getting this error. Root cause of ServletException. java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;
Not even single place out there, save this where you can find these concepts with such intricacies. Thank You so much. You are a savior.
I don´t speak English, but i understand almost all. Excellent videos!!!
Really great tutorials.... Looking forward to a separate OAuth and OAuth2 Session... :)
Thank you for sharing. Really great tutorials.
Thanks. Need a series on implementing oauth 2.0 authorization with jersey. That would be awesome
Amazing tutorial !!
It 'll be nice to have one on how to build a client application that consumes REST API with Oauth
Hi,
This is great video about basic auth mechanism for rest api,
I am looking for oAuth with Rest API not only me, more people are looking for oAuth mechanism. thanks.
Excellent Tutorials
Thanks a ton sir! real gem.
very helpful, thanks alot..
Great tutorial... It would be great to have an OAuth 2.0 example... thanks
Awesome tutorial.. thanks..
Very nice man .... excellent
Hi, This is a great resource. I am looking for details on Jax RS with OAuth. Can you point me to a direction?
Hey can you demonstrate Spring-REST, Spring-Hateoas with Spring-OAuth2
Hey, thank you for this tutorial it was great !!
how can i get the current user using this approch thank you ?
it is not authorizing when i try in postman, i am getting api output directly did i missed any thing?
Hi Sir, What will happen if more then one filter class are available in same application, as you said every request will go through the filter class first? kindly reply
Hi,
It is perfectly working and tested with Postman, but in real time application how to send such request(Html/Angular4), can you please describe.
Sometime decoded value does not appear properly because there is extra space after replacing first string of Authentication header (Basic dXNlcjpwYXNzd29yZA==).
-----------------------------------------
Using a Trim function after replace.
authTok=authTok.replaceFirst(AUTHORIZATION_HEAD_PREF, "");
authTok = authTok.trim();
thank you Varun. this was causing problem for me.
you saved me thanks.
hi i have a question here why we are using http we need to use https right if so will this example works
I would appreciate if you provide an example for Oauth2 Client using Jersey which includes all grant types.
What will happen when user name or pe already have : then how do you split
Hi Koushik,
I was following this tutorial and came across one small thing. You forgot to mention that SecurityFilter should be annotated with 'Provider'. The request will not be intercepted by our SecurityFilter without 'Provider' annotation.
Correct bro, Thank you
can anyone please help me, what maven dependencies required for this plz
why do you put "basic " in the value of header, and not only the value?
For some reason I am not getting the decoded value if I use this import org.glassfish.jersey.internal.util.Base64, the decoded value appears like this ������������, I tried multiple times... So I used apache commons codec jar instead here's the dependencies that needs to be added to add to pom.xml
commons-codec
commons-codec
1.9
and I modified the code something like this
String authToken = authHeader.get(0);
authToken = authToken.replaceFirst(AUTHORIZATION_HEADER_PREFIX, "");
byte[] decodeBase64 = Base64.decodeBase64(authToken);
String decodedToken = new String(decodeBase64, "UTF-8");
StringTokenizer tokenier = new StringTokenizer(decodedToken, ":");
String userName = tokenier.nextToken();
String password = tokenier.nextToken();
and it worked.
Got the same error. This works!!
Decoded value does not appear because there is extra space after replacing first string of Authentication header (Basic dXNlcjpwYXNzd29yZA==).
-----------------------------------------
Using a Trim function after replace works.
authTok=authTok.replaceFirst(AUTHORIZATION_HEAD_PREF, "");
authTok = authTok.trim();
what are the dependencies that are need to added?
your videos are fabulous .. but you missing to provide details on web.xml , how it needs to be configured ..
Thanks for a great course! but you know, you described authentication here, not authorization ;)
Some how its not working for me... is there any thing need to add web.xml or pom.xml. My api is working but not asking for authentication.. Please help .. thanks in advance
Same for me... Please help
same
SAME
@@duquehasbara Write @Provider in SecurityFilter
class
what if someone entered ' : ' in user-name or password ?
the username and password has to match to continue so I image you would still get an error.
No such element exception at string tokenizer
Try this- tokenizer.hasMoreTokens()? tokenizer.nextToken() : null;
Good tutorial but explain slowly and loudly
Getting this error.
Root cause of ServletException.
java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;