001/*
002 * Copyright 2016 The AppAuth for Android Authors. All Rights Reserved.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
005 * in compliance with the License. You may obtain a copy of the License at
006 *
007 * http://www.apache.org/licenses/LICENSE-2.0
008 *
009 * Unless required by applicable law or agreed to in writing, software distributed under the
010 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
011 * express or implied. See the License for the specific language governing permissions and
012 * limitations under the License.
013 */
014
015package net.openid.appauth;
016
017import android.content.Intent;
018import androidx.annotation.NonNull;
019
020import org.json.JSONObject;
021
022/**
023 * A base response for session management models
024 * {@link AuthorizationResponse}
025 * {@link EndSessionResponse}
026 */
027public abstract class AuthorizationManagementResponse {
028
029    public abstract String getState();
030
031    public abstract Intent toIntent();
032
033    /**
034     * Produces a JSON representation of the request for persistent storage or local transmission
035     * (e.g. between activities).
036     */
037    public abstract JSONObject jsonSerialize();
038
039    /**
040     * Produces a JSON representation of the end session response for persistent storage or local
041     * transmission (e.g. between activities). This method is just a convenience wrapper
042     * for {@link #jsonSerialize()}, converting the JSON object to its string form.
043     */
044    @NonNull
045    public String jsonSerializeString() {
046        return jsonSerialize().toString();
047    }
048}