title: When getPrincipal() return User object and when it return UserDetail object?
body: <p>My application uses J2eePreauth authentication provider and here is the common code to retrieve MyUser object:</p>
  
  <pre><code>MyUser user = (MyUser)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
  </code></pre>
  
  <p>It works all the time until most recently I may be upgrade Spring security or sth now it gives me </p>
  
  <pre><code>org.springframework.security.core.userdetails.User cannot be cast to com.myapp.domain.MyUser
  </code></pre>
  
  <p>And the class of <code>MyUser</code> is just implement interface <code>UserDetails</code></p>
  
  <p>It's very strange that the casting works all the time but regarding most recent update it fall apart.</p>
  
  <p>So my question is when does <code>SecurityContextHolder.getContext().getAuthentication().getPrincipal()</code> return a UserDetail object and when does it return <code>org.springframework.security.core.userdetails.User</code></p>