Text after "div class =" itemprop = "text">
I use my container, which uses the packs web (which again uses ferries, I think) In Karaf 3.0.2 I have several servlets that I registered as an OSGi service under a definite alias.
By default, etc. / jetty.xml so that I can use a JAASLoginService, which is already using the one I want to use, also the
problem It is, that I want to use both, basic and form validation:.
- Everything should use matching / ui / * form authentication
- should use all the matching / comfort / original authentication
I tried a lot, but I could not find a point where I could start I think it is possible to configure each servlet, but I want to do it globally.
Any thoughts?
After
You made a little difference. If you use a WebApplicationBundle (WAB) to deploy your Servlets, then you have all the regular elements of the web application, including basic or form based authentication.
Since you have the ability to register OSG service , So you can do this only through HTTPTontax. With the following example, it uses basic authentication. Public class AuthHttpContext imposes HttpContext {Public Boolean handleSecurity (HttpServletRequest request, HttpServletResponse resolution) throws IOException {if (req.getHeader ("authorization") == faucet) {res.sendError (HttpServletResponse SC_UNAUTHORIZED); return false; } If (certified (req)) {return true; } Other {res.sendError (HTTPSvt.UPT.S SC_UNAUTHORIZED); return false; }} Protected Boolean Authenticated (HttpServletRequest Request) {request.setAttribute (AUTHENTICATION_TYPE, HttpServletRequest.BASIC_AUTH); String authzHeader = request.getHeader ("authorization"); String Username and Password = New String (Base64.decodeBase64 (authzHeader.substring (6) .getBytes ())); Int userNameIndex = Username and Powered.indexoff (":"); String Username = Username and Powered Versioning (0, UsernameName); String Password = Username and Password Thread (Username Indax + 1); // Here I'll check the lame hard-coded credentials not highly recommended! Boolean success = ((user name). ("Admin") & password; equal ("administrator"); If (success) request.setAttribute (REMOTE_USER, "Admin"); The success of the return; } ...}
For form-based, you will need an additional HTTP contact. For each matching path you need to make sure the right HttpContext is registered, the following codes can also be found here.
If (httpServiceRef! = Null) {httpService = (HTTPSwire) BKSST Service (httpServiceRef); ... httpService.registerServlet ("/ state-authentication", new status service (), blank, new AuthHttpContext ()); }} ...}
Comments
Post a Comment