use of com.tremolosecurity.provisioning.core.ProvisioningException in project OpenUnison by TremoloSecurity.
the class LoadGroupMetadataFromK8s method modifyObject.
@Override
public void modifyObject(TremoloType cfg, JSONObject item) throws ProvisioningException {
String rawJson = item.toJSONString();
StringBuffer b = new StringBuffer();
b.setLength(0);
OpenUnisonConfigLoader.integrateIncludes(b, rawJson);
try {
JSONObject newRoot = (JSONObject) new JSONParser().parse(b.toString());
JSONObject metadata = (JSONObject) newRoot.get("metadata");
if (metadata == null) {
throw new ProvisioningException("No metadata");
}
String name = (String) metadata.get("name");
logger.info("Modifying GroupMetadata " + name);
try {
JSONObject spec = (JSONObject) newRoot.get("spec");
String k8s = (String) spec.get("groupName");
String ext = (String) spec.get("externalName");
this.md.addMapping(k8s, ext);
} catch (Exception e) {
logger.warn("Could not initialize group mapping " + name, e);
return;
}
} catch (ParseException e) {
throw new ProvisioningException("Could not parse groupmetadata", e);
}
}
use of com.tremolosecurity.provisioning.core.ProvisioningException in project OpenUnison by TremoloSecurity.
the class LoadGroupMetadataFromK8s method addObject.
@Override
public void addObject(TremoloType cfg, JSONObject item) throws ProvisioningException {
String rawJson = item.toJSONString();
StringBuffer b = new StringBuffer();
b.setLength(0);
OpenUnisonConfigLoader.integrateIncludes(b, rawJson);
try {
JSONObject newRoot = (JSONObject) new JSONParser().parse(b.toString());
JSONObject metadata = (JSONObject) newRoot.get("metadata");
if (metadata == null) {
throw new ProvisioningException("No metadata");
}
String name = (String) metadata.get("name");
logger.info("Adding GroupMetadata " + name);
try {
JSONObject spec = (JSONObject) newRoot.get("spec");
String k8s = (String) spec.get("groupName");
String ext = (String) spec.get("externalName");
this.md.addMapping(k8s, ext);
} catch (Exception e) {
logger.warn("Could not initialize group mapping " + name, e);
return;
}
} catch (ParseException e) {
throw new ProvisioningException("Could not parse custom groupmetadata", e);
}
}
use of com.tremolosecurity.provisioning.core.ProvisioningException in project OpenUnison by TremoloSecurity.
the class LoadJavaScriptMappingFromK8s method addObject.
@Override
public void addObject(TremoloType cfg, JSONObject item) throws ProvisioningException {
String rawJson = item.toJSONString();
StringBuffer b = new StringBuffer();
b.setLength(0);
OpenUnisonConfigLoader.integrateIncludes(b, rawJson);
try {
JSONObject newRoot = (JSONObject) new JSONParser().parse(b.toString());
JSONObject metadata = (JSONObject) newRoot.get("metadata");
if (metadata == null) {
throw new ProvisioningException("No metadata");
}
String name = (String) metadata.get("name");
logger.info("Adding mapping " + name);
maps.put(name, (String) ((JSONObject) newRoot.get("spec")).get("javascript"));
} catch (ParseException e) {
throw new ProvisioningException("Could not parse resultgroup", e);
}
}
use of com.tremolosecurity.provisioning.core.ProvisioningException in project OpenUnison by TremoloSecurity.
the class LoadJavaScriptMappingFromK8s method modifyObject.
@Override
public void modifyObject(TremoloType cfg, JSONObject item) throws ProvisioningException {
String rawJson = item.toJSONString();
StringBuffer b = new StringBuffer();
b.setLength(0);
OpenUnisonConfigLoader.integrateIncludes(b, rawJson);
try {
JSONObject newRoot = (JSONObject) new JSONParser().parse(b.toString());
JSONObject metadata = (JSONObject) newRoot.get("metadata");
if (metadata == null) {
throw new ProvisioningException("No metadata");
}
String name = (String) metadata.get("name");
logger.info("modifying mapping " + name);
maps.put(name, (String) ((JSONObject) newRoot.get("spec")).get("javascript"));
} catch (ParseException e) {
throw new ProvisioningException("Could not parse resultgroup", e);
}
}
use of com.tremolosecurity.provisioning.core.ProvisioningException in project OpenUnison by TremoloSecurity.
the class LoadJavaScriptMappingFromK8s method deleteObject.
@Override
public void deleteObject(TremoloType cfg, JSONObject item) throws ProvisioningException {
JSONObject metadata = (JSONObject) item.get("metadata");
if (metadata == null) {
throw new ProvisioningException("No metadata");
}
String name = (String) metadata.get("name");
logger.info("Deleting mapping " + name);
maps.remove(name);
}
Aggregations