Return-Path: X-Original-To: apmail-incubator-clerezza-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-clerezza-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 610934D2A for ; Thu, 19 May 2011 21:24:39 +0000 (UTC) Received: (qmail 85158 invoked by uid 500); 19 May 2011 21:24:39 -0000 Delivered-To: apmail-incubator-clerezza-commits-archive@incubator.apache.org Received: (qmail 85140 invoked by uid 500); 19 May 2011 21:24:39 -0000 Mailing-List: contact clerezza-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: clerezza-dev@incubator.apache.org Delivered-To: mailing list clerezza-commits@incubator.apache.org Received: (qmail 85133 invoked by uid 99); 19 May 2011 21:24:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 May 2011 21:24:39 +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; Thu, 19 May 2011 21:24:37 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id C91922388A36; Thu, 19 May 2011 21:24:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1125119 - /incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala Date: Thu, 19 May 2011 21:24:17 -0000 To: clerezza-commits@incubator.apache.org From: bblfish@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110519212417.C91922388A36@eris.apache.org> Author: bblfish Date: Thu May 19 21:24:17 2011 New Revision: 1125119 URL: http://svn.apache.org/viewvc?rev=1125119&view=rev Log: CLEREZZA-506: profile access denied -- placing some code inside AccessController.doPriviledged fixes the problem. Something to keep watching out for. Also added scala logging support. Modified: incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala Modified: incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala?rev=1125119&r1=1125118&r2=1125119&view=diff ============================================================================== --- incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala (original) +++ incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala Thu May 19 21:24:17 2011 @@ -37,8 +37,6 @@ import impl.{SimpleMGraph, TripleImpl} import org.apache.clerezza.rdf.utils.GraphNode import org.apache.clerezza.rdf.utils.UnionMGraph import org.osgi.service.component.ComponentContext -import org.slf4j.Logger -import org.slf4j.LoggerFactory import javax.ws.rs._ import javax.ws.rs.core.Context import javax.ws.rs.core.MediaType @@ -53,9 +51,9 @@ import org.apache.clerezza.platform.user import java.net.URI import org.apache.clerezza.rdf.scala.utils.{RichGraphNode, EasyGraphNode, EasyGraph} import org.apache.clerezza.rdf.ontologies._ +import org.slf4j.scala.Logging object ProfilePanel { - private val logger: Logger = LoggerFactory.getLogger(classOf[ProfilePanel]) val webIdTemplate = classOf[ProfilePanel].getAnnotation(classOf[Path]).value+"#me" @@ -77,9 +75,8 @@ object ProfilePanel { */ @Path("/user/{id}/profile") -class ProfilePanel { +class ProfilePanel extends Logging { - import ProfilePanel.logger import collection.JavaConversions._ import EasyGraph._ @@ -97,15 +94,13 @@ class ProfilePanel { private def getPersonalProfile(userName: String, info: UriInfo): EasyGraphNode = { val profileDocUri = getSuggestedPPDUri(userName) - val userInSysGraph = userManager.getUserInSystemGraph(userName) - - - val profile: EasyGraphNode = AccessController.doPrivileged(new PrivilegedAction[EasyGraphNode] { - def run: EasyGraphNode = { - userInSysGraph.getNode match { + val (user,profile) = AccessController.doPrivileged(new PrivilegedAction[Pair[Resource,EasyGraphNode]] { + def run: Pair[Resource,EasyGraphNode] = { + val userInSysGraph = userManager.getUserInSystemGraph(userName) + val profile = userInSysGraph.getNode match { case blank: BNode => { //user does not have a webId yet val g = new EasyGraph() - return ( + ( g.bnode ⟝ CONTROLPANEL.isLocalProfile ⟶ true ⟝ CONTROLPANEL.suggestedPPDUri ⟶ profileDocUri ⟝ FOAF.primaryTopic ⟶ (g.bnode ⟝ PLATFORM.userName ⟶ userName) @@ -123,10 +118,11 @@ class ProfilePanel { res } } + (userInSysGraph.getNode,profile) } }) - val friendInfo = for (kn: Triple <- profile.getGraph.filter(userInSysGraph.getNode.asInstanceOf[NonLiteral], FOAF.knows, null) + val friendInfo = for (kn: Triple <- profile.getGraph.filter(user.asInstanceOf[NonLiteral], FOAF.knows, null) if kn.getObject.isInstanceOf[UriRef]; friend = kn.getObject.asInstanceOf[UriRef] if (friend != profileDocUri) @@ -336,14 +332,18 @@ class ProfilePanel { @FormParam("webId") webId: UriRef, @FormParam("name") name: String, @FormParam("description") description: String): Response = { - val webIDInfo = webIdGraphsService.getWebIdInfo(webId) - val agent: GraphNode = new GraphNode(webId, webIDInfo.localPublicUserData) - agent.deleteProperties(FOAF.name) - agent.addPropertyValue(FOAF.name, name) - agent.deleteProperties(DC.description) - agent.addPropertyValue(DC.description, description) - logger.debug("local graph (uri: {}) is now of size {}", webIDInfo.webId, webIDInfo.localPublicUserData.size) - return RedirectUtil.createSeeOtherResponse("../profile", uriInfo) + AccessController.doPrivileged(new PrivilegedAction[Response] { + def run: Response = { + val webIDInfo = webIdGraphsService.getWebIdInfo(webId) + val agent: GraphNode = new GraphNode(webId, webIDInfo.localPublicUserData) + agent.deleteProperties(FOAF.name) + agent.addPropertyValue(FOAF.name, name) + agent.deleteProperties(DC.description) + agent.addPropertyValue(DC.description, description) + logger.debug("local graph (uri: {}) is now of size {}".format( webIDInfo.webId, webIDInfo.localPublicUserData.size)) + RedirectUtil.createSeeOtherResponse("../profile", uriInfo) + } + }) } protected def bindUserManager(usermanager: UserManager): Unit = {