Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Is method IDACall.processRPCTransaction(...) removed?

    Hello,

    I am extending IDACall to make sure my role based authorization can work with Spring Security on the client-side. Pretty much as explained in the Getting Started Guide I do this:

    Code:
    package ....;
    
    import java.io.IOException;
    import java.util.Iterator;
    import java.util.List;
    
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import com.isomorphic.rpc.RPCManager;
    import com.isomorphic.servlet.IDACall;
    import com.isomorphic.servlet.RequestContext;
    
    public class SecureIDACall extends IDACall {
    
    	public void processRequest(HttpServletRequest request,
    			HttpServletResponse response) throws ServletException, IOException {
    		//TODO derive this from Spring Security
    		Boolean b = true;
    
    		//TODO derive this from Spring Security
    		String roles = "ROLE_ADMINISTRATOR, ROLE_USER";
    
    		if (roles != null) {
    			try {
    				RequestContext context = RequestContext.instance(this, request,
    						response);
    				RPCManager rpc = new RPCManager(request, response);
    
    				rpc.setAuthenticated(b);
    				rpc.setUserRoles(roles);
    
    				// call processRPCTransaction() to iterate through all RPCRequests and
    				// DSRequests and execute them
    			       processRPCTransaction(rpc, context);
    
    			} catch (Throwable e) {
    				handleError(response, e);
    			}
    		} else {
    			super.processRequest(request, response);
    		}
    	}
    }
    But my compiler in Eclipse says (smartgwtee2.3 evaluation):
    Code:
    The method processRPCTransaction(RPCManager, RequestContext) is undefined for the type SecureIDACall	SecureIDACall.java	/Persons/src/nl/sytematic/projects/Persons/server/security	line 41	Java Problem
    Is this removed from the IDACall class? How should I work-around this? Is the Getting Started Guide perhaps not up to date?
    Last edited by Kah0ona; 5 Oct 2010, 04:13.

    #2
    This API is still present and with the same signature. Please look into this as an IDE issue, you may need to rebuild the project or similar to get the IDE to fix itself.

    Comment


      #3
      I tried a clean build with Eclipse, to no effect.
      I also tried removing all isomorphic_*.jars from the project's build path, as well as smartgwt(ee).jars and put them back, and THEN do a clean+build combo.

      Still, I got the same error...

      (Smartgwt EE 2.3)

      Comment


        #4
        Go ahead and use "javap" or a similar tool to directly inspect the class files in the downloaded .jars from smartclient.com - you'll find the API is present. Then, continue to troubleshooting this as an IDE / project configuration issue.

        Comment


          #5
          I tried javap on your advice, and it ('processRPCTransaction') does not seem to be there:

          Code:
          $ javap -private -classpath . IDACall
          Compiled from "IDACall.java"
          public class com.isomorphic.servlet.IDACall extends com.isomorphic.servlet.BaseServlet{
              public com.isomorphic.servlet.IDACall();
              public void doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)       throws javax.servlet.ServletException, java.io.IOException;
              public void doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)       throws javax.servlet.ServletException, java.io.IOException;
              public void processRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)       throws javax.servlet.ServletException, java.io.IOException;
              public com.isomorphic.datasource.DSResponse handleDSRequest(com.isomorphic.datasource.DSRequest, com.isomorphic.rpc.RPCManager, com.isomorphic.servlet.RequestContext)       throws java.lang.Exception;
              public com.isomorphic.rpc.RPCResponse handleRPCRequest(com.isomorphic.rpc.RPCRequest, com.isomorphic.rpc.RPCManager, com.isomorphic.servlet.RequestContext)       throws java.lang.Exception;
          }

          What is an equivalent way of doing the same as 'processRPCTransaction' from the example? ** EDIT: my attempt is in the post below, please comment on this if this is the way to go **
          Last edited by Kah0ona; 13 Oct 2010, 03:12.

          Comment


            #6
            This is now my SecureIDACall class, just curious if this is the way to go?

            Code:
            public class SecureIDACall extends IDACall {
            
            	public void processRequest(HttpServletRequest request,
            			HttpServletResponse response) throws ServletException, IOException {
            
            	//retrieve from SpringSecurity framework
            	Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
                    
                    UserDetails user = (UserDetails) principal;
            		Collection<GrantedAuthority> roles = user.getAuthorities();
            		
            	Boolean b = (user != null && user.isEnabled() && user.isAccountNonExpired() && user.isAccountNonLocked()) ? true : false;
            
            	if (roles != null && !roles.isEmpty()) {
            			try {
            				RequestContext context = RequestContext.instance(this, request,
            						response);
            				RPCManager rpc = new RPCManager(request, response);
            
            				rpc.setAuthenticated(b);
            
            				String stringRoles = this.getCommaSeparatedRoles(roles);				
            
            				rpc.setUserRoles(stringRoles);
            
            				// call processRPCTransaction() to iterate through all RPCRequests and
            				// DSRequests and execute them
            				List reqs = rpc.getRequests();
            				
            				Iterator iter= reqs.iterator();
            				while(iter.hasNext()){
            					Object o = iter.next();
            					if(o instanceof RPCRequest){
            			RPCResponse resp =			handleRPCRequest((RPCRequest) o, rpc, context);						
                                    rpc.send(resp);
            					}
            					
            					if(o instanceof DSRequest){
            						DSResponse resp = handleDSRequest((DSRequest) o, rpc,context);
                                                            rpc.send((DSRequest)o, resp);
            					}
            					
            				 }
            
            
            			} catch (Throwable e) {
            				handleError(response, e);
            			}
            		} else {
            			super.processRequest(request, response);
            		}
            	}
            Last edited by Kah0ona; 13 Oct 2010, 05:09.

            Comment

            Working...
            X