Announcement Announcement Module
Collapse
No announcement yet.
pb accessing user info in a view Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      pb fixed

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

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

      Comment

      Working...
      X