Alon Bar-Lev has posted comments on this change.

Change subject: userportal,webadmin: xsrf token changes
......................................................................


Patch Set 1:

(4 comments)

http://gerrit.ovirt.org/#/c/31089/1/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/OvirtXsrfTokenServiceServlet.java
File 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/OvirtXsrfTokenServiceServlet.java:

Line 38:      * @throws NoSuchAlgorithmException
Line 39:      */
Line 40:     OvirtXsrfTokenServiceServlet() throws NoSuchProviderException, 
NoSuchAlgorithmException {
Line 41:         super();
Line 42:         random = SecureRandom.getInstance("SHA1PRNG", "SUN"); 
//$NON-NLS-1$ $NON-NLS-2$
please do not use sun explicitly.
Line 43:         //Call nextBytes this once to initialize the random 
implementation.
Line 44:         //We ignore the result, we just called it to initialize the 
implementation.
Line 45:         byte[] b = new byte[TOKEN_SIZE];
Line 46:         random.nextBytes(b);


Line 40:     OvirtXsrfTokenServiceServlet() throws NoSuchProviderException, 
NoSuchAlgorithmException {
Line 41:         super();
Line 42:         random = SecureRandom.getInstance("SHA1PRNG", "SUN"); 
//$NON-NLS-1$ $NON-NLS-2$
Line 43:         //Call nextBytes this once to initialize the random 
implementation.
Line 44:         //We ignore the result, we just called it to initialize the 
implementation.
why is it needed?
Line 45:         byte[] b = new byte[TOKEN_SIZE];
Line 46:         random.nextBytes(b);
Line 47:     }
Line 48: 


Line 65:                 random.nextBytes(tokenBytes);
Line 66:                 session.setAttribute(XSRF_TOKEN, tokenBytes);
Line 67:             } else {
Line 68:                 tokenBytes = (byte[]) session.getAttribute(XSRF_TOKEN);
Line 69:             }
either get this once or get it always... two patterns:

 sync {
     tokenBytes = (byte[]) session.getAttribute(XSRF_TOKEN);
     if (tokenBytes == null) {
         ...
         session.setAttribute(XSRF_TOKEN, tokenBytes);
     }
 }

or:

 sync {
     if (session.getAttribute(XSRF_TOKEN) == null) {
         ...
         session.setAttribute(XSRF_TOKEN, tokenBytes);
     }
 }
 tokenBytes = (byte[]) session.getAttribute(XSRF_TOKEN);
Line 70:         }
Line 71:         return StringUtils.toHexString(tokenBytes);
Line 72:     }


http://gerrit.ovirt.org/#/c/31089/1/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/XsrfProtectedRpcServlet.java
File 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/XsrfProtectedRpcServlet.java:

Line 22:             throw new RpcTokenException("XSRF token missing"); 
//$NON-NLS-1$
Line 23:         }
Line 24:         String expectedToken;
Line 25:         HttpSession session = getThreadLocalRequest().getSession();
Line 26:         synchronized (session) {
why do you need to sync?
Line 27:             expectedToken = StringUtils.toHexString(
Line 28:                     (byte[]) 
session.getAttribute(OvirtXsrfTokenServiceServlet.XSRF_TOKEN));
Line 29:         }
Line 30:         XsrfToken xsrfToken = (XsrfToken) token;


-- 
To view, visit http://gerrit.ovirt.org/31089
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ic028b0d1f8a6fd0cf67863af51d02d892d33f5fb
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Alexander Wels <aw...@redhat.com>
Gerrit-Reviewer: Alexander Wels <aw...@redhat.com>
Gerrit-Reviewer: Alon Bar-Lev <alo...@redhat.com>
Gerrit-Reviewer: Einav Cohen <eco...@redhat.com>
Gerrit-Reviewer: Vojtech Szocs <vsz...@redhat.com>
Gerrit-Reviewer: automat...@ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to