JNI: Initial commit of Java library + example program

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
android: Bump gmp up to version 5.1.2

binutils 2.23.2, which is part of the arm-linux-androideabi-4.8
toolchain in NDK r9, fails to compile gmp without the following
workaround from v5.1.2:

    * mpn/arm/udiv.asm: Change spacing to work around binutils bug.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
android: Enable JNI in build

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
android: Add libstoken to build

This was tested with NDK release r8e on ARM (on a real device) and
x86 (compile only).

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
android: Add liboath to build

Compile-tested with NDK r9:

    make NDK=/opt/android-ndk-r9 GCCVER=4.8

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
android: Honor $TMPDIR when writing CSD script

Android doesn't have /tmp, so honor $TMPDIR if the caller sets it to
an alternate location.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
auth: Fix comment in parse_form()

This function never actually returns 1.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
android: Add "sources" target

Provide an easy way to download and extract the source tarballs in
anticipation of a multiplatform build.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
android: Fix broken ARCH=mips build

The MIPS NDK doesn't seem to handle dependencies correctly.  i.e.

libopenconnect.so references symbols in libz.so (from the toolchain's
sysroot), so it has a NEEDED entry for libz.so.  It was linked with -lz.

openconnect links in libopenconnect.so, but doesn't use zlib directly so
it isn't linked with -lz.

This causes a link failure on MIPS only:

    /opt/android-ndk-r9/toolchains/mipsel-linux-android-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/mipsel-linux-android/4.8/../../../../mipsel-linux-android/bin/ld: warning: libz.so, needed by ./.libs/libopenconnect.so, not found (try using -rpath or -rpath-link)
    ./.libs/libopenconnect.so: undefined reference to `deflateEnd'
    ./.libs/libopenconnect.so: undefined reference to `inflate'
    ./.libs/libopenconnect.so: undefined reference to `inflateInit2_'
    ./.libs/libopenconnect.so: undefined reference to `deflate'
    ./.libs/libopenconnect.so: undefined reference to `adler32'
    ./.libs/libopenconnect.so: undefined reference to `inflateEnd'
    ./.libs/libopenconnect.so: undefined reference to `deflateInit2_'
    collect2: error: ld returned 1 exit status
    make[2]: *** [openconnect] Error 1

ARM/x86 are fine.  So we'll use a temporary workaround on MIPS only,
until it's resolved.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
android: Add .gitignore file

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
android: Update Makefile to use NDK r9b

NDK gcc 4.7 is now deprecated, so let's recommend NDK r9b + gcc 4.8.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
library: Use named constants for process_auth_form() return value

Currently we have 3 valid results, and we're about to add a fourth.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
main: Move username/password/authgroup vars into main.c

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
auth: Add <group-access> node to XML POST initial request

This ensures that we get the form and <opaque> data corresponding to the
authgroup in use.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
auth: Add oc_choice->selected flag

In XML POST mode, the gateway keeps track of which authgroup is selected.
Provide this information to the UI so that the interface can be rendered
correctly.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
process_auth_form: Add code to support NEWGROUP return status from UI

In order to support refreshing the <opaque> data (XML POST) or the
secondary_* fields (non XML POST) on the auth form, it is necessary for
the process_auth_form() callback to return to libopenconnect to refresh
the form fields whenever the user changes the value of a <select>
dropdown.

This change should not break existing implementations.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
auth: Remove outdated comment for parse_auth_choice()

We do offer <select> choices to the user (and have for some time).

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
auth: Parse second-auth-related properties from the auth form

Add new fields to oc_form_opt and oc_choice.  These structs are allocated
by libopenconnect so it is safe to add more elements at the end.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
auth: Hide unused form fields based on the selected authgroup

Non-aggregate-auth servers have limited support for customizing the login
form based on which authgroup is currently selected.  Selectively convert
text/password fields to hidden fields, based on the following attributes:

  <input second-auth="1"> (for text/password fields)

  <option                 (for authgroup options)
          second-auth="1"
          secondary_username="foo"
          secondary_username_editable="true"
          noaaa="1" >

Note that implementing secondary_username_editable can cause
libopenconnect to prepopulate the opt->value field, which may be blindly
overwritten (without freeing) by legacy clients.  The other changes
should be backward-compatible, although they are not fully functional
on clients that do not implement OC_FORM_RESULT_NEWGROUP.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>