Results 1 to 9 of 9

Thread: Loading during j_spring_security_check other functions

  1. #1
    Join Date
    Dec 2009
    Posts
    21

    Default Loading during j_spring_security_check other functions

    Hello all,
    I have a problem after my login:

    My login works.
    But now: After login I want to redirect to a page with datatables.
    The problem is now, that I must load this tables to load the entries.
    So I must call my functions to load this entries in my datatable.
    How and where can I fix this?

  2. #2
    Luke Taylor is offline Senior Member Acegi Security System TeamSpring Team
    Join Date
    Aug 2004
    Location
    Glasgow, Scotland
    Posts
    3,449

    Default

    Not really sure what the problem is... Can't you just use a standard MVC controller for the page you want to redirect to, and load the data there?
    Spring - by Pivotal
    twitter @tekul

  3. #3
    Join Date
    Dec 2009
    Posts
    21

    Default

    Quote Originally Posted by Luke Taylor View Post
    Can't you just use a standard MVC controller for the page you want to redirect to, and load the data there?
    Yes, I think so.
    Can you show me the code please?

    I donīt know which classes form Spring Security I should to be use for this function.

  4. #4
    Luke Taylor is offline Senior Member Acegi Security System TeamSpring Team
    Join Date
    Aug 2004
    Location
    Glasgow, Scotland
    Posts
    3,449

    Default

    They aren't Spring Security classes, just plain Spring ones. If you don't understand Spring MVC then you can use a plain servlet.
    Spring - by Pivotal
    twitter @tekul

  5. #5
    Join Date
    Dec 2009
    Posts
    21

    Default

    Okay, I have an idea.
    But I need the login-information (username, password, enable) after the action: /j_spring_security_check

    Code:
    		 
    <h:form id="formLoginEingabe" action="/j_spring_security_check" method="post">
    
    <h:panelGrid id="loginGrid" columns="3">
    						
    	<h:outputLabel value="RACF:"/>
    	<h:inputText id="j_username" size="30" styleClass="inputText"/>
    		
    	<h:outputLabel  value="Password:"/>
    	<h:inputSecret  id="j_password"  size="30" styleClass="inputText"/>
            
            <h:commandButton action="#{auth.startpage}" value="Login"/>
      </h:panelGrid>
    </h:form>


    Here my function startpage():
    The red words are the issues.
    I need the UserDetails in this function.
    How can I get this information????

    Code:
    public String startpage()  {
    		
    		Map<String, Object> sessionMap = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
    		us.getUsername();
    		
    try{
    	ExternalContext ext=FacesContext.getCurrentInstance().getExternalContext();
    	findUser = (User) ext.getSessionMap().get(AuthMgdBean.USER_LOGIN);			
    
    // Admin
    if(findUser.getRole().equals(Constants.ROLE_ADMIN)){
    		sessionMap.put(ADMIN, findUser);
    
    		newsBean.findNews();
    		vvBean.reporting();
    
    		return "/admin/index";
    	}			
    }
    Last edited by internet; Jul 21st, 2010 at 06:41 AM.

  6. #6
    Luke Taylor is offline Senior Member Acegi Security System TeamSpring Team
    Join Date
    Aug 2004
    Location
    Glasgow, Scotland
    Posts
    3,449

    Default

    Please check the manual for more information.
    Spring - by Pivotal
    twitter @tekul

  7. #7
    Join Date
    Dec 2009
    Posts
    21

    Default

    Thank you for your reply.

    1. I have a problem to get my role (Authority).
    2. How can I get the whole Object "User"?

    Code:
    public String startpage() throws ServletException, IOException{	
    Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    		
    String role;
    					
    if (principal instanceof UserDetails) {
    
    	role = ((GrantedAuthority)principal).getAuthority();
    } else {
    				
    	role = principal.toString();
    }  
    		
    Map<String, Object> sessionMap = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
    		
    	if(role.equals("ROLE_ADMIN")){
    
    			sessionMap.put(ADMIN, findBenutzer);
    			sessionMap.put(BENUTZER_EINGELOGGT, findBenutzer);
    									
    			newsBean.findNews();
    			vvBean.reporting();
    
    			return "/admin/ok";
    		}

  8. #8
    Luke Taylor is offline Senior Member Acegi Security System TeamSpring Team
    Join Date
    Aug 2004
    Location
    Glasgow, Scotland
    Posts
    3,449

    Default

    The principal is the user object. Or whatever is returned by the authentication provider... Please read the technical overview chapter to get an understanding of how things fit together.
    Spring - by Pivotal
    twitter @tekul

  9. #9
    Join Date
    Dec 2009
    Posts
    21

    Default

    Only one question:

    How can I get the role (GrantedAuthority) from the principal?
    My problem is, that GrantedAuthority is a list.
    So I cannot got this Property over a "get-Property".

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •