You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2010/07/01 16:11:53 UTC
svn commit: r959675 [1/2] - in
/incubator/clerezza/trunk/org.apache.clerezza.parent: ./
org.apache.clerezza.jaxrs.rdf.providers/src/main/java/org/apache/clerezza/jaxrs/rdf/providers/
org.apache.clerezza.permissiondescriptions/ org.apache.clerezza.platf...
Author: reto
Date: Thu Jul 1 14:11:51 2010
New Revision: 959675
URL: http://svn.apache.org/viewvc?rev=959675&view=rev
Log:
CLEREZZA-243: basic structure for personal-profile- garphs and profile editor
Added:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/MenuItemProvider.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/SettingsPanel.java
- copied, changed from r956251, incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/AccountControlPanel.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-panel.ssp
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-staticweb/
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-staticweb/scripts/
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-staticweb/scripts/profile.js
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-staticweb/style/
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-staticweb/style/profile.css
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/settings-panel.ssp
- copied, changed from r956215, incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/control-panel.ssp
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/static/
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/WebIdBasedPermissionProvider.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/
- copied from r956251, incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/src/main/scala/org/apache/clerezza/platform/
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/src/main/scala/org/apache/clerezza/platform/users/
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/src/main/scala/org/apache/clerezza/platform/users/UserGraphAcessPermissionProvider.scala
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/src/main/scala/org/apache/clerezza/platform/users/WebDescriptionProvider.scala
- copied, changed from r956251, incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/WebDescriptionProvider.scala
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/src/main/scala/org/apache/clerezza/platform/users/WebIdGraphsService.scala
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/ontologies/src/main/resources/org/apache/clerezza/platform/
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/ontologies/src/main/resources/org/apache/clerezza/platform/users/
- copied from r956251, incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/ontologies/src/main/resources/org/apache/clerezza/foafssl/
Removed:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/AccountControlPanel.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/control-panel.ssp
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/WebDescriptionProvider.scala
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/src/main/scala/org/apache/clerezza/foafssl/
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/ontologies/src/main/resources/org/apache/clerezza/foafssl/
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/ontologies/src/main/resources/org/apache/clerezza/platform/users/ontologies/atomowl.rdf
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/ontologies/src/main/resources/org/apache/clerezza/platform/users/ontologies/cert.rdf
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/ontologies/src/main/resources/org/apache/clerezza/platform/users/ontologies/rsa.rdf
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.jaxrs.rdf.providers/src/main/java/org/apache/clerezza/jaxrs/rdf/providers/ (props changed)
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.permissiondescriptions/ (props changed)
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/pom.xml
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.ontologies/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/ontologies/controlpanel.rdf
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.config/src/main/resources/org/apache/clerezza/platform/config/default-system-graph.rdf
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.launcher.storageless.parent/pom.xml
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/pom.xml
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/resources/OSGI-INF/serviceComponents.xml
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/auth/FoafSslAuthentication.scala
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/ssl/X509TrustManagerWrapperService.scala
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/UserAwarePolicy.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/pom.xml
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/src/main/resources/OSGI-INF/serviceComponents.xml
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/ontologies/pom.xml
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/pom.xml
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredMGraph.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredTripleCollection.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleLiteralFactory.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.uima/org.apache.clerezza.uima.ontologies/ (props changed)
incubator/clerezza/trunk/org.apache.clerezza.parent/pom.xml
Propchange: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.jaxrs.rdf.providers/src/main/java/org/apache/clerezza/jaxrs/rdf/providers/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Jul 1 14:11:51 2010
@@ -0,0 +1 @@
+.GraphNodeWriter.java.swp
Propchange: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.permissiondescriptions/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Jul 1 14:11:51 2010
@@ -0,0 +1 @@
+target
Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/pom.xml?rev=959675&r1=959674&r2=959675&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/pom.xml (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/pom.xml Thu Jul 1 14:11:51 2010
@@ -1,8 +1,9 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.clerezza</groupId>
- <artifactId>org.apache.clerezza.platform.accountcontrolpanel</artifactId>
+ <artifactId>org.apache.clerezza.platform.accountcontrolpanel</artifactId>
<version>0.9-incubating-SNAPSHOT</version>
</parent>
<groupId>org.apache.clerezza</groupId>
@@ -66,6 +67,10 @@
<artifactId>org.apache.clerezza.platform.typerendering.seedsnipe</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>org.apache.clerezza.platform.users.core</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
</dependency>
@@ -87,6 +92,14 @@
</dependency>
<dependency>
<groupId>org.apache.clerezza</groupId>
+ <artifactId>org.apache.clerezza.platform.usermanager</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>org.apache.clerezza.web.fileserver</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
<artifactId>org.apache.clerezza.permissiondescriptions</artifactId>
</dependency>
</dependencies>
Added: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/MenuItemProvider.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/MenuItemProvider.java?rev=959675&view=auto
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/MenuItemProvider.java (added)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/MenuItemProvider.java Thu Jul 1 14:11:51 2010
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.clerezza.platform.accountcontrolpanel;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.security.AccessControlContext;
+import java.security.AccessControlException;
+import java.security.AccessController;
+import java.security.Principal;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.security.auth.Subject;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.clerezza.platform.dashboard.GlobalMenuItem;
+
+
+import org.apache.clerezza.platform.dashboard.GlobalMenuItemsProvider;
+import org.apache.clerezza.platform.security.UserUtil;
+
+/**
+ *
+ * Provides menu-item to profile or settings-panel or none depending on user
+ * permissions.
+ *
+ * @author reto
+ */
+@Component
+@Service(value = GlobalMenuItemsProvider.class)
+public class MenuItemProvider implements GlobalMenuItemsProvider{
+
+
+ @Override
+ public Set<GlobalMenuItem> getMenuItems() {
+ Set<GlobalMenuItem> items = new HashSet<GlobalMenuItem>();
+
+ String userName = UserUtil.getCurrentUserName();
+ if (userName != null) {
+ try {
+ AccessController.checkPermission(new AccountControlPanelAppPermission(userName, ""));
+ } catch (AccessControlException e) {
+ return items;
+ }
+ try {
+ String path = "/user/" + URLEncoder.encode(userName, "utf-8") + "/control-panel";
+ items.add(new GlobalMenuItem(path, "ACP", "Account Control Panel", 5,
+ "Main-Modules"));
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ return items;
+ }
+}
Added: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.java?rev=959675&view=auto
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.java (added)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.java Thu Jul 1 14:11:51 2010
@@ -0,0 +1,215 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.clerezza.platform.accountcontrolpanel;
+
+
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import javax.ws.rs.core.UriInfo;
+import org.apache.clerezza.jaxrs.utils.RedirectUtil;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+
+
+import org.apache.clerezza.jaxrs.utils.TrailingSlash;
+import org.apache.clerezza.platform.accountcontrolpanel.ontologies.CONTROLPANEL;
+import org.apache.clerezza.platform.config.PlatformConfig;
+import org.apache.clerezza.platform.security.UserUtil;
+import org.apache.clerezza.platform.typerendering.RenderletManager;
+import org.apache.clerezza.platform.typerendering.scalaserverpages.ScalaServerPagesRenderlet;
+import org.apache.clerezza.platform.usermanager.UserManager;
+import org.apache.clerezza.platform.users.WebIdGraphsService;
+import org.apache.clerezza.rdf.core.BNode;
+import org.apache.clerezza.rdf.core.LiteralFactory;
+import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.clerezza.rdf.core.NonLiteral;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.access.TcManager;
+import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
+import org.apache.clerezza.rdf.core.impl.TripleImpl;
+import org.apache.clerezza.rdf.ontologies.DC;
+import org.apache.clerezza.rdf.ontologies.FOAF;
+import org.apache.clerezza.rdf.ontologies.PLATFORM;
+import org.apache.clerezza.rdf.ontologies.RDF;
+import org.apache.clerezza.rdf.ontologies.RDFS;
+import org.apache.clerezza.rdf.utils.GraphNode;
+import org.apache.clerezza.rdf.utils.UnionMGraph;
+import org.apache.clerezza.web.fileserver.FileServer;
+import org.osgi.service.component.ComponentContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * Presents a panel where the user can create a webid and edit her profile.
+ *
+ * @author reto
+ */
+@Component
+@Service(value = Object.class)
+@Property(name = "javax.ws.rs", boolValue = true)
+@Path("/user/{id}/profile")
+public class ProfilePanel extends FileServer {
+
+ private static final Logger logger = LoggerFactory.getLogger(ProfilePanel.class);
+
+ @Reference
+ private UserManager userManager;
+
+ @Reference
+ private TcManager tcManager;
+
+ @Reference
+ private RenderletManager renderletManager;
+
+ @Reference
+ private WebIdGraphsService webIdGraphsService;
+
+ @Reference
+ private PlatformConfig platformConfig;
+
+ protected void activate(ComponentContext componentContext) {
+ URL templateURL = getClass().getResource("profile-panel.ssp");
+ renderletManager.registerRenderlet(ScalaServerPagesRenderlet.class.getName(),
+ new UriRef(templateURL.toString()), CONTROLPANEL.ProfilePage,
+ "naked", MediaType.APPLICATION_XHTML_XML_TYPE, true);
+ configure(componentContext.getBundleContext(), "profile-staticweb");
+ }
+
+ @GET
+ public GraphNode getPersonalProfilePage(@Context UriInfo uriInfo, @PathParam(value = "id") String userName) {
+ TrailingSlash.enforceNotPresent(uriInfo);
+ GraphNode resultNode = getPersonalProfile(userName);
+ resultNode.addProperty(RDF.type, PLATFORM.HeadedPage);
+ resultNode.addProperty(RDF.type, CONTROLPANEL.ProfilePage);
+ return resultNode;
+ }
+
+ private GraphNode getPersonalProfile(final String userName) {
+ return AccessController.doPrivileged(new PrivilegedAction<GraphNode>() {
+ @Override
+ public GraphNode run() {
+ GraphNode userInSystemGraph = userManager.getUserInSystemGraph(userName);
+ NonLiteral userNodeInSystemGraph = (NonLiteral)userInSystemGraph.getNode();
+ if (userNodeInSystemGraph instanceof BNode) {
+ //no personal profile without web-id
+ SimpleMGraph simpleMGraph = new SimpleMGraph();
+ GraphNode profileNode = new GraphNode(new BNode(), simpleMGraph);
+ profileNode.addProperty(CONTROLPANEL.isLocalProfile,
+ LiteralFactory.getInstance().createTypedLiteral(true));
+ UriRef suggestedPPDUri = getSuggestedPPDUri(userName);
+ profileNode.addProperty(CONTROLPANEL.suggestedPPDUri,
+ LiteralFactory.getInstance().createTypedLiteral(suggestedPPDUri));
+ NonLiteral agent = new BNode();
+ profileNode.addProperty(FOAF.primaryTopic, agent);
+ simpleMGraph.add(new TripleImpl(agent, PLATFORM.userName,
+ LiteralFactory.getInstance().createTypedLiteral(userName)));
+ return profileNode;
+ } else {
+ return getProfileInUserGraph((UriRef)userNodeInSystemGraph);
+ }
+ }
+ });
+ }
+
+ private UriRef getSuggestedPPDUri(String userName) {
+ return new UriRef(platformConfig.getDefaultBaseUri().getUnicodeString()+
+ "user/"+userName+"/profile");
+ }
+
+ private GraphNode getProfileInUserGraph(UriRef webId) {
+ WebIdGraphsService.WebIdGraphs webIdGraphs = webIdGraphsService.getWebIdGraphs(webId);
+ MGraph userGraph = webIdGraphs.publicUserGraph();
+ logger.debug("got publicUserGraph of size {}.", userGraph.size());
+ GraphNode userGraphNode = new GraphNode(webId, userGraph);
+ GraphNode resultNode = new GraphNode(new BNode(),
+ new UnionMGraph(new SimpleMGraph(), userGraphNode.getGraph()));
+ resultNode.addProperty(CONTROLPANEL.isLocalProfile,
+ LiteralFactory.getInstance().createTypedLiteral(webIdGraphs.isLocal()));
+ resultNode.addProperty(FOAF.primaryTopic, userGraphNode.getNode());
+ return resultNode;
+ }
+
+ @POST
+ @Path("set-existing-webid")
+ public Response setExistingWebId(@Context final UriInfo uriInfo,
+ @FormParam("webid") final UriRef webId, @PathParam(value = "id") final String userName) {
+ //TODO check that its not local
+ //TODO check its not an existing user
+ return AccessController.doPrivileged(new PrivilegedAction<Response>() {
+ @Override
+ public Response run() {
+ GraphNode userInSystemGraph = userManager.getUserInSystemGraph(userName);
+ userInSystemGraph.replaceWith(webId);
+ return RedirectUtil.createSeeOtherResponse("../profile", uriInfo);
+ }
+ });
+ }
+
+ @POST
+ @Path("create-new-web-id")
+ public Response createNewWebId(@Context final UriInfo uriInfo,
+ @PathParam(value = "id") final String userName) {
+ //TODO check its not an existing user
+ final UriRef ppd = getSuggestedPPDUri(userName);
+ final UriRef webId = new UriRef(ppd.getUnicodeString()+"#me");
+ final WebIdGraphsService.WebIdGraphs webIdGraphs = webIdGraphsService.getWebIdGraphs(webId);
+ webIdGraphs.localGraph().add(new TripleImpl(ppd, FOAF.primaryTopic, webId));
+ webIdGraphs.localGraph().add(new TripleImpl(ppd, RDF.type, FOAF.PersonalProfileDocument));
+ return AccessController.doPrivileged(new PrivilegedAction<Response>() {
+ @Override
+ public Response run() {
+ GraphNode userInSystemGraph = userManager.getUserInSystemGraph(userName);
+ userInSystemGraph.replaceWith(webId);
+ return RedirectUtil.createSeeOtherResponse("../profile", uriInfo);
+ }
+ });
+ }
+
+ @POST
+ @Path("modify")
+ public Response modifyProfile(@Context final UriInfo uriInfo,
+ @PathParam(value = "id") final String userName,
+ @FormParam("webId") final UriRef webId,
+ @FormParam("name") final String name,
+ @FormParam("description") final String description) {
+ final WebIdGraphsService.WebIdGraphs webIdGraphs = webIdGraphsService.getWebIdGraphs(webId);
+ final GraphNode agent = new GraphNode(webId, webIdGraphs.localGraph());
+ agent.deleteProperties(FOAF.name);
+ agent.addPropertyValue(FOAF.name, name);
+ agent.deleteProperties(DC.description);
+ agent.addPropertyValue(DC.description, description);
+ logger.info("desc:"+description);
+ logger.info("local graph (uri: {}) is now of size {}", webIdGraphs.localGraphUri(), webIdGraphs.localGraph().size());
+ return RedirectUtil.createSeeOtherResponse("../profile", uriInfo);
+ }
+
+}
Copied: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/SettingsPanel.java (from r956251, incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/AccountControlPanel.java)
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/SettingsPanel.java?p2=incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/SettingsPanel.java&p1=incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/AccountControlPanel.java&r1=956251&r2=959675&rev=959675&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/AccountControlPanel.java (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/SettingsPanel.java Thu Jul 1 14:11:51 2010
@@ -23,16 +23,11 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URL;
-import java.net.URLEncoder;
-import java.security.AccessControlContext;
import java.security.AccessControlException;
import java.security.AccessController;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
-import java.security.Principal;
import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.HashSet;
@@ -41,7 +36,6 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import javax.security.auth.Subject;
import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
@@ -62,8 +56,6 @@ import org.apache.felix.scr.annotations.
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.ReferencePolicy;
import org.apache.felix.scr.annotations.Service;
-import org.apache.felix.scr.annotations.Services;
-import org.apache.clerezza.platform.dashboard.GlobalMenuItem;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.service.cm.Configuration;
@@ -79,7 +71,6 @@ import org.apache.clerezza.jaxrs.utils.f
import org.apache.clerezza.jaxrs.utils.form.MultiPartBody;
import org.apache.clerezza.platform.accountcontrolpanel.ontologies.CONTROLPANEL;
import org.apache.clerezza.platform.config.SystemConfig;
-import org.apache.clerezza.platform.dashboard.GlobalMenuItemsProvider;
import org.apache.clerezza.platform.typerendering.RenderletManager;
import org.apache.clerezza.platform.typerendering.scalaserverpages.ScalaServerPagesRenderlet;
import org.apache.clerezza.rdf.core.BNode;
@@ -110,22 +101,19 @@ import org.apache.clerezza.triaxrs.prefi
* @author mir, hasan
*/
@Component
-@Services({
- @Service(value = Object.class),
- @Service(value = GlobalMenuItemsProvider.class)
-})
+@Service(value = Object.class)
@Property(name = "javax.ws.rs", boolValue = true)
@Reference(name = "configurationAdmin", cardinality = ReferenceCardinality.OPTIONAL_UNARY,
policy = ReferencePolicy.DYNAMIC, referenceInterface = ConfigurationAdmin.class)
-@Path("/user/{id}")
-public class AccountControlPanel implements GlobalMenuItemsProvider{
+@Path("/user/{id}/control-panel")
+public class SettingsPanel {
private ComponentContext componentContext;
@Reference(target = SystemConfig.SYSTEM_GRAPH_FILTER)
private MGraph systemGraph; // System graph for user data access
@Reference
private RenderletManager renderletManager;
- private final Logger logger = LoggerFactory.getLogger(AccountControlPanel.class);
+ private final Logger logger = LoggerFactory.getLogger(SettingsPanel.class);
private ConfigurationAdmin configAdmin;
/**
@@ -136,8 +124,7 @@ public class AccountControlPanel impleme
*
*/
@GET
- @Path("control-panel")
- public GraphNode mainpage(@PathParam(value = "id") String idP,
+ public GraphNode settingsPage(@PathParam(value = "id") String idP,
@QueryParam("changedPassword") String changedPassword,
@Context UriInfo uriInfo) {
TrailingSlash.enforceNotPresent(uriInfo);
@@ -175,7 +162,7 @@ public class AccountControlPanel impleme
graphNode.addProperty(CONTROLPANEL.changedPassword,
new PlainLiteralImpl("false"));
}
- graphNode.addProperty(RDF.type, CONTROLPANEL.AccountControlPage);
+ graphNode.addProperty(RDF.type, CONTROLPANEL.SettingsPage);
graphNode.addProperty(RDF.type, PLATFORM.HeadedPage);
return graphNode;
}
@@ -294,7 +281,7 @@ public class AccountControlPanel impleme
*
*/
@POST
- @Path("control-panel/install-bundle")
+ @Path("install-bundle")
@Consumes
public Response installBundle(@PathParam(value = "id") final String id,
MultiPartBody multiForm,
@@ -413,7 +400,7 @@ public class AccountControlPanel impleme
*
*/
@POST
- @Path("control-panel/start-bundle")
+ @Path("start-bundle")
public Response startBundle(@PathParam(value = "id") String idP,
@FormParam("bundleId") String bundleIdStringP,
@Context UriInfo uriInfo) {
@@ -456,7 +443,7 @@ public class AccountControlPanel impleme
*
*/
@POST
- @Path("control-panel/stop-bundle")
+ @Path("stop-bundle")
public Response stopBundle(@PathParam(value = "id") String idP,
@FormParam("bundleId") String bundleIdStringP,
@Context UriInfo uriInfo) {
@@ -498,7 +485,7 @@ public class AccountControlPanel impleme
*
*/
@POST
- @Path("control-panel/uninstall-bundle")
+ @Path("uninstall-bundle")
public Response uninstallBundle(@PathParam(value = "id") String idP,
@FormParam("bundleId") String bundleIdStringP,
@Context UriInfo uriInfo) {
@@ -546,7 +533,7 @@ public class AccountControlPanel impleme
* @return
*/
@POST
- @Path("control-panel/change-password")
+ @Path("change-password")
public Response changePassword(@PathParam(value = "id") String idP,
@FormParam("oldPW") final String oldPW,
@FormParam("newPW") final String newPW,
@@ -651,15 +638,14 @@ public class AccountControlPanel impleme
/**
* The activate method is called when SCR activates the component configuration.
- * This method gets the system graph or create a new one if it doesn't exist.
*
* @param componentContext
*/
protected void activate(ComponentContext componentContext) {
this.componentContext = componentContext;
- URL templateURL = getClass().getResource("control-panel.ssp");
+ URL templateURL = getClass().getResource("settings-panel.ssp");
renderletManager.registerRenderlet(ScalaServerPagesRenderlet.class.getName(),
- new UriRef(templateURL.toString()), CONTROLPANEL.AccountControlPage,
+ new UriRef(templateURL.toString()), CONTROLPANEL.SettingsPage,
"naked", MediaType.APPLICATION_XHTML_XML_TYPE, true);
logger.info("Account Control Panel activated.");
@@ -675,52 +661,4 @@ public class AccountControlPanel impleme
this.configAdmin = null;
}
- @Override
- public Set<GlobalMenuItem> getMenuItems() {
- Set<GlobalMenuItem> items = new HashSet<GlobalMenuItem>();
-
- String user = getUserName();
- if (user != null) {
- try {
- AccessController.checkPermission(new AccountControlPanelAppPermission(user, ""));
- } catch (AccessControlException e) {
- return items;
- }
- try {
- String path = "/user/" + URLEncoder.encode(user, "utf-8") + "/control-panel/";
- items.add(new GlobalMenuItem(path, "ACP", "Account Control Panel", 5,
- "Main-Modules"));
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- }
- }
-
- return items;
- }
-
- private String getUserName() {
- Subject subject;
- final AccessControlContext context = AccessController.getContext();
- try {
- subject = AccessController.doPrivileged(new PrivilegedExceptionAction<Subject>() {
-
- @Override
- public Subject run() throws Exception {
- return Subject.getSubject(context);
- }
- });
- } catch (PrivilegedActionException ex) {
- Exception cause = (Exception)ex.getCause();
- if (cause instanceof RuntimeException) {
- throw (RuntimeException) cause;
- }
- throw new RuntimeException(cause);
- }
- Iterator<Principal> iter = subject.getPrincipals().iterator();
- String name = null;
- if (iter.hasNext()) {
- name = iter.next().getName();
- }
- return name;
- }
}
Added: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-panel.ssp
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-panel.ssp?rev=959675&view=auto
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-panel.ssp (added)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-panel.ssp Thu Jul 1 14:11:51 2010
@@ -0,0 +1,88 @@
+import scala.xml.NodeBuffer
+import scala.collection.mutable.ListBuffer
+def cp(s: Any) = new UriRef("http://clerezza.org/2009/03/controlpanel#"+s)
+def platform(s: Any) = new UriRef("http://clerezza.org/2009/08/platform#" + s)
+resultDocModifier.addStyleSheet("profile/style/profile.css");
+resultDocModifier.addScriptReference("profile/scripts/profile.js");
+resultDocModifier.setTitle("Account Control Panel");
+resultDocModifier.addNodes2Elem("tx-module", <h1>Account Control Panel</h1>);
+resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li class="tx-active"><a href="#">Profile</a></li>);
+resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li><a href="control-panel">Settings</a></li>);
+
+val agent = res/FOAF.primaryTopic
+
+def createWebId() = {
+ <h3>Associate Profile to Web-id</h3>
+ <div id="newOrExistingSelection">
+ <p>Your profile is not currently associated to a Web-ID. A Web-ID allows you
+ to link your friends as well as to log-in to many sites (supporting foaf+ssl
+ or open-id).</p>
+ <p>You may either create a new Web-Id or associate your account to an
+ existing Web-Id. Only creating a Web-Id here will allow you to manage your
+ profile here.</p>
+ <form action="#" id="associateSelection">
+ <button id="newWebIdButton">Create a new Web-Id</button>
+ <button id="existingWebIdButton">I already have a Web-ID and want to use it</button>
+ </form>
+ </div>
+ <div id="createNewWebId">
+ <p>You have chosen to create a new Web-Id.</p>
+ <p>The Web-ID will be created as follows:<br/>
+ <ol>
+ <li>Web-Id: {res/cp("suggestedPPDUri")*}#me</li>
+ <li>Perfonal-Profile Document: http://localhost/user/admin/profile</li>
+ </ol>
+ </p>
+ <form method="post" action="profile/create-new-web-id">
+ <input value="Create it!" type="submit"/>
+ </form>
+ </div>
+ <div id="setExistingWebId">
+ <p>Please enter your Web-Id, if your Web-Id supports Foaf+SSL you will
+ be able to use it to log in to this site.</p>
+ <form method="post" action="profile/set-existing-webid">
+ <label for="webid">Web-Id</label> <input type="text" name="webid" size="80" title="Web-ID"/><br/>
+ <input value="Associate Profile to Web-Id" type="submit"/><p />
+ </form>
+ </div>
+
+}
+
+def existingWebId() = {
+ if ((res/cp("isLocalProfile")).as[Boolean]) {
+ existingLocalWebId()
+ } else {
+ roamingUser()
+ }
+}
+
+
+def existingLocalWebId() = {
+ <h3>Manage your profile</h3>
+ <p>Here you can change your public profile.</p>
+ <form method="post" action="profile/modify">
+ <input type="hidden" name="webId" value={agent*}/>
+ <label for="name">name</label><input type="text" name="name" value={agent/FOAF.name*}/><br/>
+ <label for="description">description</label><textarea name="description"
+ >{agent/DC.description*}</textarea><br/>
+ <input value="Modify" type="submit"/><p />
+ </form>
+}
+
+def roamingUser() = {
+ <h3>Using remote profile</h3>
+ <p>{agent/FOAF.nick*}, you have accessed this site using you Web-Id {"<"+(agent*)+">"} which has not been
+ created on this site. To edit your profile you should visit the site issuing the
+ profile.</p>
+}
+
+<div id="tx-content">
+ <h2>Personal Profile</h2>
+
+ {
+ agent! match {
+ case _: BNode => createWebId()
+ case _: UriRef => existingWebId()
+ }
+ }
+</div>
\ No newline at end of file
Added: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-staticweb/scripts/profile.js
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-staticweb/scripts/profile.js?rev=959675&view=auto
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-staticweb/scripts/profile.js (added)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-staticweb/scripts/profile.js Thu Jul 1 14:11:51 2010
@@ -0,0 +1,11 @@
+$(document).ready(function() {
+ $('#newWebIdButton').click(function() {
+ $("#newOrExistingSelection").css({display: "none"})
+ $("#createNewWebId").css({display: "block"})
+ });
+ $("#existingWebIdButton").click(function() {
+ $("#newOrExistingSelection").css({display: "none"})
+ $("#setExistingWebId").css({display: "block"})
+ });
+ //$('form').submit(function () { return false; })
+});
Added: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-staticweb/style/profile.css
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-staticweb/style/profile.css?rev=959675&view=auto
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-staticweb/style/profile.css (added)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-staticweb/style/profile.css Thu Jul 1 14:11:51 2010
@@ -0,0 +1,9 @@
+#associateSelection {
+ width: 80%
+}
+#createNewWebId {
+ display: none
+}
+#setExistingWebId {
+ display: none
+}
\ No newline at end of file
Copied: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/settings-panel.ssp (from r956215, incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/control-panel.ssp)
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/settings-panel.ssp?p2=incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/settings-panel.ssp&p1=incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/control-panel.ssp&r1=956215&r2=959675&rev=959675&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/control-panel.ssp (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/settings-panel.ssp Thu Jul 1 14:11:51 2010
@@ -6,6 +6,8 @@ def platform(s: Any) = new UriRef("http:
val nodeBuff = new ListBuffer[NodeBuffer]
resultDocModifier.setTitle("Account Control Panel");
resultDocModifier.addNodes2Elem("tx-module", <h1>Account Control Panel</h1>);
+resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li><a href="profile">Profile</a></li>);
+resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li class="tx-active"><a href="#">Settings</a></li>);
if ((res/cp("userBundlePermission")*) == "true") {
nodeBuff +=(<h2>Bundle Control Panel</h2>
Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.ontologies/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/ontologies/controlpanel.rdf
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.ontologies/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/ontologies/controlpanel.rdf?rev=959675&r1=959674&r2=959675&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.ontologies/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/ontologies/controlpanel.rdf (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.ontologies/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/ontologies/controlpanel.rdf Thu Jul 1 14:11:51 2010
@@ -19,45 +19,73 @@
<!-- Classes -->
-<rdfs:Class rdf:about="#AccountControlPage">
+<rdfs:Class rdf:about="#SettingsPage">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
- <rdfs:label xml:lang="en">account control Page</rdfs:label>
+ <rdfs:label xml:lang="en">account settings Page</rdfs:label>
<skos:definition xml:lang="en">A web page containing a list of bundles of a user. Over the page
bundles can be managed.</skos:definition>
<rdfs:isDefinedBy rdf:resource="http://clerezza.org/2009/03/controlpanel#" />
</rdfs:Class>
+<rdfs:Class rdf:about="#ProfilePage">
+ <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
+ <rdfs:label xml:lang="en">personal profile management page</rdfs:label>
+ <skos:definition xml:lang="en">A web page allowing users to change to change
+ their profile.</skos:definition>
+ <rdfs:isDefinedBy rdf:resource="http://clerezza.org/2009/03/controlpanel#" />
+</rdfs:Class>
+
<!-- Properties -->
<rdf:Property rdf:about="#userBundlePermission">
- <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty" />
+ <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty" />
<rdfs:label xml:lang="en">User Bundle Permission</rdfs:label>
<skos:definition xml:lang="en">Points to a boolean indicating if the user has
the permission to install bundles over his/her account control page, which is the subject.</skos:definition>
<rdfs:isDefinedBy rdf:resource="http://clerezza.org/2009/03/controlpanel#" />
- <rdfs:domain rdf:resource="#AccountControlPage" />
+ <rdfs:domain rdf:resource="#SettingsPage" />
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#boolean"/>
</rdf:Property>
<rdf:Property rdf:about="#changePasswordPermission">
- <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty" />
+ <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty" />
<rdfs:label xml:lang="en">Change Password Permission</rdfs:label>
<skos:definition xml:lang="en">Points to a boolean indicating if the user has
the permission to change the password over his/her account control page, which is the subject.</skos:definition>
<rdfs:isDefinedBy rdf:resource="http://clerezza.org/2009/03/controlpanel#" />
- <rdfs:domain rdf:resource="#AccountControlPage" />
+ <rdfs:domain rdf:resource="#SettingsPage" />
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#boolean"/>
</rdf:Property>
<rdf:Property rdf:about="#changedPassword">
- <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty" />
+ <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty" />
<rdfs:label xml:lang="en">change password</rdfs:label>
- <skos:definition xml:lang="en">Points from an account control page over which an attempt was made to change the password of the user owning it
+ <skos:definition xml:lang="en">Points from a settings page over which an attempt was made to change the password of the user owning it
to a boolean indicating if an attempt succeeded.</skos:definition>
<rdfs:isDefinedBy rdf:resource="http://clerezza.org/2009/03/controlpanel#" />
- <rdfs:domain rdf:resource="#AccountControlPage" />
+ <rdfs:domain rdf:resource="#SettingsPage" />
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#boolean"/>
</rdf:Property>
+<rdf:Property rdf:about="#isLocalProfile">
+ <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty" />
+ <rdfs:label xml:lang="en">profile local</rdfs:label>
+ <skos:definition xml:lang="en">Points from a profile page to a boolean
+indicating if the server considers itself as authoritative for that profile.</skos:definition>
+ <rdfs:isDefinedBy rdf:resource="http://clerezza.org/2009/03/controlpanel#" />
+ <rdfs:domain rdf:resource="#SettingsPage" />
+ <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#boolean"/>
+</rdf:Property>
+
+<rdf:Property rdf:about="#suggestedPPDUri">
+ <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty" />
+ <rdfs:label xml:lang="en">Suggested PPD URI</rdfs:label>
+ <skos:definition xml:lang="en">Points to a uri suggested for a new local
+ personal profile document of the subject.</skos:definition>
+ <rdfs:isDefinedBy rdf:resource="http://clerezza.org/2009/03/controlpanel#" />
+ <rdfs:domain rdf:resource="#SettingsPage" />
+ <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#anyURI"/>
+</rdf:Property>
+
</rdf:RDF>
Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.config/src/main/resources/org/apache/clerezza/platform/config/default-system-graph.rdf
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.config/src/main/resources/org/apache/clerezza/platform/config/default-system-graph.rdf?rev=959675&r1=959674&r2=959675&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.config/src/main/resources/org/apache/clerezza/platform/config/default-system-graph.rdf (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.config/src/main/resources/org/apache/clerezza/platform/config/default-system-graph.rdf Thu Jul 1 14:11:51 2010
@@ -4,7 +4,8 @@
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:sioc="http://rdfs.org/sioc/ns#"
- xmlns:plat="http://clerezza.org/2009/08/platform#">
+ xmlns:plat="http://clerezza.org/2009/08/platform#"
+ xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<perm:Role>
<dc:title>CommunityUser</dc:title>
<perm:hasPermission rdf:parseType="Resource">
@@ -20,6 +21,7 @@
<sioc:has_function>
<perm:Role>
<dc:title>BasePermissionsRole</dc:title>
+ <rdfs:comment>Every user implicitely has this role as this is a perm:BaseRole</rdfs:comment>
<rdf:type rdf:resource="http://clerezza.org/2008/10/permission#BaseRole"/>
<perm:hasPermission rdf:parseType="Resource">
<perm:javaPermissionEntry>(java.util.PropertyPermission "*" "read")</perm:javaPermissionEntry>
@@ -41,6 +43,7 @@
</foaf:Agent>
<perm:Role>
<dc:title>DefaultRole</dc:title>
+ <rdfs:comment>A role regular users typically have</rdfs:comment>
<perm:hasPermission rdf:parseType="Resource">
<perm:javaPermissionEntry>(org.apache.clerezza.platform.accountcontrolpanel.AccountControlPanelAppPermission "{username}" "")</perm:javaPermissionEntry>
</perm:hasPermission>
Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.launcher.storageless.parent/pom.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.launcher.storageless.parent/pom.xml?rev=959675&r1=959674&r2=959675&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.launcher.storageless.parent/pom.xml (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.launcher.storageless.parent/pom.xml Thu Jul 1 14:11:51 2010
@@ -440,6 +440,11 @@
</dependency>
<dependency>
<groupId>org.apache.clerezza</groupId>
+ <artifactId>org.apache.clerezza.platform.users.core</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
<artifactId>org.apache.clerezza.utils</artifactId>
<scope>runtime</scope>
</dependency>
Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/pom.xml?rev=959675&r1=959674&r2=959675&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/pom.xml (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/pom.xml Thu Jul 1 14:11:51 2010
@@ -35,12 +35,15 @@
<groupId>org.apache.clerezza</groupId>
<artifactId>org.apache.clerezza.rdf.scala.utils</artifactId>
</dependency>
-
<dependency>
<groupId>org.apache.clerezza</groupId>
<artifactId>org.apache.clerezza.platform.security</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>org.apache.clerezza.platform.users.core</artifactId>
+ </dependency>
+ <dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</dependency>
Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/resources/OSGI-INF/serviceComponents.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/resources/OSGI-INF/serviceComponents.xml?rev=959675&r1=959674&r2=959675&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/resources/OSGI-INF/serviceComponents.xml (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/resources/OSGI-INF/serviceComponents.xml Thu Jul 1 14:11:51 2010
@@ -11,7 +11,7 @@
<service servicefactory="false">
<provide interface="org.apache.clerezza.platform.security.auth.WeightedAuthenticationMethod"/>
</service>
- <reference name="tcManager" interface="org.apache.clerezza.foafssl.WebDescriptionProvider"
+ <reference name="webDescriptionProvider" interface="org.apache.clerezza.platform.users.WebDescriptionProvider"
cardinality="1..1" policy="static" bind="bindWebDescriptionProvider" unbind="unbindWebDescriptionProvider"/>
<!-- <reference name="conceptProviderManager"
interface="org.apache.clerezza.platform.concepts.core.ConceptProviderManager"
@@ -25,18 +25,10 @@
<service servicefactory="false">
<provide interface="org.apache.clerezza.foafssl.ssl.X509TrustManagerWrapperService"/>
</service>
- <reference name="tcManager" interface="org.apache.clerezza.foafssl.WebDescriptionProvider"
+ <reference name="tcManager" interface="org.apache.clerezza.platform.users.WebDescriptionProvider"
cardinality="1..1" policy="static" bind="bindWebDescriptionProvider" unbind="unbindWebDescriptionProvider"/>
<reference name="systemGraph" interface="org.apache.clerezza.rdf.core.access.LockableMGraph"
cardinality="1..1" policy="static" target="(name=http://tpf.localhost/system.graph)"
bind="bindSystemGraph" unbind="unbindSystemGraph"/>
</scr:component>
- <scr:component enabled="true" name="org.apache.clerezza.foafssl.WebDescriptionProvider">
- <implementation class="org.apache.clerezza.foafssl.WebDescriptionProvider"/>
- <service servicefactory="false">
- <provide interface="org.apache.clerezza.foafssl.WebDescriptionProvider"/>
- </service>
- <reference name="tcManager" interface="org.apache.clerezza.rdf.core.access.TcManager"
- cardinality="1..1" policy="static" bind="bindTcManager" unbind="unbindTcManager"/>
- </scr:component>
</components>
Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/auth/FoafSslAuthentication.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/auth/FoafSslAuthentication.scala?rev=959675&r1=959674&r2=959675&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/auth/FoafSslAuthentication.scala (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/auth/FoafSslAuthentication.scala Thu Jul 1 14:11:51 2010
@@ -20,7 +20,7 @@
package org.apache.clerezza.foafssl.auth
import org.apache.clerezza.foafssl.Utilities
-import org.apache.clerezza.foafssl.WebDescriptionProvider
+import org.apache.clerezza.platform.users.WebDescriptionProvider
import org.apache.clerezza.platform.security.auth._
import org.apache.clerezza.rdf.core._
import org.wymiwyg.wrhapi.Request
Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/ssl/X509TrustManagerWrapperService.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/ssl/X509TrustManagerWrapperService.scala?rev=959675&r1=959674&r2=959675&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/ssl/X509TrustManagerWrapperService.scala (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/ssl/X509TrustManagerWrapperService.scala Thu Jul 1 14:11:51 2010
@@ -25,7 +25,7 @@ import java.security.cert.X509Certificat
import java.security.interfaces.RSAPublicKey
import javax.net.ssl.X509TrustManager;
import org.apache.clerezza.foafssl.Utilities
-import org.apache.clerezza.foafssl.WebDescriptionProvider
+import org.apache.clerezza.platform.users.WebDescriptionProvider
import org.apache.clerezza.foafssl.ontologies.CERT
import org.apache.clerezza.foafssl.ontologies.RSA
import org.apache.clerezza.rdf.core.Literal
@@ -35,6 +35,7 @@ import org.apache.clerezza.rdf.core.Reso
import org.apache.clerezza.rdf.core.TripleCollection
import org.apache.clerezza.rdf.core.TypedLiteral
import org.apache.clerezza.rdf.core.UriRef
+import org.apache.clerezza.rdf.core.access.LockableMGraph
import org.apache.clerezza.rdf.core.access.TcManager
import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl
import org.apache.clerezza.rdf.core.impl.SimpleMGraph
@@ -62,11 +63,11 @@ class X509TrustManagerWrapperService() e
private var systemGraph: MGraph = null
- protected def bindSystemGraph(g: MGraph) {
+ protected def bindSystemGraph(g: LockableMGraph) {
systemGraph = g
}
- protected def unbindSystemGraph(g: MGraph) {
+ protected def unbindSystemGraph(g: LockableMGraph) {
systemGraph = null
}
Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/UserAwarePolicy.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/UserAwarePolicy.java?rev=959675&r1=959674&r2=959675&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/UserAwarePolicy.java (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/UserAwarePolicy.java Thu Jul 1 14:11:51 2010
@@ -31,9 +31,11 @@ import java.security.ProtectionDomain;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.clerezza.platform.config.SystemConfig;
import org.osgi.service.permissionadmin.PermissionInfo;
@@ -53,6 +55,8 @@ import org.apache.clerezza.rdf.ontologie
import org.apache.clerezza.rdf.ontologies.SIOC;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.ReferencePolicy;
import org.apache.felix.scr.annotations.Service;
/**
@@ -61,6 +65,10 @@ import org.apache.felix.scr.annotations.
*/
@Component
@Service(UserAwarePolicy.class)
+@Reference(name = "webIdPermissionProvider",
+cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
+policy = ReferencePolicy.DYNAMIC,
+referenceInterface = WebIdBasedPermissionProvider.class)
public class UserAwarePolicy extends Policy {
final Logger logger = LoggerFactory.getLogger(UserAwarePolicy.class);
@@ -80,6 +88,8 @@ public class UserAwarePolicy extends Pol
private UserPermissionsCache cache = new UserPermissionsCache();
private Policy originalPolicy;
+ private Set<WebIdBasedPermissionProvider> permissionProviders =
+ new HashSet<WebIdBasedPermissionProvider>();
public UserAwarePolicy() {
this.originalPolicy = Policy.getPolicy();
@@ -193,19 +203,19 @@ public class UserAwarePolicy extends Pol
throws UserUnregisteredException {
NonLiteral user = getUserByName(userName);
- List<String> result = getPermissionEntriesOfARole(user, userName);
-
+
+ List<String> result = getPermissionEntriesOfAUser(user, userName);
Iterator<Triple> roleTriples = systemGraph.filter(user,
SIOC.has_function, null);
while (roleTriples.hasNext()) {
NonLiteral anotherRole = (NonLiteral) roleTriples.next()
.getObject();
- result.addAll(getPermissionEntriesOfARole(anotherRole, userName));
+ result.addAll(getPermissionEntriesOfARole(anotherRole, userName, user));
}
Iterator<NonLiteral> baseRoles = getResourcesOfType(PERMISSION.BaseRole);
while(baseRoles.hasNext()) {
- result.addAll(getPermissionEntriesOfARole(baseRoles.next(), userName));
+ result.addAll(getPermissionEntriesOfARole(baseRoles.next(), userName, user));
}
return result;
}
@@ -221,7 +231,17 @@ public class UserAwarePolicy extends Pol
throw new UserUnregisteredException(userName);
}
- private List<String> getPermissionEntriesOfARole(NonLiteral role, String userName) {
+ private List<String> getPermissionEntriesOfAUser(NonLiteral user, String userName) {
+ List<String> result = getPermissionEntriesOfARole(user, userName, user);
+ if (user instanceof UriRef) {
+ for (WebIdBasedPermissionProvider p : permissionProviders) {
+ result.addAll(p.getPermissions((UriRef)user));
+ }
+ }
+ return result;
+ }
+ //note that users are roles too
+ private List<String> getPermissionEntriesOfARole(NonLiteral role, String userName, NonLiteral user) {
List<String> result = new ArrayList<String>();
Iterator<Triple> permsForRole = systemGraph.filter(role,
PERMISSION.hasPermission, null);
@@ -264,5 +284,15 @@ public class UserAwarePolicy extends Pol
}
};
}
+
+ protected void bindWebIdPermissionProvider(WebIdBasedPermissionProvider p) {
+ permissionProviders.add(p);
+ refresh();
+ }
+
+ protected void unbindWebIdPermissionProvider(WebIdBasedPermissionProvider p) {
+ permissionProviders.remove(p);
+ refresh();
+ }
}
Added: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/WebIdBasedPermissionProvider.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/WebIdBasedPermissionProvider.java?rev=959675&view=auto
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/WebIdBasedPermissionProvider.java (added)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/WebIdBasedPermissionProvider.java Thu Jul 1 14:11:51 2010
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2010 reto.
+ *
+ * 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.
+ * under the License.
+ */
+
+package org.apache.clerezza.platform.security;
+
+import java.util.Collection;
+import org.apache.clerezza.rdf.core.UriRef;
+
+/**
+ * Services implementing this interface provide additional permissions
+ * to users with a Web-Id.
+ *
+ * Typically this is used to assign permissions to roaming users.
+ *
+ * @author reto
+ */
+public interface WebIdBasedPermissionProvider {
+ /**
+ * This methods returns string descriptions of the permissions to be granted
+ * to the user with a specified Web-Id. The permissions are described
+ * using the conventional format '("ClassName" "name" "actions")'.
+ *
+ * @param webId the uri identifying the user (aka Web-Id)
+ * @return the string descriptions of the permissions
+ */
+ Collection<String> getPermissions(UriRef webId);
+}
Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/pom.xml?rev=959675&r1=956251&r2=959675&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/pom.xml (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/pom.xml Thu Jul 1 14:11:51 2010
@@ -2,16 +2,16 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.clerezza</groupId>
- <artifactId>org.apache.clerezza.platform.security.foafssl</artifactId>
+ <artifactId>org.apache.clerezza.platform.users</artifactId>
<version>0.1-incubating-SNAPSHOT</version>
</parent>
<groupId>org.apache.clerezza</groupId>
- <artifactId>org.apache.clerezza.platform.security.foafssl.core</artifactId>
+ <artifactId>org.apache.clerezza.platform.users.core</artifactId>
<version>0.1-incubating-SNAPSHOT</version>
<packaging>bundle</packaging>
- <name>Clerezza - Platform Security foaf+ssl Core</name>
+ <name>Clerezza - Platform Users Core</name>
<description>
- Foaf + Ssl Core
+ User Graphs Core
</description>
<dependencies>
@@ -97,9 +97,9 @@
<configuration>
<instructions>
<Service-Component>OSGI-INF/serviceComponents.xml</Service-Component>
- <Export-Package>!org.apache.clerezza.foafssl.ontologies,
- org.apache.clerezza.foafssl.*</Export-Package>
- <Bundle-SymbolicName>org.apache.clerezza.foafssl</Bundle-SymbolicName>
+ <Export-Package>!org.apache.clerezza.platform.users.ontologies,
+ org.apache.clerezza.platform.users</Export-Package>
+ <Bundle-SymbolicName>org.apache.clerezza.platform.users.core</Bundle-SymbolicName>
</instructions>
</configuration>
</plugin>
Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/src/main/resources/OSGI-INF/serviceComponents.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/src/main/resources/OSGI-INF/serviceComponents.xml?rev=959675&r1=956251&r2=959675&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/src/main/resources/OSGI-INF/serviceComponents.xml (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/src/main/resources/OSGI-INF/serviceComponents.xml Thu Jul 1 14:11:51 2010
@@ -1,42 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
- <scr:component enabled="true" name="org.apache.clerezza.foafssl.ssl.Activator" immediate="true">
- <implementation class="org.apache.clerezza.foafssl.ssl.Activator"/>
- <reference name="x509TrustManagerWrapperService"
- interface="org.apache.clerezza.foafssl.ssl.X509TrustManagerWrapperService"
- cardinality="1..1" policy="static" bind="bindX509TrustManagerWrapperService" unbind="unbindX509TrustManagerWrapperService"/>
- </scr:component>
- <scr:component enabled="true" name="org.apache.clerezza.foafssl.auth.FoafSslAuthentication" immediate="true">
- <implementation class="org.apache.clerezza.foafssl.auth.FoafSslAuthentication"/>
+
+ <scr:component enabled="true" name="org.apache.clerezza.platform.users.UserGraphAcessPermissionProviderr">
+ <implementation class="org.apache.clerezza.platform.users.UserGraphAcessPermissionProvider"/>
<service servicefactory="false">
- <provide interface="org.apache.clerezza.platform.security.auth.WeightedAuthenticationMethod"/>
+ <provide interface="org.apache.clerezza.platform.security.WebIdBasedPermissionProvider"/>
</service>
- <reference name="tcManager" interface="org.apache.clerezza.foafssl.WebDescriptionProvider"
- cardinality="1..1" policy="static" bind="bindWebDescriptionProvider" unbind="unbindWebDescriptionProvider"/>
- <!-- <reference name="conceptProviderManager"
- interface="org.apache.clerezza.platform.concepts.core.ConceptProviderManager"
- cardinality="1..1" policy="static" bind="bindConceptProviderManager" unbind="unbindConceptProviderManager"/>
- <reference name="renderletManager"
- interface="org.apache.clerezza.platform.typerendering.RenderletManager"
- cardinality="1..1" policy="static" bind="bindRenderletManager" unbind="unbindRenderletManager"/> -->
</scr:component>
- <scr:component enabled="true" name="org.apache.clerezza.foafssl.ssl.X509TrustManagerWrapperService">
- <implementation class="org.apache.clerezza.foafssl.ssl.X509TrustManagerWrapperService"/>
+ <scr:component enabled="true" name="org.apache.clerezza.platform.users.WebDescriptionProvider">
+ <implementation class="org.apache.clerezza.platform.users.WebDescriptionProvider"/>
<service servicefactory="false">
- <provide interface="org.apache.clerezza.foafssl.ssl.X509TrustManagerWrapperService"/>
+ <provide interface="org.apache.clerezza.platform.users.WebDescriptionProvider"/>
</service>
- <reference name="tcManager" interface="org.apache.clerezza.foafssl.WebDescriptionProvider"
- cardinality="1..1" policy="static" bind="bindWebDescriptionProvider" unbind="unbindWebDescriptionProvider"/>
- <reference name="systemGraph" interface="org.apache.clerezza.rdf.core.access.LockableMGraph"
- cardinality="1..1" policy="static" target="(name=http://tpf.localhost/system.graph)"
- bind="bindSystemGraph" unbind="unbindSystemGraph"/>
+ <reference name="tcManager" interface="org.apache.clerezza.rdf.core.access.TcManager"
+ cardinality="1..1" policy="static" bind="bindTcManager" unbind="unbindTcManager"/>
+ <reference name="webIdGraphsService" interface="org.apache.clerezza.platform.users.WebIdGraphsService"
+ cardinality="1..1" policy="static" bind="bindWebIdGraphsService" unbind="unbindWebIdGraphsService"/>
</scr:component>
- <scr:component enabled="true" name="org.apache.clerezza.foafssl.WebDescriptionProvider">
- <implementation class="org.apache.clerezza.foafssl.WebDescriptionProvider"/>
+ <scr:component enabled="true" name="org.apache.clerezza.platform.users.WebIdGraphsService">
+ <implementation class="org.apache.clerezza.platform.users.WebIdGraphsService"/>
<service servicefactory="false">
- <provide interface="org.apache.clerezza.foafssl.WebDescriptionProvider"/>
+ <provide interface="org.apache.clerezza.platform.users.WebIdGraphsService"/>
</service>
<reference name="tcManager" interface="org.apache.clerezza.rdf.core.access.TcManager"
cardinality="1..1" policy="static" bind="bindTcManager" unbind="unbindTcManager"/>
+ <reference name="parser" interface="org.apache.clerezza.rdf.core.serializedform.Parser"
+ cardinality="1..1" policy="static" bind="bindParser" unbind="unbindParser"/>
+ <reference name="platformConfig" interface="org.apache.clerezza.platform.config.PlatformConfig"
+ cardinality="1..1" policy="static" bind="bindPlatformConfig" unbind="unbindPlatformConfig"/>
+ <!-- <reference name="tcManager" interface="org.apache.clerezza.platform.users.WebDescriptionProvider"
+ cardinality="1..1" policy="static" bind="bindWebDescriptionProvider" unbind="unbindWebDescriptionProvider"/> -->
</scr:component>
</components>
Added: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/src/main/scala/org/apache/clerezza/platform/users/UserGraphAcessPermissionProvider.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/src/main/scala/org/apache/clerezza/platform/users/UserGraphAcessPermissionProvider.scala?rev=959675&view=auto
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/src/main/scala/org/apache/clerezza/platform/users/UserGraphAcessPermissionProvider.scala (added)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/src/main/scala/org/apache/clerezza/platform/users/UserGraphAcessPermissionProvider.scala Thu Jul 1 14:11:51 2010
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2010 reto.
+ *
+ * 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.
+ * under the License.
+ */
+
+package org.apache.clerezza.platform.users
+
+import org.apache.clerezza.platform.security.WebIdBasedPermissionProvider
+import org.apache.clerezza.rdf.core.UriRef
+
+class UserGraphAcessPermissionProvider extends WebIdBasedPermissionProvider {
+
+ override def getPermissions(webId: UriRef) : java.util.Collection[String] = {
+ import scala.collection.JavaConversions._
+ val uriString = webId.getUnicodeString
+ def uriStringWithoutFragment = {
+ val hashPos = uriString.indexOf('#')
+ if (hashPos != -1) {
+ uriString.substring(0, hashPos)
+ } else {
+ uriString
+ }
+ }
+ List("(org.apache.clerezza.rdf.core.access.security.TcPermission \""+uriStringWithoutFragment+"\" \"readwrite\")")
+ }
+}
Copied: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/src/main/scala/org/apache/clerezza/platform/users/WebDescriptionProvider.scala (from r956251, incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/WebDescriptionProvider.scala)
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/src/main/scala/org/apache/clerezza/platform/users/WebDescriptionProvider.scala?p2=incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/src/main/scala/org/apache/clerezza/platform/users/WebDescriptionProvider.scala&p1=incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/WebDescriptionProvider.scala&r1=956251&r2=959675&rev=959675&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/WebDescriptionProvider.scala (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/src/main/scala/org/apache/clerezza/platform/users/WebDescriptionProvider.scala Thu Jul 1 14:11:51 2010
@@ -17,16 +17,17 @@
* under the License.
*/
-package org.apache.clerezza.foafssl
+package org.apache.clerezza.platform.users
import java.net.HttpURLConnection
import java.net.URL
+import org.apache.clerezza.platform.config.PlatformConfig
+import org.apache.clerezza.platform.config.SystemConfig
import org.apache.clerezza.rdf.core.TripleCollection
import org.apache.clerezza.rdf.core.UriRef
import org.apache.clerezza.rdf.core.access.NoSuchEntityException
import org.apache.clerezza.rdf.core.access.TcManager
import org.apache.clerezza.rdf.core.serializedform.Parser
-import org.apache.clerezza.rdf.core.serializedform.SupportedFormat
import org.apache.clerezza.rdf.utils.GraphNode
import org.apache.clerezza.rdf.utils.UnionMGraph
import org.osgi.service.component.ComponentContext
@@ -38,6 +39,15 @@ import org.osgi.service.component.Compon
*/
class WebDescriptionProvider {
+ private var webIdGraphsService: WebIdGraphsService = null
+ protected def bindWebIdGraphsService(s: WebIdGraphsService) = {
+ this.webIdGraphsService = s
+ }
+ protected def unbindWebIdGraphsService(s: WebIdGraphsService) = {
+ this.webIdGraphsService = null
+ }
+
+
private var tcManager: TcManager = null;
protected def bindTcManager(tcManager: TcManager) = {
@@ -48,12 +58,9 @@ class WebDescriptionProvider {
this.tcManager = null
}
- private lazy val parser = Parser.getInstance
-
- private val systemGraphUri = new UriRef("http://tpf.localhost/system.graph")
-
private val authoritativeLocalGraphs = Array(
- systemGraphUri,
+ SystemConfig.SYSTEM_GRAPH_URI,
+ PlatformConfig.CONFIG_GRAPH_URI,
new UriRef("http://tpf.localhost/config.graph"))
private var authoritativeLocalGraphUnion: TripleCollection = null
@@ -69,100 +76,22 @@ class WebDescriptionProvider {
authoritativeLocalGraphUnion = null
}
- lazy val acceptHeader = {
- import scala.collection.JavaConversions._
- (for (f <- parser.getSupportedFormats) yield {
- val qualityOfFormat = {
- f match {
- //the default format
- case SupportedFormat.RDF_XML => "1.0";
- //n3 is a bit less well defined and/or many parsers supports only subsets
- case SupportedFormat.N3 => "0.5";
- case _ => "0.8";
- }
- }
- f+"; q="+qualityOfFormat+","
- }).mkString +" *; q=.1"
- }
+
/**
* @return a GraphNode describing uri
*/
def getWebDescription(uri: UriRef, update: Boolean): GraphNode = {
- lazy val representationGraphUriString = {
- val uriString = uri.getUnicodeString
- val hashPos = uriString.indexOf('#')
- if (hashPos != -1) {
- uriString.substring(0, hashPos)
- } else {
- finalRedirectLocation
- }
- }
- lazy val representationGraphUri = {
- new UriRef(representationGraphUriString)
- }
- lazy val finalRedirectLocation = {
- finalRedirectLocationFor(uri.getUnicodeString)
- }
- def finalRedirectLocationFor(us: String): String = {
- val url = new URL(us)
- val connection = url.openConnection()
- connection match {
- case hc : HttpURLConnection => {
- hc.setRequestMethod("HEAD");
- hc.setInstanceFollowRedirects(false)
- hc.addRequestProperty("Accept:", acceptHeader)
- hc.getResponseCode match {
- case HttpURLConnection.HTTP_SEE_OTHER => {
- val location = hc.getHeaderField("Location")
- if (location == null) {
- throw new RuntimeException("No Location Headers in 303 response")
- }
- finalRedirectLocationFor(location)
- }
- case _ => us
- }
- }
- case _ => us
- }
- }
-
- lazy val localCacheUri = {
- new UriRef(representationGraphUriString+".cache")
- }
-
- def updateLocalCache() = {
- val url = new URL(representationGraphUriString)
- val connection = url.openConnection()
-
-
- connection match {
- case hc: HttpURLConnection => hc.addRequestProperty("Accept:", acceptHeader);
- }
-
- val mediaType = connection.getContentType()
- val in = url.openStream
- val remoteTriples = parser.parse(in, mediaType, representationGraphUri)
- val localCache = try {
- val g = tcManager.getMGraph(localCacheUri)
- g.clear()
- g
- } catch {
- case e: NoSuchEntityException => tcManager.createMGraph(localCacheUri)
- }
- localCache.addAll(remoteTriples)
- }
+ val webIdGraphs = webIdGraphsService.getWebIdGraphs(uri)
if (update) {
- updateLocalCache()
+ webIdGraphs.updateLocalCache()
}
-
val cacheGraphOption: Option[TripleCollection] = try {
- Some(tcManager.getTriples(localCacheUri))
+ Some(tcManager.getTriples(webIdGraphs.localCacheUri))
} catch {
case e: NoSuchEntityException => None
}
-
val tripleCollection = cacheGraphOption match {
case Some(g) => new UnionMGraph(authoritativeLocalGraphUnion, g)
case None => authoritativeLocalGraphUnion