forked from apache/jackrabbit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JCR-2887 : Split PrivilegeRegistry in a per-session manager instance …
…and a repository level registry [work in progress] git-svn-id: https://svn.apache.org/repos/asf/jackrabbit/trunk@1081433 13f79535-47bb-0310-9956-ffa450edef68
- Loading branch information
Showing
9 changed files
with
617 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
187 changes: 98 additions & 89 deletions
187
...re/src/main/java/org/apache/jackrabbit/core/security/authorization/PrivilegeRegistry.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...bit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/privilege/ParseException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* 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.jackrabbit.commons.privilege; | ||
|
||
/** | ||
* <code>ParseException</code>... | ||
*/ | ||
public class ParseException extends Exception { | ||
|
||
public ParseException(Throwable throwable) { | ||
super(throwable); | ||
} | ||
|
||
public ParseException(String s, Throwable throwable) { | ||
super(s, throwable); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...cr-commons/src/main/java/org/apache/jackrabbit/commons/privilege/PrivilegeDefinition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* 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.jackrabbit.commons.privilege; | ||
|
||
/** | ||
* <code>PrivilegeDefinition</code> | ||
*/ | ||
public class PrivilegeDefinition { | ||
private final String name; | ||
private final boolean isAbstract; | ||
private final String[] declaredAggregateNames; | ||
|
||
public PrivilegeDefinition(String name, boolean isAbstract, String[] declaredAggregateNames) { | ||
this.name = name; | ||
this.isAbstract = isAbstract; | ||
this.declaredAggregateNames = declaredAggregateNames; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public boolean isAbstract() { | ||
return isAbstract; | ||
} | ||
|
||
public String[] getDeclaredAggregateNames() { | ||
return declaredAggregateNames; | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
...mons/src/main/java/org/apache/jackrabbit/commons/privilege/PrivilegeDefinitionReader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* 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.jackrabbit.commons.privilege; | ||
|
||
import java.io.InputStream; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Reads privilege definitions for the specified <code>InputStream</code>. Note, | ||
* that this reader will not apply any validation. | ||
*/ | ||
public class PrivilegeDefinitionReader { | ||
|
||
private final PrivilegeDefinition[] privilegeDefinitions; | ||
private final Map<String, String> namespaces = new HashMap<String, String>(); | ||
|
||
/** | ||
* Creates a new <code>PrivilegeDefinitionReader</code> for the given | ||
* input stream. The specified content type is used in order to determine | ||
* the type of privilege serialization. | ||
* | ||
* @param in The input stream to read the privilege definitions from. | ||
* @param contentType Currently only types supported by | ||
* {@link PrivilegeXmlHandler#isSupportedContentType(String)PrivilegeXmlHandler} | ||
* are allowed. | ||
* @throws ParseException If an error occurs. | ||
* @throws IllegalArgumentException if the specified content type is not supported. | ||
*/ | ||
public PrivilegeDefinitionReader(InputStream in, String contentType) throws ParseException { | ||
if (PrivilegeXmlHandler.isSupportedContentType(contentType)) { | ||
PrivilegeHandler pxh = new PrivilegeXmlHandler(); | ||
privilegeDefinitions = pxh.readDefinitions(in, namespaces); | ||
} else { | ||
// not yet supported | ||
throw new IllegalArgumentException("Unsupported content type " + contentType); | ||
} | ||
} | ||
|
||
/** | ||
* Returns the privilege definitions retrieved from the input stream. | ||
* | ||
* @return an array of <code>PrivilegeDefinition</code> | ||
*/ | ||
public PrivilegeDefinition[] getPrivilegeDefinitions() { | ||
return privilegeDefinitions; | ||
} | ||
|
||
/** | ||
* Returns the namespace mappings such as retrieved during parsing. | ||
* | ||
* @return a mapping of namespace prefix to uri used by the privilege | ||
* definitions. | ||
*/ | ||
public Map<String,String> getNamespaces() { | ||
return namespaces; | ||
} | ||
} |
Oops, something went wrong.