001/*******************************************************************************
002 * Copyright 2017 The MIT Internet Trust Consortium
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *   http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *******************************************************************************/
016
017package org.mitre.openid.connect.service;
018
019import java.io.IOException;
020
021import com.google.gson.stream.JsonReader;
022import com.google.gson.stream.JsonWriter;
023
024/**
025 * A modular extension to the data import/export layer. Any instances of this need to be
026 * declared as beans to be picked up by the data services.
027 *
028 * @author jricher
029 *
030 */
031public interface MITREidDataServiceExtension {
032
033        /**
034         * Export any data for this extension. This is called from the top level object.
035         * All extensions MUST return the writer to a state such that another member of
036         * the top level object can be written next.
037         *
038         * @param writer
039         */
040        void exportExtensionData(JsonWriter writer) throws IOException;
041
042        /**
043         * Import data that's part of this extension. This is called from the context of
044         * reading the top level object. All extensions MUST return the reader to a state
045         * such that another member of the top level object can be read next. The name of
046         * the data element being imported is passed in as name. If the extension does not
047         * support this data element, it must return without advancing the reader.
048         *
049         * Returns "true" if the item was processed, "false" otherwise.
050         *
051         * @param reader
052         */
053        boolean importExtensionData(String name, JsonReader reader) throws IOException;
054
055        /**
056         * Signal the extension to wrap up all object processing and finalize its
057         */
058        void fixExtensionObjectReferences(MITREidDataServiceMaps maps);
059
060        /**
061         * Return
062         * @param mitreidConnect13
063         * @return
064         */
065        boolean supportsVersion(String version);
066
067}