001/*
002 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and others.
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 * Contributors:
017 *     Arnaud Kervern
018 */
019package org.nuxeo.ecm.platform.oauth2.request;
020
021import static org.nuxeo.ecm.platform.oauth2.Constants.AUTHORIZATION_CODE_PARAM;
022import static org.nuxeo.ecm.platform.oauth2.Constants.CLIENT_SECRET_PARAM;
023import static org.nuxeo.ecm.platform.oauth2.Constants.CODE_VERIFIER_PARAM;
024import static org.nuxeo.ecm.platform.oauth2.Constants.GRANT_TYPE_PARAM;
025import static org.nuxeo.ecm.platform.oauth2.Constants.REFRESH_TOKEN_PARAM;
026
027import javax.servlet.http.HttpServletRequest;
028
029/**
030 * @author <a href="mailto:ak@nuxeo.com">Arnaud Kervern</a>
031 * @since 5.9.2
032 */
033public class TokenRequest extends OAuth2Request {
034
035    protected String grantType;
036
037    protected String code;
038
039    protected String clientSecret;
040
041    protected String refreshToken;
042
043    protected String codeVerifier;
044
045    public TokenRequest(HttpServletRequest request) {
046        super(request);
047        grantType = request.getParameter(GRANT_TYPE_PARAM);
048        code = request.getParameter(AUTHORIZATION_CODE_PARAM);
049        clientSecret = request.getParameter(CLIENT_SECRET_PARAM);
050        refreshToken = request.getParameter(REFRESH_TOKEN_PARAM);
051        codeVerifier = request.getParameter(CODE_VERIFIER_PARAM);
052    }
053
054    public String getGrantType() {
055        return grantType;
056    }
057
058    public String getCode() {
059        return code;
060    }
061
062    public String getClientSecret() {
063        return clientSecret;
064    }
065
066    public String getRefreshToken() {
067        return refreshToken;
068    }
069
070    public String getCodeVerifier() {
071        return codeVerifier;
072    }
073}