code: private static boolean removeCryptographyRestrictions() {
          Logger logger = LoggerFactory.getLogger(Stack.class);
  
          if (isRestrictedCryptography()) {
              try {
                  final Class<?> jceSecurity = Class.forName("javax.crypto.JceSecurity");
                  final Class<?> cryptoPermissions = Class.forName("javax.crypto.CryptoPermissions");
                  final Class<?> cryptoAllPermission = Class.forName("javax.crypto.CryptoAllPermission");
  
                  final Field isRestrictedField = jceSecurity.getDeclaredField("isRestricted");
                  isRestrictedField.setAccessible(true);
                  isRestrictedField.set(null, false);
  
                  final Field defaultPolicyField = jceSecurity.getDeclaredField("defaultPolicy");
                  defaultPolicyField.setAccessible(true);
                  final PermissionCollection defaultPolicy = (PermissionCollection) defaultPolicyField.get(null);
  
                  final Field perms = cryptoPermissions.getDeclaredField("perms");
                  perms.setAccessible(true);
                  ((Map<?, ?>) perms.get(defaultPolicy)).clear();
  
                  final Field instance = cryptoAllPermission.getDeclaredField("INSTANCE");
                  instance.setAccessible(true);
                  defaultPolicy.add((Permission) instance.get(null));
  
                  logger.info("Successfully removed cryptography restrictions.");
                  return true;
              } catch (final Exception e) {
                  logger.warn("Failed to remove cryptography restrictions.", e);
                  return false;
              }
          }
  
          return true;
      }
docs: Do the following, but with reflection to bypass access checks:
  <p>
  JceSecurity.isRestricted = false;
  JceSecurity.defaultPolicy.perms.clear();
  JceSecurity.defaultPolicy.add(CryptoAllPermission.INSTANCE);