package com.airlock.iam.saml2.infrastructure.plugin;

import com.airlock.iam.elog.api.ELogger;
import com.airlock.iam.elog.api.ELoggerFactory;
import com.airlock.iam.saml2.domain.model.logging.Saml2LogTypes;
import com.sun.identity.saml.xmlsig.KeyProvider;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;

public final class SamlNoCertKeyProviderImpl implements KeyProvider {
   private static final ELogger LOGGER = ELoggerFactory.getLogger(SamlNoCertKeyProviderImpl.class);

   @Override
   public Certificate getCertificate(PublicKey publicKey) {
      String message = this.getClass().getSimpleName() + " does not support method getCertificate()";
      LOGGER.error(Saml2LogTypes.FEDERATION_LIBRARY_MESSAGE, message);
      throw new UnsupportedOperationException(message);
   }

   @Override
   public KeyStore getKeyStore() {
      String message = this.getClass().getSimpleName() + " does not support method getKeyStore()";
      LOGGER.error(Saml2LogTypes.FEDERATION_LIBRARY_MESSAGE, message);
      throw new UnsupportedOperationException(message);
   }

   @Override
   public PrivateKey getPrivateKey(String certAlias) {
      String message = this.getClass().getSimpleName() + " does not support method getPrivateKey()";
      LOGGER.debug(message + ", returning null");
      return null;
   }

   @Override
   public PublicKey getPublicKey(String keyAlias) {
      String message = this.getClass().getSimpleName() + " does not support method getPublicKey()";
      LOGGER.error(Saml2LogTypes.FEDERATION_LIBRARY_MESSAGE, message);
      throw new UnsupportedOperationException(message);
   }

   @Override
   public X509Certificate getX509Certificate(String certAlias) {
      String message = this.getClass().getSimpleName() + " does not support method getX509Certificate()";
      LOGGER.error(Saml2LogTypes.FEDERATION_LIBRARY_MESSAGE, message);
      throw new UnsupportedOperationException(message);
   }
}
