context.getParameters().set(name,value,false);
}
List<Link> auths = hostConf.getLinks().get("auth-service");
if (auths!=null && auths.size()>0) {
Link authLink = auths.get(0);
getLogger().info("Adding identity and security filters.");
router = new Router(context);
router.setDefaultMatchingMode(Template.MODE_STARTS_WITH);
security = new SecurityGuard(context);
security.setNext(router);
final IdentityFilter filter = new IdentityFilter(context,security,new Reference(authLink.getLink().toString()));
vhost.attachDefault(filter);
this.context.getAttributes().put(IdentityManager.ATTR, new IdentityManager() {
public void add(String id,Identity identity) {
filter.addIdentity(id, identity);
}
public boolean remove(String id)
{
return filter.removeIdentity(id);
}
});
}
this.staticApplications = new ArrayList<AppInfo>();
for (Configuration.Content content : hostConf.getContentSources()) {
try {
final String uri = content.getSource().toString();
String scheme = content.getSource().getScheme();
if (scheme.equals("http") || scheme.equals("https")) {
getLogger().info(" Proxy: "+content.getSource()+" at "+content.getMatch());
ProxyApplication proxy = new ProxyApplication(context,uri.toString());
proxy.getTunnelService().setEnabled(false);
router.attach(content.getMatch(),proxy);
} else {
// hope the directory resource can handle it
getLogger().info(" Directory: "+content.getSource()+" at "+content.getMatch());
Application app = new Application(context) {
public Restlet createRoot() {
Directory directory = new Directory(getContext(),uri);
directory.setIndexName("index.html");
return directory;
}
};
router.attach(content.getMatch(),app);
}
} catch (Exception ex) {
getLogger().log(Level.SEVERE,"Cannot add content at "+content.getMatch(),ex);
}
}
List<Link> metadataSet = hostConf.getLinks().get("metadata");
Link metadata = metadataSet==null ? null : metadataSet.size()>0 ? metadataSet.get(0) : null;
List<Link> autoconfList = hostConf.getLinks().get("autoconf");
this.resourceManager = new ResourceManager(getLogger(),hostConf.getLinks());
this.context.getAttributes().put(ResourceManager.ATTR, resourceManager);
// TODO: make the expiration configurable
client = context.getClientDispatcher();