I'm using Spring 4.x and trying to get @PreAuthorize to work, but for some reason the program continues without an exception as if there was no @PreAuthorize. I've read the documentation and I've looked at other posts here, but to no avail and have no idea where I'm going wrong as there is no errors being reported.
I have the following configurations:
@EnableGlobalMethodSecurity(securedEnabled=true, prePostEnabled = true, proxyTargetClass = true)
public class WorkInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
      @Override
      protected Class<?>[] getRootConfigClasses() {
          return new Class<?>[] { RootConfig.class };
      }
      @Override
      protected Class<?>[] getServletConfigClasses() {
        return new Class<?>[] { WebConfig.class };
      }
      @Override
      protected String[] getServletMappings() {
        return new String[] { "/" };
      }
}
And..
@EnableGlobalMethodSecurity(securedEnabled=true, prePostEnabled = true, proxyTargetClass = true)
public class MethodSecurityConfig extends GlobalMethodSecurityConfiguration {
...
}
and in my controller:
  @PreAuthorize("#username == authentication.name")
  @RequestMapping(value="/{username}", method=GET)
  public String viewPrivateProfile(@P("username") @PathVariable String username, Model model) {
      logger.debug("Debug: Entered Private Profile!");
      return "privateprofile";
  }
In the logs, it shows that @PreAuthorize has been found:
16:41:43.018 [localhost-startStop-1] DEBUG o.s.s.a.p.PrePostAnnotationSecurityMetadataSource - @org.springframework.security.access.prepost.PreAuthorize(value=#username == authentication.name) found on specific method: public java.lang.String com.work.personnel.ViewController.viewPrivateProfile(java.lang.String,org.springframework.ui.Model)
So, if I login as 'bob', I can also view 'mike's private profile by going to the following link:
http://localhost:8080/workarea/profile/private/mike
What could I have possibly done wrong when all my other Security features, such as, authorizeRequests().antMatchers(...), etc. work as expected?