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/06/19 18:19:42 UTC
svn commit: r956251 - in
/incubator/clerezza/trunk/org.apache.clerezza.parent: ./
org.apache.clerezza.foafssl/
org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/plat...
Author: reto
Date: Sat Jun 19 16:19:41 2010
New Revision: 956251
URL: http://svn.apache.org/viewvc?rev=956251&view=rev
Log:
CLEREZZA-93: added foaf+ssl to launcher
Added:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/
- copied from r956215, incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.foafssl/
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/Utilities.scala
- copied, changed from r956215, incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/CertUtilities.scala
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/SecurityActivator.java
Removed:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.foafssl/
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/CertUtilities.scala
Modified:
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.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/scala/org/apache/clerezza/foafssl/WebDescriptionProvider.scala
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.foafssl/ontologies/pom.xml
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/pom.xml
incubator/clerezza/trunk/org.apache.clerezza.parent/pom.xml
Modified: 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/AccountControlPanel.java?rev=956251&r1=956250&r2=956251&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/AccountControlPanel.java Sat Jun 19 16:19:41 2010
@@ -559,47 +559,53 @@ public class AccountControlPanel impleme
if (newPW.trim().equals(confirmNewPW.trim()) && checkPWStrings(oldPW, newPW)) {
changedPassword = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
- @Override
- public Boolean run() {
- final NonLiteral agent = getAgent(id);
- // The encoded current password which the user typed in
- String encodedOlpPW = getEncodedPW(oldPW);
- // The current password which is in the system graph
+ private String getCurrentPassword(NonLiteral agent) {
String currentPassword = null;
Iterator<Triple> oldPWTriple = systemGraph.filter(agent,
PERMISSION.passwordSha1, null);
if (oldPWTriple.hasNext()) {
- /*
- * The Clerezza WCMS Ontologies expect the Object to be a
- * Literal
- */
Literal currentPWLiteral = (Literal) oldPWTriple.next().getObject();
currentPassword = currentPWLiteral.getLexicalForm();
}
- if (currentPassword.equals(encodedOlpPW)) {
- removeOldPwAndAddNewPW(agent, currentPassword, newPW);
- return true;
- } else {
+ return currentPassword;
+ }
+
+ @Override
+ public Boolean run() {
+ final NonLiteral agent = getAgent(id);
+ // The encoded current password which the user typed in
+ String encodedOlpPW = getEncodedPW(oldPW);
+ // The current password which is in the system graph
+ String currentPassword = getCurrentPassword(agent);
+ if ((currentPassword != null) && !currentPassword.equals(encodedOlpPW)) {
logger.info("Typed wrong current password!");
return false;
+ } else {
+ removeOldPwAndAddNewPW(agent, currentPassword, newPW);
+ return true;
}
}
private void removeOldPwAndAddNewPW(NonLiteral agent, String currentPassword,
String newPW) {
- Triple oldPWTriple = new TripleImpl(agent,
- PERMISSION.passwordSha1, new PlainLiteralImpl(
- currentPassword));
Triple newPWTriple = new TripleImpl(agent,
PERMISSION.passwordSha1,
new PlainLiteralImpl(getEncodedPW(newPW)));
- systemGraph.remove(oldPWTriple);
- logger.debug("removed old password from systemgraph");
+ if (currentPassword != null) {
+ Triple oldPWTriple = new TripleImpl(agent,
+ PERMISSION.passwordSha1, new PlainLiteralImpl(
+ currentPassword));
+ systemGraph.remove(oldPWTriple);
+ logger.debug("removed old password from systemgraph");
+ }
systemGraph.add(newPWTriple);
logger.debug("user " + id + " changed password");
}
private String getEncodedPW(String password) {
+ if (password == null) {
+ return null;
+ }
try {
return bytes2HexString(MessageDigest.getInstance("SHA1").digest(
password.getBytes("UTF-8")));
@@ -637,7 +643,7 @@ public class AccountControlPanel impleme
* checks if the typed strings are valid
*/
private boolean checkPWStrings(String oldPW, String newPW) {
- if (oldPW.length() == 0 || newPW.length() == 0) {
+ if (newPW.length() == 0) {
return false;
}
return true;
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=956251&r1=956250&r2=956251&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 Sat Jun 19 16:19:41 2010
@@ -109,6 +109,11 @@
<artifactId>httpcore-osgi</artifactId>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>org.jsslutils</groupId>
+ <artifactId>jsslutils</artifactId>
+ <scope>runtime</scope>
+ </dependency>
<!--
Clerezza Bundles
@@ -265,6 +270,16 @@
</dependency>
<dependency>
<groupId>org.apache.clerezza</groupId>
+ <artifactId>org.apache.clerezza.platform.security.foafssl.core</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>org.apache.clerezza.platform.security.foafssl.ontologies</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
<artifactId>org.apache.clerezza.platform.security.auth.basic</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=956251&r1=956215&r2=956251&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 Sat Jun 19 16:19:41 2010
@@ -2,14 +2,14 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.clerezza</groupId>
- <artifactId>org.apache.clerezza.foafssl</artifactId>
- <version>0.1-SNAPSHOT</version>
+ <artifactId>org.apache.clerezza.platform.security.foafssl</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
</parent>
<groupId>org.apache.clerezza</groupId>
- <artifactId>org.apache.clerezza.foafssl.core</artifactId>
- <version>0.1-SNAPSHOT</version>
+ <artifactId>org.apache.clerezza.platform.security.foafssl.core</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
<packaging>bundle</packaging>
- <name>Clerezza - foaf+ssl Core</name>
+ <name>Clerezza - Platform Security foaf+ssl Core</name>
<description>
Foaf + Ssl Core
</description>
@@ -17,8 +17,7 @@
<dependencies>
<dependency>
<groupId>org.apache.clerezza</groupId>
- <artifactId>org.apache.clerezza.foafssl.ontologies</artifactId>
- <version>0.1-SNAPSHOT</version>
+ <artifactId>org.apache.clerezza.platform.security.foafssl.ontologies</artifactId>
</dependency>
<dependency>
<groupId>org.apache.clerezza</groupId>
@@ -52,12 +51,10 @@
<dependency>
<groupId>org.jsslutils</groupId>
<artifactId>jsslutils</artifactId>
- <version>1.0.5</version>
</dependency>
<dependency>
<groupId>org.wymiwyg</groupId>
<artifactId>jetty-osgi-httpservice</artifactId>
- <version>0.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
@@ -100,7 +97,8 @@
<configuration>
<instructions>
<Service-Component>OSGI-INF/serviceComponents.xml</Service-Component>
- <Export-Package>org.apache.clerezza.foafssl.*</Export-Package>
+ <Export-Package>!org.apache.clerezza.foafssl.ontologies,
+ org.apache.clerezza.foafssl.*</Export-Package>
<Bundle-SymbolicName>org.apache.clerezza.foafssl</Bundle-SymbolicName>
</instructions>
</configuration>
Copied: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/Utilities.scala (from r956215, incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/CertUtilities.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/Utilities.scala?p2=incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/Utilities.scala&p1=incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/CertUtilities.scala&r1=956215&r2=956251&rev=956251&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/CertUtilities.scala (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/Utilities.scala Sat Jun 19 16:19:41 2010
@@ -27,7 +27,7 @@ import org.apache.clerezza.rdf.core.UriR
*
* @author Reto Bachmann-Gmür, Henry Story
*/
-object CertUtilities {
+object Utilities {
/**
* same as getClaimedWebIds(chain(0))
@@ -72,5 +72,9 @@ object CertUtilities {
}
return result
}
+
+ def cretateUsernameForWebId(webId: UriRef) = {
+ webId.getUnicodeString.replace(":", "");
+ }
}
\ No newline at end of file
Modified: 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.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/WebDescriptionProvider.scala?rev=956251&r1=956215&r2=956251&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.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/WebDescriptionProvider.scala Sat Jun 19 16:19:41 2010
@@ -26,6 +26,7 @@ import org.apache.clerezza.rdf.core.UriR
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
@@ -71,7 +72,16 @@ class WebDescriptionProvider {
lazy val acceptHeader = {
import scala.collection.JavaConversions._
(for (f <- parser.getSupportedFormats) yield {
- f+"; q=1.0,"
+ 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"
}
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=956251&r1=956215&r2=956251&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 Sat Jun 19 16:19:41 2010
@@ -19,7 +19,7 @@
package org.apache.clerezza.foafssl.auth
-import org.apache.clerezza.foafssl.CertUtilities
+import org.apache.clerezza.foafssl.Utilities
import org.apache.clerezza.foafssl.WebDescriptionProvider
import org.apache.clerezza.platform.security.auth._
import org.apache.clerezza.rdf.core._
@@ -49,8 +49,8 @@ class FoafSslAuthentication extends Weig
if ((certificates == null) || (certificates.length == 0)) {
return null
} else {
- val webIdUriRefs = CertUtilities.getClaimedWebIds(certificates)
- webIdUriRefs(0).getUnicodeString
+ val webIdUriRefs = Utilities.getClaimedWebIds(certificates)
+ Utilities.cretateUsernameForWebId(webIdUriRefs(0))
}
}
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=956251&r1=956215&r2=956251&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 Sat Jun 19 16:19:41 2010
@@ -24,7 +24,7 @@ import java.security.cert.CertificateExc
import java.security.cert.X509Certificate
import java.security.interfaces.RSAPublicKey
import javax.net.ssl.X509TrustManager;
-import org.apache.clerezza.foafssl.CertUtilities
+import org.apache.clerezza.foafssl.Utilities
import org.apache.clerezza.foafssl.WebDescriptionProvider
import org.apache.clerezza.foafssl.ontologies.CERT
import org.apache.clerezza.foafssl.ontologies.RSA
@@ -74,7 +74,7 @@ class X509TrustManagerWrapperService() e
new TrustAllClientsWrappingTrustManager(
trustManager) {
override def checkClientTrusted(chain: Array[X509Certificate], authType: String): Unit = {
- val webIdUriRefs = CertUtilities.getClaimedWebIds(chain)
+ val webIdUriRefs = Utilities.getClaimedWebIds(chain)
if (webIdUriRefs.length == 0) {
trustManager.checkClientTrusted(chain, authType)
} else {
@@ -104,12 +104,10 @@ class X509TrustManagerWrapperService() e
}
def createSystemUserDescription(webDescription: GraphNode) = {
- val result = new SimpleMGraph(webDescription.getNodeContext)
- //TODO remove at leaf platform usernames
+ val result = new SimpleMGraph()
val webId = webDescription.getNode.asInstanceOf[UriRef]
result.add(new TripleImpl(webId, PLATFORM.userName,
- new PlainLiteralImpl(webId.getUnicodeString)))
- //LiteralFactory.getInstance.createTypedLiteral(webId.getUnicodeString)))
+ new PlainLiteralImpl(Utilities.cretateUsernameForWebId(webId))))
result.add(new TripleImpl(webId, RDF.`type` ,
FOAF.Agent))
result
Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/ontologies/pom.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/ontologies/pom.xml?rev=956251&r1=956215&r2=956251&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/ontologies/pom.xml (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/ontologies/pom.xml Sat Jun 19 16:19:41 2010
@@ -2,14 +2,14 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.clerezza</groupId>
- <artifactId>org.apache.clerezza.foafssl</artifactId>
- <version>0.1-SNAPSHOT</version>
+ <artifactId>org.apache.clerezza.platform.security.foafssl</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
</parent>
<groupId>org.apache.clerezza</groupId>
- <artifactId>org.apache.clerezza.foafssl.ontologies</artifactId>
- <version>0.1-SNAPSHOT</version>
+ <artifactId>org.apache.clerezza.platform.security.foafssl.ontologies</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
<packaging>bundle</packaging>
- <name>Clerezza - foafssl Ontologies</name>
+ <name>CClerezza - Platform Security foaf+ssl Ontologies</name>
<description>
Fafo + Ssl Ontologies
</description>
Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/pom.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/pom.xml?rev=956251&r1=956215&r2=956251&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/pom.xml (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.foafssl/pom.xml Sat Jun 19 16:19:41 2010
@@ -6,10 +6,10 @@
<version>0.2-incubating-SNAPSHOT</version>
</parent>
<groupId>org.apache.clerezza</groupId>
- <artifactId>org.apache.clerezza.foafssl</artifactId>
+ <artifactId>org.apache.clerezza.platform.security.foafssl</artifactId>
<packaging>pom</packaging>
- <version>0.1-SNAPSHOT</version>
- <name>Clerezza - foaf+ssl</name>
+ <version>0.1-incubating-SNAPSHOT</version>
+ <name>Clerezza - Platform Security foaf+ssl</name>
<modules>
<module>ontologies</module>
<module>core</module>
Added: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/SecurityActivator.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/SecurityActivator.java?rev=956251&view=auto
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/SecurityActivator.java (added)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/SecurityActivator.java Sat Jun 19 16:19:41 2010
@@ -0,0 +1,76 @@
+/*
+ * 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.security.PermissionCollection;
+import java.security.Permissions;
+import java.security.Policy;
+import java.security.Principal;
+import java.security.ProtectionDomain;
+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.osgi.service.component.ComponentContext;
+
+/**
+ * A component with no required dependency ensuring that the UserAwarePolicy is
+ * activated if available or otherwise a restrictive default policy is set
+ *
+ * @author reto
+ */
+@Component
+@Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY,
+name = "userAwarePolicy",
+policy = ReferencePolicy.DYNAMIC,
+referenceInterface = UserAwarePolicy.class)
+public class SecurityActivator {
+
+ private Policy originalPolicy;
+ private Policy fallBackPolicy = new Policy() {
+
+ @Override
+ public PermissionCollection getPermissions(final ProtectionDomain domain) {
+
+ PermissionCollection result;
+
+ Principal[] principals = domain.getPrincipals();
+ if (principals.length > 0) {
+ result = new Permissions();
+ } else {
+ result = originalPolicy.getPermissions(domain);
+ }
+ return result;
+ }
+ };
+
+ protected void activate(final ComponentContext context) throws Exception {
+ originalPolicy = Policy.getPolicy();
+ }
+
+ protected void deactivate(final ComponentContext context) throws Exception {
+ Policy.setPolicy(originalPolicy);
+ }
+
+ protected void bindUserAwarePolicy(UserAwarePolicy userAwarePolicy) {
+ Policy.setPolicy(userAwarePolicy);
+ }
+
+ protected void unbindUserAwarePolicy(UserAwarePolicy userAwarePolicy) {
+ Policy.setPolicy(fallBackPolicy);
+ }
+}
Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/pom.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/pom.xml?rev=956251&r1=956250&r2=956251&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/pom.xml (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/pom.xml Sat Jun 19 16:19:41 2010
@@ -59,6 +59,7 @@
<module>org.apache.clerezza.platform.scripting.scriptmanager</module>
<module>org.apache.clerezza.platform.security.auth.basic</module>
<module>org.apache.clerezza.platform.security.auth.cookie</module>
+ <module>org.apache.clerezza.platform.security.foafssl</module>
<module>org.apache.clerezza.platform.security.conditions</module>
<module>org.apache.clerezza.platform.security</module>
<module>org.apache.clerezza.platform.testing</module>
@@ -480,7 +481,7 @@
<groupId>org.ops4j.pax.runner</groupId>
<artifactId>pax-runner-no-jcl</artifactId>
<version>1.4.0</version>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-junit</artifactId>
@@ -692,19 +693,19 @@
<version>0.4-incubating-SNAPSHOT</version>
</dependency>
<dependency>
- <groupId>org.apache.clerezza.scala</groupId>
- <artifactId>scala-library-osgi</artifactId>
- <version>0.1-incubating-SNAPSHOT</version>
+ <groupId>org.apache.clerezza.scala</groupId>
+ <artifactId>scala-library-osgi</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
</dependency>
<dependency>
- <groupId>org.apache.clerezza.scala</groupId>
- <artifactId>scala-compiler-osgi</artifactId>
- <version>0.1-incubating-SNAPSHOT</version>
+ <groupId>org.apache.clerezza.scala</groupId>
+ <artifactId>scala-compiler-osgi</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
</dependency>
<dependency>
- <groupId>org.apache.clerezza.scala</groupId>
- <artifactId>script-engine</artifactId>
- <version>0.1-incubating-SNAPSHOT</version>
+ <groupId>org.apache.clerezza.scala</groupId>
+ <artifactId>script-engine</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.clerezza</groupId>
@@ -792,6 +793,26 @@
<version>0.8-incubating-SNAPSHOT</version>
</dependency>
<dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>org.apache.clerezza.platform.security.foafssl.core</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>org.apache.clerezza.platform.security.foafssl.ontologies</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jsslutils</groupId>
+ <artifactId>jsslutils</artifactId>
+ <version>1.0.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.wymiwyg</groupId>
+ <artifactId>jetty-osgi-httpservice</artifactId>
+ <version>0.1</version>
+ </dependency>
+ <dependency>
<groupId>org.wymiwyg</groupId>
<artifactId>wrhapi</artifactId>
<version>0.9</version>