package org.jivesoftware.smack.sasl.core;

import javax.security.auth.callback.CallbackHandler;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.sasl.SASLMechanism;
import org.jivesoftware.smack.util.stringencoder.Base64;

public class SASLXOauth2Mechanism extends SASLMechanism {
   public static final String NAME = "X-OAUTH2";

   protected void authenticateInternal(CallbackHandler cbh) throws SmackException {
      throw new UnsupportedOperationException("CallbackHandler not (yet) supported");
   }

   protected byte[] getAuthenticationText() throws SmackException {
      return Base64.encode(toBytes('\u0000' + this.authenticationId + '\u0000' + this.password));
   }

   public String getName() {
      return "X-OAUTH2";
   }

   public int getPriority() {
      return 410;
   }

   public SASLXOauth2Mechanism newInstance() {
      return new SASLXOauth2Mechanism();
   }

   public void checkIfSuccessfulOrThrow() throws SmackException {
   }
}
