Obsidian4java is a project mainly written in Java, it's free.
A Java wrapper for the Obsidian Portal API. Obsidian Portal is a service that allows people to create campaign websites for Dungeons & Dragons and other tabletop RPGs.
Integration with Obsidian Portal via this API involves the following steps:
That's it! Now you're ready to start pretending you have a native Obsidian Portal sitting on your desktop.
This is a very crude, standalone servlet capable of accessing the User API.
public class UserServlet extends HttpServlet {
private static final String CUSTOMER_KEY = "<your API key>";
private static final String CUSTOMER_SECRET = "<your API secret>";
private final ObsidianClientFactory clientFactory;
public UserServlet() {
TokenRepository tokenRepository = new SimpleTokenRepository();
clientFactory = new ObsidianClientFactory( CUSTOMER_KEY, CUSTOMER_SECRET, tokenRepository );
}
@Override
public void doGet( HttpServletRequest request, HttpServletResponse ) throws IOException {
String userId = request.getParameter( "userId" );
String verifier = request.getParameter( "verifier" );
URL callbackUrl = new URL( request.getRequestURL().toString() );
ObsidianClient client = null;
if( verifier != null ) {
client = clientFactory.createInstance( userId, verifier );
} else {
try {
client = clientFactory.createInstance( userId, callbackUrl );
} catch( AuthorizationRequiredException exception ) {
response.sendRedirect( exception.getAuthorizationUrl() );
return;
}
}
UserService userService = WebServiceFactory.createUserService( client );
User user = userService.getCurrentUser();
response.getWriter().println( user.toString() );
response.getWriter().flush();
response.getWriter().close();
}
}
Both this library and the Obsidian Portal API itself are still very unstable, so use at your own risk!