All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.blade.oauth2.OAuthRequest Maven / Gradle / Ivy

There is a newer version: 1.0.2
Show newest version
/**
 * 
 */
package com.blade.oauth2;

import blade.kit.StringKit;

import com.blade.Aop;
import com.blade.oauth2.base.request.OAuthBaseRequest;
import com.blade.oauth2.base.validator.OAuthValidator;
import com.blade.oauth2.exception.OAuthProblemException;
import com.blade.oauth2.kit.OAuthKit;
import com.blade.oauth2.message.types.ResponseType;
import com.blade.oauth2.validator.AuthorizationValidator;
import com.blade.oauth2.validator.ImplicitCodeValidator;
import com.blade.web.http.Request;

/**
 * 
 * @author BruceZCQ [[email protected]]
 * @version
 */
public class OAuthRequest extends OAuthBaseRequest {
	
	public OAuthRequest(Request request)
			throws OAuthProblemException {
		super(request);
	}

	@Override
	protected OAuthValidator initValidator() throws OAuthProblemException {
		// end user authorization validators
		validators.put(ResponseType.CODE.toString(), AuthorizationValidator.class);
		validators.put(ResponseType.TOKEN.toString(), ImplicitCodeValidator.class);
		final String requestTypeValue = getParam(OAuth.OAUTH_RESPONSE_TYPE);
		if (StringKit.isBlank(requestTypeValue)) {
			throw OAuthKit.handleOAuthProblemException("Missing response_type parameter value");
		}
		final Class> clazz = validators
				.get(requestTypeValue);
		if (clazz == null) {
			throw OAuthKit.handleOAuthProblemException("Invalid response_type parameter value");
		}
		return Aop.create(clazz);
	}

	public String getResponseType() {
		return getParam(OAuth.OAUTH_RESPONSE_TYPE);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy