summaryrefslogtreecommitdiffstats
path: root/cadi/servlet-sample
diff options
context:
space:
mode:
Diffstat (limited to 'cadi/servlet-sample')
-rw-r--r--cadi/servlet-sample/src/test/java/org/onap/aaf/sample/cadi/MyServlet.java14
-rw-r--r--cadi/servlet-sample/src/test/java/org/onap/aaf/sample/cadi/jetty/JettyServletServer.java4
-rw-r--r--cadi/servlet-sample/src/test/java/org/onap/aaf/sample/cadi/jetty/MiniJASPIWrap.java16
-rw-r--r--cadi/servlet-sample/src/test/java/org/onap/aaf/sample/cadi/tomcate/TomcatEmbedded.java4
4 files changed, 19 insertions, 19 deletions
diff --git a/cadi/servlet-sample/src/test/java/org/onap/aaf/sample/cadi/MyServlet.java b/cadi/servlet-sample/src/test/java/org/onap/aaf/sample/cadi/MyServlet.java
index f11d8f89..e3342914 100644
--- a/cadi/servlet-sample/src/test/java/org/onap/aaf/sample/cadi/MyServlet.java
+++ b/cadi/servlet-sample/src/test/java/org/onap/aaf/sample/cadi/MyServlet.java
@@ -60,15 +60,15 @@ import org.onap.aaf.cadi.principal.TaggedPrincipal;
request.getUserPrincipal());
String perm = request.getParameter("PERM");
- if(perm!=null) {
- if(request.isUserInRole(perm)) {
- if(perm.indexOf('|')<0) {
+ if (perm!=null) {
+ if (request.isUserInRole(perm)) {
+ if (perm.indexOf('|')<0) {
res.getOutputStream().println("\nCongrats!, You are in Role " + perm);
} 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);
@@ -78,12 +78,12 @@ import org.onap.aaf.cadi.principal.TaggedPrincipal;
// You can get the working AAFCon from Trans
AAFCon<?> aafcon = AAFCon.obtain(req);
- if(aafcon!=null) {
+ if (aafcon!=null) {
try {
res.getOutputStream().println("----- Perms JSON from direct call -----");
final Principal up = request.getUserPrincipal();
TaggedPrincipal tp;
- if(up instanceof TaggedPrincipal) {
+ if (up instanceof TaggedPrincipal) {
tp = (TaggedPrincipal)up;
} else {
tp = new TaggedPrincipal() {
@@ -101,7 +101,7 @@ import org.onap.aaf.cadi.principal.TaggedPrincipal;
// This call will be "as the user calling", but only if permission is set to trust.
// Future<String> future = aafcon.clientAs("2.0",tp).read("/authz/perms/user/"+request.getUserPrincipal().getName(),"application/Perms+json");
Future<String> future = aafcon.client("2.0").read("/authz/perms/user/"+request.getUserPrincipal().getName(),"application/Perms+json");
- if(future.get(4000 /* timeout */)) {
+ if (future.get(4000 /* timeout */)) {
res.getOutputStream().print(future.value);
} else {
System.err.println(future.code() + ", " + future.body());
diff --git a/cadi/servlet-sample/src/test/java/org/onap/aaf/sample/cadi/jetty/JettyServletServer.java b/cadi/servlet-sample/src/test/java/org/onap/aaf/sample/cadi/jetty/JettyServletServer.java
index cec8a539..165acffb 100644
--- a/cadi/servlet-sample/src/test/java/org/onap/aaf/sample/cadi/jetty/JettyServletServer.java
+++ b/cadi/servlet-sample/src/test/java/org/onap/aaf/sample/cadi/jetty/JettyServletServer.java
@@ -51,7 +51,7 @@ public abstract class JettyServletServer implements Servlet {
int maxPoolSize = 10;
int keepAliveTime = 3000;
String hostname = access.getProperty(Config.HOSTNAME, null);
- if(hostname==null) {
+ if (hostname==null) {
hostname = Inet4Address.getLocalHost().getHostName();
}
@@ -62,7 +62,7 @@ public abstract class JettyServletServer implements Servlet {
Server server = new Server(pool);
String protocol;
- if(access.getProperty(Config.CADI_KEYSTORE_PASSWORD,null)==null) {
+ if (access.getProperty(Config.CADI_KEYSTORE_PASSWORD,null)==null) {
ServerConnector conn = new ServerConnector(server);
conn.setHost(hostname);
conn.setPort(port);
diff --git a/cadi/servlet-sample/src/test/java/org/onap/aaf/sample/cadi/jetty/MiniJASPIWrap.java b/cadi/servlet-sample/src/test/java/org/onap/aaf/sample/cadi/jetty/MiniJASPIWrap.java
index 29462cfb..4d170f3f 100644
--- a/cadi/servlet-sample/src/test/java/org/onap/aaf/sample/cadi/jetty/MiniJASPIWrap.java
+++ b/cadi/servlet-sample/src/test/java/org/onap/aaf/sample/cadi/jetty/MiniJASPIWrap.java
@@ -55,9 +55,9 @@ public class MiniJASPIWrap extends ServletHolder {
this.rolesAllowed = servlet.getAnnotation(RolesAllowed.class);
StringBuilder sb = new StringBuilder();
boolean first = true;
- if(rolesAllowed!=null) {
- for(String str : rolesAllowed.value()) {
- if(first)first=false;
+ if (rolesAllowed!=null) {
+ for (String str : rolesAllowed.value()) {
+ if (first)first=false;
else sb.append(',');
sb.append(str);
}
@@ -73,26 +73,26 @@ public class MiniJASPIWrap extends ServletHolder {
*/
@Override
public void handle(Request baseRequest, ServletRequest request, ServletResponse response) throws ServletException, UnavailableException, IOException {
- if(rolesAllowed==null) {
+ if (rolesAllowed==null) {
super.handle(baseRequest, request, response);
} else { // Validate
try {
HttpServletRequest hreq = (HttpServletRequest)request;
boolean proceed = false;
- for(String role : rolesAllowed.value()) {
- if(hreq.isUserInRole(role)) {
+ for (String role : rolesAllowed.value()) {
+ if (hreq.isUserInRole(role)) {
proceed = true;
break;
}
}
- if(proceed) {
+ if (proceed) {
super.handle(baseRequest, request, response);
} else {
//baseRequest.getServletContext().log(hreq.getUserPrincipal().getName()+" Refused " + roles);
((HttpServletResponse)response).sendError(403); // forbidden
}
- } catch(ClassCastException e) {
+ } catch (ClassCastException e) {
throw new ServletException("JASPIWrap only supports HTTPServletRequest/HttpServletResponse");
}
}
diff --git a/cadi/servlet-sample/src/test/java/org/onap/aaf/sample/cadi/tomcate/TomcatEmbedded.java b/cadi/servlet-sample/src/test/java/org/onap/aaf/sample/cadi/tomcate/TomcatEmbedded.java
index 1597dbd5..e82dddd2 100644
--- a/cadi/servlet-sample/src/test/java/org/onap/aaf/sample/cadi/tomcate/TomcatEmbedded.java
+++ b/cadi/servlet-sample/src/test/java/org/onap/aaf/sample/cadi/tomcate/TomcatEmbedded.java
@@ -76,10 +76,10 @@ public class TomcatEmbedded {
private static void setAttr(Connector connector, Access access, String ctag, String atag) throws IOException {
String value = access.getProperty(atag, null);
- if(value==null) {
+ if (value==null) {
access.log(Level.ERROR, atag, "is null");
} else {
- if(value.startsWith("enc:")) {
+ if (value.startsWith("enc:")) {
access.log(Level.INIT,atag,"=enc:************");
value = access.decrypt(value, false);
} else {