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

de.cidaas.oauth.interceptor.CBBearerHeaderTokenExtractor Maven / Gradle / Ivy

There is a newer version: 1.0.4
Show newest version
package de.cidaas.oauth.interceptor;

import javax.servlet.http.HttpServletRequest;

import org.apache.oltu.oauth2.common.OAuth;
import org.apache.oltu.oauth2.common.utils.OAuthUtils;
import org.apache.oltu.oauth2.rs.extractor.TokenExtractor;

/**
 * The Class CBBearerHeaderTokenExtractor.
 *
 * @author michael
 */
public class CBBearerHeaderTokenExtractor implements TokenExtractor {

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.apache.oltu.oauth2.rs.extractor.TokenExtractor#getAccessToken(javax.
	 * servlet.http.HttpServletRequest)
	 */
	@Override
	public String getAccessToken(HttpServletRequest request) {
		String authzHeader = request.getHeader(OAuth.HeaderType.AUTHORIZATION);
		if (authzHeader == null) {
			return request.getHeader(Constants.get_tokenKey());
		} else {
			return OAuthUtils.getAuthHeaderField(authzHeader);
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.apache.oltu.oauth2.rs.extractor.TokenExtractor#getAccessToken(javax.
	 * servlet.http.HttpServletRequest, java.lang.String)
	 */
	@Override
	public String getAccessToken(HttpServletRequest request, String tokenName) {
		String authzHeader = request.getHeader(OAuth.HeaderType.AUTHORIZATION);
		if (authzHeader == null) {
			return request.getHeader(Constants.get_tokenKey());
		} else {
			return OAuthUtils.getAuthHeaderField(authzHeader);
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy