Apache Shiro – HTTP auth and Form auth in same project

I wanted a way to do regular form auth with an application. The idea is that regular users would use form authentication, and API users could use Simple HTTP authorization.

I had a REST service that I exposed at 2 different URLs by creating 2 Application classes extending javax.ws.rs.Application and using


to expose 2 different URLs. The first is at /rest and the second is at /api. Now, in the shiro.ini I setup a different filter for each path, and to access /rest you have to be logged in via form auth, and to access /api you must be logged in with HTTP Simple authentication.

I implemented a custom AuthorizationRealm and added the api role to the users that can access the API.

That works great, and simplifies any API connections by allowing Simple auth. Simple auth should also force SSH because it is not secure over clear HTTP, but that’s well documented by the Shiro project. There will be a post coming soon about how to implement a custom AuthorizingRealm to use your own DAOs to lookup users, but it is only 3 methods and is pretty straightforward.

PHP Validate Google CAPTCHA

Put this in check.php (or whatever) and call -> http://myserver/php/stuff/check.php?response=CAPTCHA_VALUE_FROM_PAGE, it will return JSON to the caller.

Here is a Javascript method (using JQuery) to do this validation:

Finally, here is the form that uses it:

Angular Directives – compile & link & trusted HTML

More information on Angular directives:

Here’s a simple directive with a couple of scope variables that get displayed:

Here is the angular stuff:

Here is a fiddle for the example, which has some css and things. Nothing really special here.

Now, in order to make some DOM changes, we can’t change the element during the link function. If you want to change the element, you have to do it during the compile function. The compile function gets called when the directive is created, and should return the link function. This allows the directive to be modified. This example shows how to add a list to the directive.

We can also add some HTML with the “sce” module:

The interesting thing there is the compile function. The compile function gets the tElem, which is the template element itself. This function is run when the directive is compiled, and there is no scope available. We can, however, add some elements to the directive. Note that the compile function returns the link function.

Here is a working fiddle

Here’s a final fiddle showing how to add a list to the element’s div

Configure Jackson for Glassfish 4.1

Needed to configure Jackson for Glassfish 4.1 and was getting errors due to another library (MOXY) being used.

Here is how to disable it. First, we implement the


interface like so:

Next, we configure our web service with a


object, like so:

There is also a


to register a bunch of services.

Also, here is the test code for the JacksonFeature class:

XCode Swift GET Request and Parse


Delete/Modify all Jenkins CI jobs

Navigate to


then, to delete all jobs, run:

To filter and disable jobs, run:

The Jenkins API docs are here

Plex Media Server – Allow Other Networks

Edit Preferences.xml (on ubuntu it’s in /var/lib/plexmediaserver/Library/Application Support/Plex Media Server)

Add the options that you want to change, see the link below for documentation on options: