Porting changes from picketlink2/federation.