title: SpringSecurity + JSF custom authentication
body: <p>I trying find solution but noone work. i've some spring security configs and frontend written in JSF. I found some configs in intenter but together they dont  wanna work</p>
  
  <pre><code>&lt;http&gt;
       &lt;intercept-url pattern="/index*" access="IS_AUTHENTICATED_ANONYMOUSLY" /&gt;
       &lt;intercept-url pattern="/javax.faces.resource/**"
          access="IS_AUTHENTICATED_ANONYMOUSLY" /&gt;
       &lt;intercept-url pattern="/**" access="ROLE_USER" /&gt;
       &lt;intercept-url pattern="/admin/*" access="ROLE_SUPERVISOR" /&gt;
       &lt;form-login login-page="/index.html" default-target-url="/home.html"
          always-use-default-target="true" authentication-failure-url="/index.xhtml?login_error=1" /&gt;
       &lt;logout logout-url="/logout.html" /&gt;
  &lt;/http&gt;
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>    &lt;authentication-manager&gt;
      &lt;authentication-provider&gt;               
          &lt;user-service&gt;
              &lt;user name="admin" password="admin" authorities="ROLE_USER, ROLE_SUPERVISOR" /&gt;
              &lt;user name="anonim" password="anonim" authorities="" /&gt;
              &lt;user name="user" password="user" authorities="ROLE_USER" /&gt;
          &lt;/user-service&gt;
      &lt;/authentication-provider&gt;
  &lt;/authentication-manager&gt;
  </code></pre>
  
  <p>I'd like to make some custom class that will be like custom logger i found solution that will be similar these: </p>
  
  <pre><code>public class LoginBeenController {
      private static final Logger LOGGER = Logger.getLogger(LoginBeenController.class);
  
      private String login;
      private String password;
      @Autowired
      private AuthenticationManager authenticationManager;
  
      public LoginBeenController() {
  
      }
  
      public String getLogin() {
          return login;
      }
  
      public String getPassword() {
          return password;
      }
  
      public void setLogin(String login) {
          this.login = login;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
      public String login(){
          Authentication authentication = authenticationManager
                  .authenticate(new UsernamePasswordAuthenticationToken(
                          this.login, this.password));
          if (authentication.isAuthenticated()) {
              SecurityContextHolder.getContext().setAuthentication(
                      authentication);
          }
          return new String();
      }
  
  }
  </code></pre>
  
  <p>Here is prime form:</p>
  
  <pre><code>&lt;h:form&gt;    
      &lt;h:panelGrid columns="2" cellpadding="5"&gt;  
          &lt;h:outputLabel for="username" name='j_username' value="Username:" /&gt;  
          &lt;p:inputText id="username" value="#{loginBeenController.login}" required="true" label="username" /&gt;  
  
          &lt;h:outputLabel for="password" value="Password:" /&gt;  
          &lt;h:inputSecret id="password" value='#{loginBeenController.password}' required="true" label="password" /&gt;  
  
          &lt;f:facet name="footer"&gt;  
              &lt;p:commandButton ajax='false' id="loginButton" value="Login" action="#{loginBeenController.login()}" /&gt;  
          &lt;/f:facet&gt;  
      &lt;/h:panelGrid&gt;            
  &lt;/h:form&gt;
  </code></pre>