* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// @RolesAllowed({"com.att.aaf.myPerm|myInstance|myAction"})
public class MyServlet implements Servlet {
private ServletConfig servletConfig;
-
+
public void init(ServletConfig config) throws ServletException {
servletConfig = config;
}
-
+
public ServletConfig getServletConfig() {
return servletConfig;
}
-
+
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
HttpServletRequest request;
try {
} catch (ClassCastException e) {
throw new ServletException("Only serving HTTP today",e);
}
-
+
res.getOutputStream().println("<html><header><title>CSP Servlet Test</title></header><body><h1>You're good to go!</h1><pre>" +
request.getUserPrincipal());
-
+
String perm = request.getParameter("PERM");
if (perm!=null) {
if (request.isUserInRole(perm)) {
- if (perm.indexOf('|')<0) {
+ if (perm.indexOf('|')<0) {
res.getOutputStream().println("\nCongrats!, You are in Role " + perm);
- } else {
+ } else {
res.getOutputStream().println("\nCongrats!, You have Permission " + perm);
}
} else {
- if (perm.indexOf('|')<0) {
+ if (perm.indexOf('|')<0) {
res.getOutputStream().println("\nSorry, you are NOT in Role " + perm);
} else {
res.getOutputStream().println("\nSorry, you do NOT have Permission " + perm);
}
}
}
-
+
// You can get the working AAFCon from Trans
AAFCon<?> aafcon = AAFCon.obtain(req);
if (aafcon!=null) {
res.getOutputStream().println("No AAFCon instantiated");
}
res.getOutputStream().print("</pre></body></html>");
-
+
}
-
+
public String getServletInfo() {
return "MyServlet";
}
-
+
public void destroy() {
}
}
\ No newline at end of file