Creating a Custom Access Rights Plugin
Rosetta’s Access Rights Plugin interface enables libraries to extend Rosetta’s native access rights policy conditions and apply custom logic or integrate with external DRM systems.
This simple example demonstrates how a token, appended to the delivery URL, is checked against the ORCID (sandbox) system and allows access only if the token is valid (i.e. the ORCID id is registered). The example can be further customized for more specific needs and leverage the user IP or IE PID to extract relevant data from the requested IE.
package com.exlibris.dps.repository.plugin.ar; import java.net.HttpURLConnection; import java.net.URL; import com.exlibris.dps.repository.plugin.ARPlugin; public class OrcidARPlugin implements ARPlugin { public boolean validateToken(String ip, String iePid, String token) { if (token == null) { return false; } URL url; int statusCode=0; try { url = new URL("http://pub.sandbox.orcid.org/v1.2/"+token+"/orcid-bio"); HttpURLConnection http = (HttpURLConnection)url.openConnection(); statusCode = http.getResponseCode(); } catch (Exception e) { e.printStackTrace(); } if (statusCode==200){ return true; } else { return false; } } }
The code is available on Github.