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.keymanager.cli;
019    
020    import java.io.BufferedReader;
021    
022    import org.cumulus4j.keymanager.cli.resource.ResourceHelper;
023    
024    /**
025     * <p>
026     * {@link SubCommand} implementation for showing the licence.
027     * </p>
028     * <p>
029     * Calling this will simply output the AGPL onto the console.
030     * </p>
031     *
032     * @author Marco หงุ่ยตระกูล-Schulze - marco at nightlabs dot de
033     */
034    public class LicenceSubCommand extends SubCommand {
035    
036            @Override
037            public String getSubCommandName() {
038                    return "licence";
039            }
040    
041            @Override
042            public String getSubCommandDescription() {
043                    return "Show the licence of Cumulus4j in general and this command line interface in particular.";
044            }
045    
046            @Override
047            public void run() throws Exception {
048                    System.out.println("Cumulus4j is free software released under the GNU AFFERO GENERAL PUBLIC LICENCE.");
049                    System.out.println();
050                    BufferedReader licenceReader = ResourceHelper.openLicenceAsBufferedReader();
051                    try {
052                            String line;
053                            while (null != (line = licenceReader.readLine())) {
054                                    System.out.println(line);
055                            }
056                    } finally {
057                            licenceReader.close();
058                    }
059            }
060    
061    }