use of com.disney.http.auth.server.policy.PolicyVerifierImpl in project groovity by disney.
the class VerifierFactory method processPolicy.
private PolicyVerifierImpl processPolicy(@SuppressWarnings("rawtypes") final Map policy, Class<Script> scriptClass) throws MalformedURLException, URISyntaxException, InstantiationException, IllegalAccessException, ClassNotFoundException {
PolicyVerifierImpl verifier = new PolicyVerifierImpl();
processCommon(verifier, policy, scriptClass);
verifier.setPolicyLoader(new Callable<Verifier>() {
String curPolicy = null;
Callable<Verifier> curLoader = null;
public Verifier call() throws Exception {
String loc = resolve(policy, "policy", String.class);
if (!loc.equals(curPolicy)) {
// location has changed, update loaded policy
URI policyURI = null;
if (loc.startsWith("/")) {
URL url = viewResolver.getServletContext().getResource(loc);
if (url != null) {
policyURI = url.toURI();
} else {
ViewPolicyLoader vpl = new ViewPolicyLoader();
vpl.setLocation(loc);
vpl.setViewResolver(viewResolver);
curLoader = vpl;
}
} else {
policyURI = new URI(loc);
}
if (policyURI != null) {
Number ttl = (Number) policy.get("ttl");
// set right loader based on location: view, file, HTTP url or servlet url ...
URIParcel<Verifier> parcel = new URIParcel<Verifier>(Verifier.class, policyURI);
if (ttl != null) {
parcel.setRefresh(ttl.longValue());
}
curLoader = parcel;
}
curPolicy = loc;
}
return curLoader.call();
}
});
return verifier;
}
Aggregations