public ServiceProviderToken generateAccessToken(ServiceProviderToken token) { checkNotNull(token, "token"); // make sure token is authorized if (token.isRequestToken() && token.getAuthorization() != Authorization.AUTHORIZED) { throw new IllegalArgumentException("token is not an authorized request token"); } String t = randomizer.randomAlphanumericString(32); return ServiceProviderToken.newAccessToken(t) .tokenSecret(token.getTokenSecret()) .consumer(token.getConsumer()) .authorizedBy(token.getUser()) .properties(propertiesFactory.newAccessTokenProperties(token)) .session(newSession(token)) .build(); }
throw new OAuthProblemException(TOKEN_REJECTED); if (token.isRequestToken()) { checkRequestToken(requestMessage, token); } else {
private static void setTokenData(OAuthAccessor accessor, ServiceProviderToken token) { Tokens.setCommonTokenData(accessor, token); if (token.isRequestToken()) { if (token.getAuthorization() == Authorization.AUTHORIZED) { accessor.setProperty(Tokens.AccessorProperty.USER, token.getUser()); accessor.setProperty(Tokens.AccessorProperty.AUTHORIZED, true); } else if (token.getAuthorization() == Authorization.DENIED) { accessor.setProperty(Tokens.AccessorProperty.USER, token.getUser()); accessor.setProperty(Tokens.AccessorProperty.AUTHORIZED, false); } } else { accessor.accessToken = token.getToken(); accessor.setProperty(Tokens.AccessorProperty.USER, token.getUser()); accessor.setProperty(Tokens.AccessorProperty.AUTHORIZED, true); } accessor.tokenSecret = token.getTokenSecret(); accessor.setProperty(Tokens.AccessorProperty.CREATION_TIME, token.getCreationTime()); } }
throw new OAuthProblemException(OAuth.Problems.TOKEN_REJECTED); if (token.isRequestToken()) { checkRequestToken(requestMessage, token); } else {