package com.airlock.iam.common.domain.model.jwt.encryption;

import com.nimbusds.jose.EncryptionMethod;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

public enum DirectEncryptionMethod {
   A256GCM,
   A192GCM,
   A128GCM,
   A256CBC_HS512,
   A192CBC_HS384,
   A128CBC_HS256;

   public static DirectEncryptionMethod of(EncryptionMethod encryptionMethod) {
      if (EncryptionMethod.A256GCM.equals(encryptionMethod)) {
         return A256GCM;
      } else if (EncryptionMethod.A192GCM.equals(encryptionMethod)) {
         return A192GCM;
      } else if (EncryptionMethod.A128GCM.equals(encryptionMethod)) {
         return A128GCM;
      } else if (EncryptionMethod.A256CBC_HS512.equals(encryptionMethod)) {
         return A256CBC_HS512;
      } else if (EncryptionMethod.A192CBC_HS384.equals(encryptionMethod)) {
         return A192CBC_HS384;
      } else if (EncryptionMethod.A128CBC_HS256.equals(encryptionMethod)) {
         return A128CBC_HS256;
      } else {
         throw new IllegalArgumentException("Unsupported encryption method " + encryptionMethod.getName());
      }
   }
}
