public SealConfig BarrierConfig() { if (Config != null) { return(Config.Clone()); } CheckCore(); // if err := d.checkCore(); err != nil { // return nil, err // } // // Fetch the core configuration // pe, err := d.core.physical.Get(barrierSealConfigPath) // if err != nil { // d.core.logger.Error("core: failed to read seal configuration", "error", err) // return nil, fmt.Errorf("failed to check seal configuration: %v", err) // } // // If the seal configuration is missing, we are not initialized // if pe == nil { // d.core.logger.Info("core: seal configuration missing, not initialized") // return nil, nil // } // var conf SealConfig // // Decode the barrier entry // if err := jsonutil.DecodeJSON(pe.Value, &conf); err != nil { // d.core.logger.Error("core: failed to decode seal configuration", "error", err) // return nil, fmt.Errorf("failed to decode seal configuration: %v", err) // } // switch conf.Type { // // This case should not be valid for other types as only this is the default // case "": // conf.Type = d.BarrierType() // case d.BarrierType(): // default: // d.core.logger.Error("core: barrier seal type does not match loaded type", "barrier_seal_type", conf.Type, "loaded_seal_type", d.BarrierType()) // return nil, fmt.Errorf("barrier seal type of %s does not match loaded type of %s", conf.Type, d.BarrierType()) // } // // Check for a valid seal configuration // if err := conf.Validate(); err != nil { // d.core.logger.Error("core: invalid seal configuration", "error", err) // return nil, fmt.Errorf("seal validation failed: %v", err) // } // d.config = &conf return(Config.Clone()); }
public void SetBarrierConfig(SealConfig config) { CheckCore(); // Provide a way to wipe out the cached value (also prevents actually // saving a nil config) if (config == null) { Config = null; return; } config.Type = BarrierType; // Encode the seal configuration var buf = JsonConvert.SerializeObject(config); //json.Marshal(config); // if err != nil { // return fmt.Errorf("failed to encode seal configuration: %v", err) // } // // Store the seal configuration // pe := &physical.Entry{ // Key: barrierSealConfigPath, // Value: buf, // } // if err := d.core.physical.Put(pe); err != nil { // d.core.logger.Error("core: failed to write seal configuration", "error", err) // return fmt.Errorf("failed to write seal configuration: %v", err) // } Config = config.Clone(); }