Skip to content

Commit

Permalink
Fixed security_all tests
Browse files Browse the repository at this point in the history
- incorrect usage of Principal.toString to get it's name

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
  • Loading branch information
dmatej committed Sep 18, 2022
1 parent 90396f8 commit ee7e29b
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ protected Object invoke(final InvocationContext ctx) throws Exception
Principal p = ejbCtx.getCallerPrincipal();
Method interfaceMethod = ctx.getMethod();

LOG.log(Level.INFO, "EJB Method called [Full]:\"{0}\" by Principal:{1}", new Object[]{getFullEJBClassName(interfaceMethod), p.toString()});
LOG.log(Level.INFO, "EJB Method called [Methodonly]:{0} by Principal:{1}", new Object[]{interfaceMethod.getName(), p.toString()});
LOG.log(Level.INFO, "EJB Method called [Full]:\"{0}\" by Principal:{1}", new Object[]{getFullEJBClassName(interfaceMethod), p});
LOG.log(Level.INFO, "EJB Method called [Methodonly]:{0} by Principal:{1}", new Object[]{interfaceMethod.getName(), p});

SecurityInterceptor.aroundInvokeCalled = true;
return ctx.proceed();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ protected Object invoke(final InvocationContext ctx) throws Exception
Principal p = ejbCtx.getCallerPrincipal();
Method interfaceMethod = ctx.getMethod();

LOG.log(Level.INFO, "EJB Method called [Full]:\"{0}\" by Principal:{1}", new Object[]{getFullEJBClassName(interfaceMethod), p.toString()});
LOG.log(Level.INFO, "EJB Method called [Methodonly]:{0} by Principal:{1}", new Object[]{interfaceMethod.getName(), p.toString()});
LOG.log(Level.INFO, "EJB Method called [Full]:\"{0}\" by Principal:{1}", new Object[]{getFullEJBClassName(interfaceMethod), p});
LOG.log(Level.INFO, "EJB Method called [Methodonly]:{0} by Principal:{1}", new Object[]{interfaceMethod.getName(), p});

SecurityInterceptor.aroundInvokeCalled = true;
return ctx.proceed();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ConverterBean implements SessionBean {
SessionContext mysc = null;

public String myCallerPrincipal(){
return mysc.getCallerPrincipal().toString();
return mysc.getCallerPrincipal().getName();
}
/**
* Returns the yen value for a given dollar amount.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ public void doFoo(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {

PrintWriter out = resp.getWriter();
out.println("doFoo with " + req.getUserPrincipal());
out.println("doFoo with " + req.getUserPrincipal().getName());
out.close();
}

public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {

PrintWriter out = resp.getWriter();
out.println("doGet with " + req.getUserPrincipal());
out.println("doGet with " + req.getUserPrincipal().getName());
out.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ConverterBean implements SessionBean {
SessionContext mysc = null;

public String myCallerPrincipal(){
return mysc.getCallerPrincipal().toString();
return mysc.getCallerPrincipal().getName();
}
/**
* Returns the yen value for a given dollar amount.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ConverterBean implements SessionBean {
SessionContext mysc = null;

public String myCallerPrincipal(){
return mysc.getCallerPrincipal().toString();
return mysc.getCallerPrincipal().getName();
}
/**
* Returns the yen value for a given dollar amount.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public void service(HttpServletRequest req, HttpServletResponse resp)
public void doFoo(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
PrintWriter out = resp.getWriter();
out.println("doFoo with " + req.getUserPrincipal());
out.println("doFoo with " + req.getUserPrincipal().getName());
}

public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
PrintWriter out = resp.getWriter();
out.println("doGet with " + req.getUserPrincipal());
out.println("doGet with " + req.getUserPrincipal().getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Hello World from 196 HttpServlet AuthModule Test!
<hr>
<%
try {
out.println("Hello, " + request.getUserPrincipal() + " from " + request.getAttribute("MY_NAME"));
out.println("Hello, " + request.getUserPrincipal().getName() + " from " + request.getAttribute("MY_NAME"));
out.println("PC = " + request.getAttribute("PC"));
} catch(Throwable t) {
out.println("Something wrong: " + t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Hello World from 196 HttpServletChallenge AuthModule Test!
<hr>
<%
try {
out.println("Hello, " + request.getUserPrincipal() +
out.println("Hello, " + request.getUserPrincipal().getName() +
" from " + request.getAttribute("MY_NAME") +
" with authType " + request.getAuthType());
} catch(Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Hello World from 196 HttpServletForm AuthModule Test!
<hr>
<%
try {
out.println("Hello, " + request.getUserPrincipal() +
out.println("Hello, " + request.getUserPrincipal().getName() +
" from " + request.getAttribute("MY_NAME"));
out.println("PC = " + request.getAttribute("PC"));
} catch(Throwable t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@
<html>
<head><title>JSP Page Access Profile</title></head>
<body>
<%
out.println("The web user principal = "+request.getUserPrincipal() );
<%
out.println("The web user principal = "+request.getUserPrincipal().getName() );
out.println();
%>
<H3> Calling the ProfileInfoBean </H3>
<%
try{
InitialContext ic = new InitialContext();
java.lang.Object obj = ic.lookup("jsp2sful");
out.println("Looked up home!!");
ProfileInfoHome home = (ProfileInfoHome)PortableRemoteObject.narrow(
obj, ProfileInfoHome.class);
out.println("Narrowed home!!");
out.println("Looked up home!!");
ProfileInfoHome home = (ProfileInfoHome)PortableRemoteObject.narrow(
obj, ProfileInfoHome.class);
out.println("Narrowed home!!");
ProfileInfoRemote hr = home.create("a name");
out.println("Got the EJB!!");
out.println("<li>User profile: ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void ejbCreate(String name) {
}

public String getCallerInfo() {
return sc.getCallerPrincipal().toString();
return sc.getCallerPrincipal().getName();
}

public String getSecretInfo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ConverterBean implements SessionBean {
SessionContext mysc = null;

public String myCallerPrincipal(){
return mysc.getCallerPrincipal().toString();
return mysc.getCallerPrincipal().getName();
}
/**
* Returns the yen value for a given dollar amount.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class HelloEJB implements Hello {
public String sayHello(String who) {
System.out.println("**** sayHello("+ who+")");
Principal p = ctx.getCallerPrincipal();
String principal = (p == null)? "NULL": p.toString();
String principal = (p == null)? "NULL": p.getName();
System.out.println("****EJB: principal = " + principal);
return "JBI-SecurityTest " + who + " PrincipalGot="+principal;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws jakarta.servlet.ServletException {
try {
Principal p = req.getUserPrincipal();
String principal = (p==null)? "NULL": p.toString();
String principal = (p==null)? "NULL": p.getName();
System.out.println("****Servlet: principal = " + principal);

Hello port = service.getHelloEJBPort();
Expand Down

0 comments on commit ee7e29b

Please sign in to comment.