playframework 2.0 - How to access credentials passed in the authentication popup for a 401 response -


i need implement activedirectory based authentication on site developin gusing play framework. demo, created sample app

public static result index()  {     boolean isloggedin = false;     string authorization = request().getheader(authorization);      if(!isloggedin)     {         string usrnm = request().username();         response().setheader(www_authenticate, "basic realm=\"enter id , password\"");             return unauthorized("you need login first");     }     return ok("welcome nowhere"); } 

this opens authentication popup on client. now, how access these credentials?

ok, found answer

 string authorization = request().getheader(authorization); 

the authorization header contains username:password in base64 encoded form.

authorization = "basic oa76dfexvdd3==" 

here, if decode oa76dfexvdd3==, "myusr:mypwd", can use authentication.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -