use of com.tremolosecurity.proxy.az.AzException in project OpenUnison by TremoloSecurity.
the class FreeIPAAz method listPossibleApprovers.
@Override
public List<String> listPossibleApprovers(String... params) throws AzException {
ConfigManager cfg = GlobalEntries.getGlobalEntries().getConfigManager();
try {
FreeIPATarget ipa = (FreeIPATarget) cfg.getProvisioningEngine().getTarget(this.targetName).getProvider();
IPACall showGroup = new IPACall();
showGroup.setId(0);
showGroup.setMethod("group_show");
ArrayList<String> groupName = new ArrayList<String>();
groupName.add(params[0]);
showGroup.getParams().add(groupName);
HashMap<String, String> additionalParams = new HashMap<String, String>();
additionalParams.put("no_members", "true");
showGroup.getParams().add(additionalParams);
IPAResponse resp = ipa.executeIPACall(showGroup);
ArrayList<FilterBuilder> checks = new ArrayList<FilterBuilder>();
if (((Map) resp.getResult().getResult()).containsKey("ipaexternalmember")) {
List<String> vals = (List<String>) ((Map) resp.getResult().getResult()).get("ipaexternalmember");
for (String val : vals) {
checks.add(equal(this.uidAttributeName, val));
}
}
FilterBuilder[] filters = new FilterBuilder[checks.size()];
checks.toArray(filters);
String filter = or(filters).toString();
ArrayList<String> attrsToGet = new ArrayList<String>();
attrsToGet.add("1.1");
LDAPSearchResults ldapSearch = cfg.getMyVD().search(cfg.getCfg().getLdapRoot(), 2, filter, attrsToGet);
ArrayList<String> approvers = new ArrayList<String>();
while (ldapSearch.hasMore()) {
approvers.add(ldapSearch.next().getDN());
}
return approvers;
} catch (Exception e) {
throw new AzException("Could not process authorization", e);
}
}
use of com.tremolosecurity.proxy.az.AzException in project OpenUnison by TremoloSecurity.
the class GithubTeamRule method isAuthorized.
@Override
public boolean isAuthorized(AuthInfo subject, String... params) throws AzException {
if (params.length == 0) {
// No parameters, allways true
return true;
}
List<FilterBuilder> comps = new ArrayList<FilterBuilder>();
for (String param : params) {
if (param.endsWith("/")) {
comps.add(equal("githubOrgs", param.substring(0, param.indexOf("/"))));
} else {
comps.add(equal("githubTeams", param));
}
}
FilterBuilder[] ands = new FilterBuilder[comps.size()];
comps.toArray(ands);
String filterString = or(ands).toString();
net.sourceforge.myvd.types.Filter filter;
try {
filter = new net.sourceforge.myvd.types.Filter(filterString);
} catch (LDAPException e) {
throw new AzException("Could not build authorization rule", e);
}
return filter.getRoot().checkEntry(subject.createLDAPEntry());
}
Aggregations