/*
  * (non-Javadoc)
  *
  * @see org.picketbox.core.authentication.spi.AuthenticationProvider#supports(java.lang.String)
  */
 @Override
 public boolean supports(String mechanismName) {
   for (AuthenticationMechanism mechanism : this.mechanisms) {
     if (mechanism.getClass().getName().equals(mechanismName)) {
       return true;
     }
   }
   return false;
 }
  /*
   * (non-Javadoc)
   *
   * @see org.picketbox.core.authentication.spi.AuthenticationProvider#getSupportedMechanisms()
   */
  @Override
  public String[] getSupportedMechanisms() {
    String[] mechanisms = new String[this.mechanisms.size()];

    int i = 0;

    for (AuthenticationMechanism entry : this.mechanisms) {
      mechanisms[i++] = entry.getClass().getName();
    }

    return mechanisms;
  }
  /*
   * (non-Javadoc)
   *
   * @see org.picketbox.core.authentication.spi.AuthenticationProvider#getMechanism(java.lang.String)
   */
  @Override
  public AuthenticationMechanism getMechanism(String mechanismName) {
    for (AuthenticationMechanism currentMechanism : this.mechanisms) {

      if (currentMechanism instanceof AbstractAuthenticationMechanism) {
        ((AbstractAuthenticationMechanism) currentMechanism)
            .setPicketBoxManager(this.picketBoxManager);
      }

      if (currentMechanism.getClass().getName().equals(mechanismName)) {
        return currentMechanism;
      }
    }

    return null;
  }