/*
 * 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.verification.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.info.DescriptionStore;
import org.irmacard.credentials.info.InfoException;

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

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

        // register session state
        register(new VerificationSessionsBinder());

        // Setup Core location for IRMA
        URI CORE_LOCATION;
        // TODO this try catch system is not very elegant, make a function to
        // test if the stores are initialized
        try {
            DescriptionStore.getInstance();
            IdemixKeyStore.getInstance();
        } catch (InfoException e) {
            // Not initialized, try now
            try {
                CORE_LOCATION = VerificationApplication.class.getClassLoader().getResource("/irma_configuration/").toURI();
                DescriptionStore.setCoreLocation(CORE_LOCATION);
                DescriptionStore.getInstance();
                IdemixKeyStore.setCoreLocation(CORE_LOCATION);
                IdemixKeyStore.getInstance();
            } catch (URISyntaxException|InfoException e2) {
                e2.printStackTrace();
                throw new RuntimeException(e2);
            }
        }
    }
}

@@ -2348,16 +2348,34 @@
         
+try %7B%0A            
 // Setup
@@ -2401,353 +2401,8 @@
 IRMA
-%0A        URI CORE_LOCATION;%0A        // TODO this try catch system is not very elegant, make a function to%0A        // test if the stores are initialized%0A        try %7B%0A            DescriptionStore.getInstance();%0A            IdemixKeyStore.getInstance();%0A        %7D catch (InfoException e) %7B%0A            // Not initialized, try now%0A            try %7B
 %0A   
@@ -2410,19 +2410,19 @@
         
-   
+URI
  CORE_LO
@@ -2476,16 +2476,37 @@
 Loader()
+%0A                    
 .getReso
@@ -2539,28 +2539,24 @@
 %22).toURI();%0A
-    
             
@@ -2608,36 +2608,32 @@
 N);%0A            
-  
-  
 DescriptionStore
@@ -2640,36 +2640,32 @@
 .getInstance();%0A
-    
             Idem
@@ -2711,36 +2711,32 @@
 N);%0A            
- 
-   
 IdemixKeyStore.g
@@ -2757,20 +2757,16 @@
         
-   
- 
 %7D catch 
@@ -2800,17 +2800,16 @@
 eption e
-2
 ) %7B%0A    
@@ -2820,14 +2820,9 @@
     
-    e2
+e
 .pri
@@ -2849,20 +2849,16 @@
         
-    
 throw ne
@@ -2881,26 +2881,11 @@
 on(e
-2
 );%0A
-            %7D%0A
     

Remove superfluous try/catch block when populating stores