use of edu.uiuc.ncsa.myproxy.oa4mp.oauth2.servlet.LDAPClaimsSource in project OA4MP by ncsa.
the class OA2ConfigurationLoader method getClaimSource.
public ClaimSource getClaimSource() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
DebugUtil.dbg(this, "Getting scope handler " + claimSource);
if (claimSource == null) {
// This gets the scopes if any and injects them into the scope handler.
if (0 < cn.getChildrenCount(SCOPES)) {
String scopeHandlerName = getFirstAttribute(Configurations.getFirstNode(cn, SCOPES), SCOPE_HANDLER);
if (scopeHandlerName != null) {
Class<?> k = Class.forName(scopeHandlerName);
Object x = k.newInstance();
if (!(x instanceof ClaimSource)) {
throw new GeneralException("The scope handler specified by the class name \"" + scopeHandlerName + "\" does not extend the ScopeHandler " + "interface and therefore cannot be used to handle scopes.");
}
claimSource = (ClaimSource) x;
} else {
info("Scope handler attribute found in configuration, but no value was found for it. Skipping custom loaded scope handling.");
}
}
// no scopes element, so just use the basic handler.
if (claimSource == null) {
DebugUtil.dbg(this, "No server-wide configured Scope handler");
if (getLdapConfiguration().isEnabled()) {
DebugUtil.dbg(this, " LDAP scope handler enabled, creating default");
claimSource = new LDAPClaimsSource(getLdapConfiguration(), myLogger);
} else {
DebugUtil.dbg(this, " LDAP scope handler disabled, creating basic");
claimSource = new BasicClaimsSourceImpl();
}
}
claimSource.setScopes(getScopes());
DebugUtil.dbg(this, " Actual scope handler = " + claimSource.getClass().getSimpleName());
}
return claimSource;
}
Aggregations