FetchAndUnzipProcess implements GeoServerProcess { boolean isAuthorized(String token){ boolean authorized = false; String expectedToken = getProperties().getProperty(TOKEN_PROPERTY_NAME); if(null == expectedToken){ throw new ProcessException( "Could not determine expected value for token. Please ensure that " + TOKEN_PROPERTY_NAME + " is defined on the server." ); } else if(expectedToken.equals(token)){ expectedToken = null; authorized = true; } return authorized; }  @DescribeResult(name = "filePath", description = "path to the unzipped file") String execute(
            @DescribeParameter(name = "zipUrl", min = 1, max = 1, description = "URL to the zipped file to retrieve") String zipUrl,
            @DescribeParameter(name = "token", min = 1, max = 1, description = "Token for authorizing the upload") String token
            ); String makeSafeFileName(); static final String FILE_NAME_PREFIX; }
@Test public void testIsAuthorizedWithBadAuth() { try{ instance.isAuthorized(TEST_TOKEN + "wrong"); } catch(ProcessException ex){ if(!(ex.getCause() instanceof SecurityException)){ fail("when presented with a bad token, a SecurityException wrapped in a Process Exception should be thrown"); } } }
@Test public void testIsAuthorizedWithGoodAuth() { assertTrue("the correct token should be authorized", instance.isAuthorized(TEST_TOKEN)); }