/*
 * VerificationApplication.java
 *
 * Copyright (c) 2015, Sietse Ringers, Radboud University
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * 3. Neither the name of the IRMA project nor the names of its
 * contributors may be used to endorse or promote products derived from this
 * software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

package org.irmacard.api.web;

import java.net.URI;
import java.net.URISyntaxException;

import javax.ws.rs.ApplicationPath;

import org.glassfish.jersey.server.ResourceConfig;
import org.irmacard.credentials.idemix.info.IdemixKeyStore;
import org.irmacard.credentials.idemix.info.IdemixKeyStoreDeserializer;
import org.irmacard.credentials.info.*;

@ApplicationPath("/")
public class ApiApplication extends ResourceConfig {
    public ApiApplication() {
        // register Gson
        register(GsonJerseyProvider.class);

        // register exception handler, for converting and then returning exceptions as JSON output
        register(ApiExceptionMapper.class);

        // register verification application
        register(VerificationResource.class);

        // register issuing application, if applicable
        if (ApiConfiguration.getInstance().isIssuingEnabled()) {
            System.out.println("Enabling issuing");
            register(IssueResource.class);
        } else {
            System.out.println("Disabling issuing");
        }

        // register CORS filter
        register(CORSResponseFilter.class);

        try {
            if (!DescriptionStore.isInitialized() || !IdemixKeyStore.isInitialized()) {
                URI CORE_LOCATION = ApiApplication.class.getClassLoader().getResource("/irma_configuration/").toURI();
                DescriptionStore.initialize(new DescriptionStoreDeserializer(CORE_LOCATION));
                IdemixKeyStore.initialize(new IdemixKeyStoreDeserializer(CORE_LOCATION));
            }
        } catch (URISyntaxException|InfoException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }
}

@@ -1703,16 +1703,37 @@
 ception;
+%0Aimport java.net.URL;
 %0A%0Aimport
@@ -2895,23 +2895,13 @@
   UR
-I CORE_LOCATION
+L url
  = A
@@ -2972,16 +2972,268 @@
 ation/%22)
+;%0A                if (url == null)%0A                    throw new IllegalStateException(%22irma_configuration not found in src/main/resources. %22 +%0A                            %22See README.md for more information.%22);%0A%0A                URI CORE_LOCATION = url
 .toURI()

Throw understandable exception when irma_configuration is absent