public void initiateExternalAuth(Resource resource, Request request, Response response) {
   ExternalIdentityProvider eip = getSelectedIP(request);
   if (eip == null) {
     // means that the user needs to select an identity provider, so generate appropriate page
   } else {
     eip.initiateExternalAuth(resource, request, response);
   }
 }
 private ExternalIdentityProvider getSelectedIP(Request request) {
   List<ExternalIdentityProvider> list = authenticationService.getExternalIdentityProviders();
   if (list.size() == 1) {
     return list.get(0);
   } else {
     String ipName = request.getParams().get("_ip");
     if (ipName != null && ipName.length() > 0) {
       for (ExternalIdentityProvider eip : list) {
         if (ipName.equals(eip.getName())) {
           return eip;
         }
       }
     }
     return null;
   }
 }