Results 1 to 3 of 3

Thread: pb accessing user info in a view

  1. #1
    Join Date
    Apr 2009
    Posts
    25

    Default pb accessing user info in a view

    Hi
    I store info in the "SecurityContextHolder"
    i need these info in my View
    Does Anyone know how to retrieve user info in the view ?

    I have
    Code:
    <bean id="securityAwareConfigurer" class="org.springframework.richclient.security.SecurityAwareConfigurer" lazy-init="false"/>
    and
    Code:
    public class MyView extends AbstractView implements AuthenticationAware{
    	
    	private Authentication authentication;
    	protected JComponent createControl() {
    
    		.............
    	}
    
    	public void setAuthenticationToken(Authentication arg0) {
    		this.authentication=arg0;
    		
    	}
    	
    }
    When I open the view, setAuthentificationToken is never fired

  2. #2
    Join Date
    Jun 2008
    Location
    Germany
    Posts
    67

    Default

    In my timefinder application I do something like this:

    Code:
    public class TimeFinderMasterDetailView extends AbstractView {
        ...
    
        @Override
        protected JComponent createControl() {
            YourViewDescriptor descriptor = (YourViewDescriptor)getDescriptor();
            AnyObject obj = descriptor.getAnyProperty();
        }
    ...
    }
    this means for you that you have to extend the DefaultViewDescriptor (->AnyViewDescriptor) with your AuthenticationToken property.

    Now you could either inject it explicitly:
    Code:
    <bean id="featureView" class="YourViewDescriptor">
            <property name="viewClass" value="de.timefinder.core.ui.form.TimeFinderMasterDetailView"/>
            <property name="anyObject" ref="authToken"/>
    ...
        </bean>
    or implicitly with
    Code:
    @Autowired
    public void setAuthToken...
    Hope this helps a bit.

  3. #3
    Join Date
    Apr 2009
    Posts
    25

    Default pb fixed

    I fixed the pb
    I can access values store in security using

    SecurityContextHolder.getContext().getAuthenticati on().getPrincipal();

Posting Permissions

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