001    /*
002     * Cumulus4j - Securing your data in the cloud - http://cumulus4j.org
003     * Copyright (C) 2011 NightLabs Consulting GmbH
004     *
005     * This program is free software: you can redistribute it and/or modify
006     * it under the terms of the GNU Affero General Public License as
007     * published by the Free Software Foundation, either version 3 of the
008     * License, or (at your option) any later version.
009     *
010     * This program is distributed in the hope that it will be useful,
011     * but WITHOUT ANY WARRANTY; without even the implied warranty of
012     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013     * GNU Affero General Public License for more details.
014     *
015     * You should have received a copy of the GNU Affero General Public License
016     * along with this program.  If not, see <http://www.gnu.org/licenses/>.
017     */
018    package org.cumulus4j.store.crypto.keymanager.rest;
019    
020    import java.util.Collections;
021    import java.util.HashSet;
022    import java.util.Set;
023    
024    import javax.ws.rs.ApplicationPath;
025    import javax.ws.rs.core.Application;
026    
027    import org.cumulus4j.keymanager.back.shared.JAXBContextResolver;
028    
029    /**
030     * <p>
031     * REST application providing the API for the communication between key-manager and application-server.
032     * The URL to this application must be given to the key-manager (i.e. more precisely the <code>AppServer</code>).
033     * <p></p>
034     * This class is the entry point for Jersey where all REST services and their environment is declared.
035     * </p>
036     *
037     * @author Marco หงุ่ยตระกูล-Schulze - marco at nightlabs dot de
038     */
039    @ApplicationPath("/org.cumulus4j.keyserver.back.webapp")
040    public class KeyManagerBackWebApp
041    extends Application
042    {
043    //      private static final Logger logger = LoggerFactory.getLogger(KeyManagerBackWebApp.class);
044    
045            private static final Class<?>[] serviceClassesArray = {
046                    KeyManagerChannelService.class,
047                    JAXBContextResolver.class
048            };
049    
050            private static final Set<Class<?>> serviceClassesSet;
051            static {
052                    Set<Class<?>> s = new HashSet<Class<?>>(serviceClassesArray.length);
053                    for (Class<?> c : serviceClassesArray)
054                            s.add(c);
055    
056                    serviceClassesSet = Collections.unmodifiableSet(s);
057            }
058    
059            @Override
060            public Set<Class<?>> getClasses() {
061                    return serviceClassesSet;
062            }
063    
064            private Set<Object> singletons;
065    
066            @Override
067            public Set<Object> getSingletons()
068            {
069                    if (singletons == null) {
070                            Set<Object> s = new HashSet<Object>();
071    //                      s.add(new KeyStoreProvider(keyStore));
072    //                      s.add(new SessionManagerProvider(new SessionManager(keyStore)));
073                            singletons = Collections.unmodifiableSet(s);
074                    }
075    
076                    return singletons;
077            }
078    }