/*
 * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 * WSO2 Inc. licenses this file to you under the Apache License,
 * Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.wso2.carbon.device.mgt.mobile.impl.ios.enrollment;

import org.wso2.carbon.device.mgt.ios.core.bean.ChallengeTokenBean;
import org.wso2.carbon.device.mgt.ios.core.exception.IOSEnrollmentException;

/**
 * This service exposes functionality to persistence/retrieval of IOS Device Enrollment Token
 */
public interface IOSEnrollmentTokenService {
    /**
     * Persists the challenge token bean
     *
     * @param challengeTokenBean {@link ChallengeTokenBean}
     * @throws IOSEnrollmentException if unable to save the challenge token
     */
    void saveDeviceEnrollmentToken(ChallengeTokenBean challengeTokenBean) throws IOSEnrollmentException;

    /**
     * Persists the challenge token bean
     *
     * @param challengeTokenBean {@link ChallengeTokenBean}
     * @throws IOSEnrollmentException if unable to update the challenge token
     */
    void updateDeviceEnrollmentToken(ChallengeTokenBean challengeTokenBean) throws IOSEnrollmentException;

    /**
     * Retrieve challenge token information.
     *
     * @param challengeToken challengeToken
     * @return {@link ChallengeTokenBean}
     * @throws IOSEnrollmentException if unable to retrieve the challenge token
     */
    ChallengeTokenBean getDeviceEnrollmentToken(String challengeToken) throws IOSEnrollmentException;

    /**
     * Retrieve challenge token information.
     *
     * @param deviceId device identifier
     * @return {@link ChallengeTokenBean}
     * @throws IOSEnrollmentException if unable to retrieve the challenge token for the given device id
     */
    ChallengeTokenBean getDeviceEnrollmentTokenByDeviceId(String deviceId) throws IOSEnrollmentException;

    /**
     * Removes challenge token entry.
     *
     * @param deviceId device identifier
     * @throws IOSEnrollmentException if unable to remove challenge token
     */
    void removeDeviceEnrollmentToken(String deviceId) throws IOSEnrollmentException;
}
