Skip to Main Content
Securing WebLogic Server 12c
book

Securing WebLogic Server 12c

by Luca Masini
November 2012
Intermediate to advanced content levelIntermediate to advanced
100 pages
2h 16m
English
Packt Publishing
Content preview from Securing WebLogic Server 12c

Securing the web module

The first resource we want to protect is the web resource, a servlet, as follows:

package net.lucamasini.security;

@WebServlet(name="MyWorkServlet",
        urlPatterns={"/myprotectedresource"})
public class MyProtectedServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req,
                 HttpServletResponse resp) 
        throws ServletException, IOException {
        Principal userPrincipal = req.getUserPrincipal();
resp.getWriter().println(userPrincipal!=null?userPrincipal.getName(): "anonymous");
    }
}

Here we can see the power of Java EE 6: we don't need to write XML to declare a servlet and to bind it to a URL, a single annotation is enough. Now, after compiling and launching, the deploy goal will allow us to call http://localhost:7001/chapter3-web/myprotectedresource ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Professional Oracle® WebLogic Server

Professional Oracle® WebLogic Server

Robert Patrick, Gregory Nyberg, Philip Aston, Josh Bregman, Paul Done
Linux: Powerful Server Administration

Linux: Powerful Server Administration

Uday Sawant, Oliver Pelz, Jonathan Hobson, William Leemans
The Definitive Guide to SOA: Oracle® Service Bus, SECOND EDITION

The Definitive Guide to SOA: Oracle® Service Bus, SECOND EDITION

Jeff Davies, David Schorow, Samrat Ray, David Rieber

Publisher Resources

ISBN: 9781849687782Other