Search in sources :

Example 16 with ApplicationType

use of com.tremolosecurity.config.xml.ApplicationType in project OpenUnison by TremoloSecurity.

the class LoadApplicationsFromK8s 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 application " + name);
        try {
            synchronized (GlobalEntries.getGlobalEntries().getConfigManager()) {
                ApplicationType app = this.createApplication(item, name);
                GlobalEntries.getGlobalEntries().getConfigManager().deleteApp(app.getName());
                GlobalEntries.getGlobalEntries().getConfigManager().initializeUrls(GlobalEntries.getGlobalEntries().getConfigManager().addApplication(app));
            }
        } catch (Exception e) {
            logger.warn("Could not modify application " + name, e);
        }
    } catch (ParseException e) {
        throw new ProvisioningException("Could not parse custom authorization", e);
    }
}
Also used : ApplicationType(com.tremolosecurity.config.xml.ApplicationType) JSONObject(org.json.simple.JSONObject) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) JSONParser(org.json.simple.parser.JSONParser) ParseException(org.json.simple.parser.ParseException) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) ParseException(org.json.simple.parser.ParseException)

Aggregations

ApplicationType (com.tremolosecurity.config.xml.ApplicationType)16 IOException (java.io.IOException)6 ParamType (com.tremolosecurity.config.xml.ParamType)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 ProvisioningException (com.tremolosecurity.provisioning.core.ProvisioningException)4 Attribute (com.tremolosecurity.saml.Attribute)4 ServletException (javax.servlet.ServletException)4 AuthMechParamType (com.tremolosecurity.config.xml.AuthMechParamType)3 FilterConfigType (com.tremolosecurity.config.xml.FilterConfigType)3 ParamWithValueType (com.tremolosecurity.config.xml.ParamWithValueType)3 TrustType (com.tremolosecurity.config.xml.TrustType)3 UrlType (com.tremolosecurity.config.xml.UrlType)3 LDAPAttribute (com.novell.ldap.LDAPAttribute)2 LDAPException (com.novell.ldap.LDAPException)2 AuthChainType (com.tremolosecurity.config.xml.AuthChainType)2 CustomAzRuleType (com.tremolosecurity.config.xml.CustomAzRuleType)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 DateTime (org.joda.time.DateTime)2