001package org.apache.archiva.redback.rest.api.model;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 * http://www.apache.org/licenses/LICENSE-2.0
013 * Unless required by applicable law or agreed to in writing,
014 * software distributed under the License is distributed on an
015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
016 * KIND, either express or implied.  See the License for the
017 * specific language governing permissions and limitations
018 * under the License.
019 */
020
021import io.swagger.v3.oas.annotations.media.Schema;
022import org.apache.archiva.redback.rest.api.model.v2.GrantType;
023
024import javax.xml.bind.annotation.XmlElement;
025import javax.xml.bind.annotation.XmlRootElement;
026import java.io.Serializable;
027
028/**
029 * @author Martin Stockhammer <martin_s@apache.org>
030 */
031@XmlRootElement( name = "refreshToken" )
032@Schema( name = "TokenRequest", description = "Information for requesting tokens" )
033public class TokenRequest implements Serializable
034{
035    private static final long serialVersionUID = -7888325843736616091L;
036    GrantType grantType;
037    String refreshToken;
038    String scope;
039
040    public TokenRequest( )
041    {
042    }
043
044    public TokenRequest( GrantType grantType, String refreshToken, String scope )
045    {
046        this.grantType = grantType;
047        this.refreshToken = refreshToken;
048        this.scope = scope;
049    }
050
051    @XmlElement( name = "grant_type", required = true)
052    @Schema(description = "The grant type for requesting the token. 'refresh_token' for token refresh")
053    public GrantType getGrantType( )
054    {
055        return grantType;
056    }
057
058    public void setGrantType( GrantType grantType )
059    {
060        this.grantType = grantType;
061    }
062
063    @XmlElement( name = "refresh_token" )
064    @Schema(description = "The refresh token that is validated before generating the new access token")
065    public String getRefreshToken( )
066    {
067        return refreshToken;
068    }
069
070    public void setRefreshToken( String refreshToken )
071    {
072        this.refreshToken = refreshToken;
073    }
074
075    @XmlElement( name = "scope")
076    @Schema(description = "The scope for the new access token.")
077    public String getScope( )
078    {
079        return scope;
080    }
081
082    public void setScope( String scope )
083    {
084        this.scope = scope;
085    }
086}