use of com.tremolosecurity.config.xml.AzRuleType in project OpenUnison by TremoloSecurity.
the class ListOrgs method copyOrg.
private void copyOrg(Organization org, OrgType ot, AzSys az, AuthInfo auinfo) throws MalformedURLException, ProvisioningException {
ConfigManager cfgMgr = GlobalEntries.getGlobalEntries().getConfigManager();
if (ot.getAzRules() != null && ot.getAzRules().getRule().size() > 0) {
ArrayList<AzRule> rules = new ArrayList<AzRule>();
for (AzRuleType art : ot.getAzRules().getRule()) {
rules.add(new AzRule(art.getScope(), art.getConstraint(), art.getClassName(), cfgMgr, null));
}
if (!az.checkRules(auinfo, cfgMgr, rules, null)) {
return;
}
}
org.setId(ot.getUuid());
org.setName(ot.getName());
org.setDescription(ot.getDescription());
for (OrgType child : ot.getOrgs()) {
Organization sub = new Organization();
org.getSubOrgs().add(sub);
copyOrg(sub, child, az, auinfo);
}
}
use of com.tremolosecurity.config.xml.AzRuleType in project OpenUnison by TremoloSecurity.
the class ListReports method checkOrg.
private void checkOrg(HashSet<String> allowedOrgs, OrgType ot, AzSys az, AuthInfo auinfo) throws MalformedURLException, ProvisioningException {
ConfigManager cfgMgr = GlobalEntries.getGlobalEntries().getConfigManager();
if (ot.getAzRules() != null && ot.getAzRules().getRule().size() > 0) {
ArrayList<AzRule> rules = new ArrayList<AzRule>();
for (AzRuleType art : ot.getAzRules().getRule()) {
rules.add(new AzRule(art.getScope(), art.getConstraint(), art.getClassName(), cfgMgr, null));
}
if (!az.checkRules(auinfo, cfgMgr, rules, null)) {
return;
}
}
allowedOrgs.add(ot.getUuid());
for (OrgType child : ot.getOrgs()) {
checkOrg(allowedOrgs, child, az, auinfo);
}
}
use of com.tremolosecurity.config.xml.AzRuleType in project OpenUnison by TremoloSecurity.
the class OrgTypeHolder method addOrg.
private void addOrg(TremoloType tremolo, Object o) {
JSONObject trustObj = (JSONObject) o;
JSONObject metadata = (JSONObject) trustObj.get("metadata");
JSONObject spec = (JSONObject) trustObj.get("spec");
logger.info(metadata.get("name"));
StringBuffer b = new StringBuffer();
OrgType org = new OrgType();
String label = (String) spec.get("label");
if (label == null) {
org.setName((String) metadata.get("name"));
} else {
b.setLength(0);
OpenUnisonConfigLoader.integrateIncludes(b, label);
org.setName(b.toString());
}
if (spec.get("description") != null) {
b.setLength(0);
OpenUnisonConfigLoader.integrateIncludes(b, (String) spec.get("description"));
org.setDescription(b.toString());
}
b.setLength(0);
OpenUnisonConfigLoader.integrateIncludes(b, (String) spec.get("uuid"));
org.setUuid(b.toString());
org.setShowInPortal(((Boolean) spec.get("showInPortal")));
org.setShowInReports(((Boolean) spec.get("showInReports")));
org.setShowInRequestsAccess(((Boolean) spec.get("showInRequestAccess")));
org.setAzRules(new AzRulesType());
String parentId = (String) spec.get("parent");
JSONArray rules = (JSONArray) spec.get("azRules");
for (Object orr : rules) {
JSONObject rule = (JSONObject) orr;
AzRuleType art = new AzRuleType();
b.setLength(0);
OpenUnisonConfigLoader.integrateIncludes(b, (String) rule.get("scope"));
art.setScope(b.toString());
b.setLength(0);
OpenUnisonConfigLoader.integrateIncludes(b, (String) rule.get("constraint"));
art.setConstraint(b.toString());
org.getAzRules().getRule().add(art);
}
OrgType parent = this.findById(parentId, tremolo.getProvisioning().getOrg());
if (parent == null) {
for (String oid : this.orphanes.keySet()) {
OrgType orphan = this.orphanes.get(oid);
parent = this.findById(parentId, orphan);
if (parent != null) {
break;
}
}
}
if (parent == null) {
OrgType oot = new OrgType();
oot.setUuid(parentId);
oot.setAzRules(new AzRulesType());
oot.getOrgs().add(org);
this.orphanes.put(parentId, oot);
} else {
this.deleteOrg(tremolo, org.getUuid());
parent.getOrgs().add(org);
}
if (this.orphanes.containsKey(org.getUuid())) {
OrgType oot = this.orphanes.remove(org.getUuid());
org.getOrgs().addAll(oot.getOrgs());
}
}
use of com.tremolosecurity.config.xml.AzRuleType in project OpenUnison by TremoloSecurity.
the class AzFilter method doFilter.
@Override
public void doFilter(HttpFilterRequest request, HttpFilterResponse response, HttpFilterChain chain) throws Exception {
HttpSession session = request.getSession();
AuthInfo authData = ((AuthController) request.getSession().getAttribute(ProxyConstants.AUTH_CTL)).getAuthInfo();
UrlHolder holder = (UrlHolder) request.getAttribute(ProxyConstants.AUTOIDM_CFG);
List<AzRuleType> rules = holder.getUrl().getAzRules().getRule();
boolean OK = az.checkRules(authData, holder.getConfig(), holder.getAzRules(), null);
if (OK) {
String respGroup = az.getResponseSuccessGroup(holder);
AccessLog.log(AccessEvent.AzSuccess, holder.getApp(), request.getServletRequest(), authData, respGroup != null ? respGroup : "NONE");
if (respGroup != null) {
az.processRequestResult(request.getServletRequest(), response.getServletResponse(), holder.getConfig().getResultGroup(respGroup), authData);
}
chain.nextFilter(request, response, chain);
if (respGroup != null) {
az.proccessResponseResult(request.getServletRequest(), response.getServletResponse(), holder.getConfig().getResultGroup(respGroup), false, authData, holder.getApp().getCookieConfig());
}
} else {
String respGroup = az.getResponseFailGroup(holder);
AccessLog.log(AccessEvent.AzFail, holder.getApp(), request.getServletRequest(), authData, respGroup != null ? respGroup : "NONE");
if (respGroup != null) {
az.proccessResponseResult(request.getServletRequest(), response.getServletResponse(), holder.getConfig().getResultGroup(respGroup), true, authData, holder.getApp().getCookieConfig());
} else {
((HttpServletResponse) response).sendError(401);
}
}
}
use of com.tremolosecurity.config.xml.AzRuleType in project OpenUnison by TremoloSecurity.
the class ScaleMain method copyOrg.
private boolean copyOrg(Organization org, OrgType ot, AzSys az, AuthInfo auinfo) throws MalformedURLException, ProvisioningException {
ConfigManager cfgMgr = GlobalEntries.getGlobalEntries().getConfigManager();
if (ot.getAzRules() != null && ot.getAzRules().getRule().size() > 0) {
ArrayList<AzRule> rules = new ArrayList<AzRule>();
for (AzRuleType art : ot.getAzRules().getRule()) {
rules.add(new AzRule(art.getScope(), art.getConstraint(), art.getClassName(), cfgMgr, null));
}
if (!az.checkRules(auinfo, cfgMgr, rules, new HashMap<String, Object>())) {
return false;
}
}
org.setId(ot.getUuid());
org.setName(ot.getName());
org.setDescription(ot.getDescription());
org.setShowInPortal(ot.isShowInPortal());
org.setShowInReports(ot.isShowInReports());
org.setShowInRequest(ot.isShowInRequestsAccess());
for (OrgType child : ot.getOrgs()) {
Organization sub = new Organization();
if (copyOrg(sub, child, az, auinfo)) {
org.getSubOrgs().add(sub);
}
}
return true;
}
Aggregations