Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2006-2011 the original author or authors.
  * 
  * Licensed 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.springframework.security.oauth2.provider.token;

Author(s):
Dave Syer
public abstract class AbstractTokenGranter implements TokenGranter {
	protected final Log logger = LogFactory.getLog(getClass());
	private final String grantType;
			ClientDetailsService clientDetailsServiceString grantType) {
		this. = clientDetailsService;
		this. = grantType;
		this. = tokenServices;
	}
	public OAuth2AccessToken grant(String grantTypeAuthorizationRequest authorizationRequest) {
		if (!this..equals(grantType)) {
			return null;
		}
		String clientId = authorizationRequest.getClientId();
		validateGrantType(grantTypeclient);
		.debug("Getting access token for: " + clientId);
		return getAccessToken(authorizationRequest);
	}
	protected OAuth2AccessToken getAccessToken(AuthorizationRequest authorizationRequest) {
		DefaultAuthorizationRequest outgoingRequest  = new DefaultAuthorizationRequest(authorizationRequest);
		outgoingRequest.setApproved(true);
		// FIXME: do we need to explicitly set approved flag here?
	}
		return new OAuth2Authentication(authorizationRequestnull);
	}
	protected void validateGrantType(String grantTypeClientDetails clientDetails) {
		Collection<StringauthorizedGrantTypes = clientDetails.getAuthorizedGrantTypes();
		if (authorizedGrantTypes != null && !authorizedGrantTypes.isEmpty()
				&& !authorizedGrantTypes.contains(grantType)) {
			throw new InvalidGrantException("Unauthorized grant type: " + grantType);
		}
	}
		return ;
	}
New to GrepCode? Check out our FAQ X