Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 32118D498 for ; Tue, 4 Dec 2012 16:45:59 +0000 (UTC) Received: (qmail 7255 invoked by uid 500); 4 Dec 2012 16:45:58 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 7141 invoked by uid 500); 4 Dec 2012 16:45:58 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 7115 invoked by uid 99); 4 Dec 2012 16:45:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Dec 2012 16:45:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Dec 2012 16:45:56 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 0ECB223889BF; Tue, 4 Dec 2012 16:45:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1417025 - /cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/ImplicitGrantService.java Date: Tue, 04 Dec 2012 16:45:35 -0000 To: commits@cxf.apache.org From: sergeyb@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121204164536.0ECB223889BF@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sergeyb Date: Tue Dec 4 16:45:34 2012 New Revision: 1417025 URL: http://svn.apache.org/viewvc?rev=1417025&view=rev Log: Updating implicit grant service to report the scope if it is available Modified: cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/ImplicitGrantService.java Modified: cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/ImplicitGrantService.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/ImplicitGrantService.java?rev=1417025&r1=1417024&r2=1417025&view=diff ============================================================================== --- cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/ImplicitGrantService.java (original) +++ cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/ImplicitGrantService.java Tue Dec 4 16:45:34 2012 @@ -28,9 +28,11 @@ import javax.ws.rs.core.Response; import org.apache.cxf.rs.security.oauth2.common.AccessTokenRegistration; import org.apache.cxf.rs.security.oauth2.common.Client; +import org.apache.cxf.rs.security.oauth2.common.OAuthPermission; import org.apache.cxf.rs.security.oauth2.common.ServerAccessToken; import org.apache.cxf.rs.security.oauth2.common.UserSubject; import org.apache.cxf.rs.security.oauth2.utils.OAuthConstants; +import org.apache.cxf.rs.security.oauth2.utils.OAuthUtils; /** @@ -82,8 +84,16 @@ public class ImplicitGrantService extend if (isWriteOptionalParameters()) { sb.append("&").append(OAuthConstants.ACCESS_TOKEN_EXPIRES_IN) .append("=").append(token.getExpiresIn()); - //TODO: also report the approved scope and other parameters if any + // Reporting scope is required if the approved scope is different and + // optional - otherwise; lets always report it for now if it is non-empty + List perms = token.getScopes(); + if (!perms.isEmpty()) { + sb.append("&").append(OAuthConstants.SCOPE) + .append("=").append(OAuthUtils.convertPermissionsToScope(perms)); + } + //TODO: also report other token parameters if any if needed } + return Response.seeOther(URI.create(sb.toString())).build(); }