Author: adrianc
Date: Mon Aug 17 21:22:29 2009 New Revision: 805148 URL: http://svn.apache.org/viewvc?rev=805148&view=rev Log: Some files that didn't go through in last commit. Added: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/ ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AccessController.java (with props) ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AdminPermission.java (with props) ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AuthorizationManager.java (with props) ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/BasicPermission.java (with props) ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/BasicPermissions.java (with props) ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/PermissionsIntersection.java (with props) ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/PermissionsList.java (with props) ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/PermissionsUnion.java (with props) Added: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AccessController.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AccessController.java?rev=805148&view=auto ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AccessController.java (added) +++ ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AccessController.java Mon Aug 17 21:22:29 2009 @@ -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.ofbiz.api.authorization; + +import java.security.AccessControlException; +import java.security.Permission; + +/** + * AccessController interface. + */ +public interface AccessController { + + public void checkPermission(Permission permission) throws AccessControlException; + +} Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AccessController.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AccessController.java ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AccessController.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AdminPermission.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AdminPermission.java?rev=805148&view=auto ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AdminPermission.java (added) +++ ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AdminPermission.java Mon Aug 17 21:22:29 2009 @@ -0,0 +1,66 @@ +/******************************************************************************* + * 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.ofbiz.api.authorization; + +import java.security.Permission; + +/** + * Admin permission class. Similar to java.security.BasicPermission. + */ +@SuppressWarnings("serial") +public class AdminPermission extends Permission { + + protected final String permissionString = "admin=true"; + + public AdminPermission() { + super("admin=true"); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + try { + BasicPermission that = (BasicPermission) obj; + return this.permissionString.equals(that.permissionString); + } catch (Exception e) {} + return false; + } + + @Override + public String getActions() { + return null; + } + + @Override + public int hashCode() { + return this.permissionString.hashCode(); + } + + @Override + public boolean implies(Permission permission) { + return true; + } + + @Override + public String toString() { + return this.permissionString; + } +} Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AdminPermission.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AdminPermission.java ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AdminPermission.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AuthorizationManager.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AuthorizationManager.java?rev=805148&view=auto ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AuthorizationManager.java (added) +++ ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AuthorizationManager.java Mon Aug 17 21:22:29 2009 @@ -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.ofbiz.api.authorization; + +import org.ofbiz.api.context.ExecutionContext; + +/** + * AuthorizationManager interface. + */ +public interface AuthorizationManager { + + // Get the access controller for an artifact/user combination + public AccessController getAccessController (ExecutionContext executionContext); + +} Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AuthorizationManager.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AuthorizationManager.java ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AuthorizationManager.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/BasicPermission.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/BasicPermission.java?rev=805148&view=auto ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/BasicPermission.java (added) +++ ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/BasicPermission.java Mon Aug 17 21:22:29 2009 @@ -0,0 +1,85 @@ +/******************************************************************************* + * 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.ofbiz.api.authorization; + +import java.security.Permission; + +/** + * Basic permission class. Similar to java.security.BasicPermission. + */ +@SuppressWarnings("serial") +public class BasicPermission extends Permission { + + protected final String permissionString; + + public BasicPermission(String permissionString) { + super(permissionString); + this.permissionString = permissionString; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + try { + BasicPermission that = (BasicPermission) obj; + return this.permissionString.equals(that.permissionString); + } catch (Exception e) {} + return false; + } + + @Override + public String getActions() { + return null; + } + + @Override + public int hashCode() { + return this.permissionString.hashCode(); + } + + @Override + public boolean implies(Permission permission) { + try { + PermissionsUnion permissionsUnion = (PermissionsUnion) permission; + for (Permission perm : permissionsUnion.permissionsList) { + if (this.implies(perm)) { + return true; + } + } + return false; + } catch (Exception e) {} + try { + PermissionsIntersection permissionsIntersection = (PermissionsIntersection) permission; + for (Permission perm : permissionsIntersection.permissionsList) { + if (!this.implies(perm)) { + return false; + } + } + return true; + } catch (Exception e) {} + return this.equals(permission); + } + + @Override + public String toString() { + return this.permissionString; + } +} Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/BasicPermission.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/BasicPermission.java ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/BasicPermission.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/BasicPermissions.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/BasicPermissions.java?rev=805148&view=auto ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/BasicPermissions.java (added) +++ ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/BasicPermissions.java Mon Aug 17 21:22:29 2009 @@ -0,0 +1,33 @@ +/******************************************************************************* + * 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.ofbiz.api.authorization; + +import java.security.Permission; + +/** + * A collection of basic permissions. + */ +public class BasicPermissions { + public static final Permission Access = new BasicPermission("access=true"); + public static final Permission Admin = new AdminPermission(); + public static final Permission Create = new BasicPermission("create=true"); + public static final Permission Delete = new BasicPermission("delete=true"); + public static final Permission Update = new BasicPermission("update=true"); + public static final Permission View = new BasicPermission("view=true"); +} Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/BasicPermissions.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/BasicPermissions.java ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/BasicPermissions.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/PermissionsIntersection.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/PermissionsIntersection.java?rev=805148&view=auto ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/PermissionsIntersection.java (added) +++ ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/PermissionsIntersection.java Mon Aug 17 21:22:29 2009 @@ -0,0 +1,64 @@ +/******************************************************************************* + * 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.ofbiz.api.authorization; + +import java.security.Permission; +import java.util.List; + +/** + * A <code>List</code> of permissions that represent an intersection. + */ +@SuppressWarnings("serial") +public class PermissionsIntersection extends PermissionsList { + + public PermissionsIntersection(String listName, List<Permission> permissionsList) { + super(listName, permissionsList); + } + + /** Returns <code>true</code> if all of the contained permissions + * returns <code>true</code>. + */ + @Override + public boolean implies(Permission permission) { + try { + PermissionsUnion permissionsUnion = (PermissionsUnion) permission; + for (Permission perm : permissionsUnion.permissionsList) { + if (this.implies(perm)) { + return true; + } + } + return false; + } catch (Exception e) {} + try { + PermissionsIntersection permissionsIntersection = (PermissionsIntersection) permission; + for (Permission perm : permissionsIntersection.permissionsList) { + if (!this.implies(perm)) { + return false; + } + } + return true; + } catch (Exception e) {} + for (Permission perm : this.permissionsList) { + if (!perm.implies(permission)) { + return false; + } + } + return true; + } +} Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/PermissionsIntersection.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/PermissionsIntersection.java ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/PermissionsIntersection.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/PermissionsList.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/PermissionsList.java?rev=805148&view=auto ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/PermissionsList.java (added) +++ ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/PermissionsList.java Mon Aug 17 21:22:29 2009 @@ -0,0 +1,67 @@ +/******************************************************************************* + * 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.ofbiz.api.authorization; + +import java.security.Permission; +import java.util.List; + +/** + * A <code>List</code> of permissions. + */ +@SuppressWarnings("serial") +public abstract class PermissionsList extends Permission { + protected final List<Permission> permissionsList; + + public PermissionsList(String listName, List<Permission> permissionsList) { + super(listName); + this.permissionsList = permissionsList; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + try { + PermissionsList that = (PermissionsList) obj; + return this.permissionsList.equals(that.permissionsList); + } catch (Exception e) {} + return false; + } + + @Override + public String getActions() { + return null; + } + + @Override + public int hashCode() { + return permissionsList.hashCode(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + for (Permission perm : this.permissionsList) { + sb.append(perm); + sb.append(" "); + } + return sb.toString().trim(); + } +} Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/PermissionsList.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/PermissionsList.java ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/PermissionsList.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/PermissionsUnion.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/PermissionsUnion.java?rev=805148&view=auto ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/PermissionsUnion.java (added) +++ ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/PermissionsUnion.java Mon Aug 17 21:22:29 2009 @@ -0,0 +1,98 @@ +/******************************************************************************* + * 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.ofbiz.api.authorization; + +import java.security.Permission; +import java.util.List; + +/** + * A <code>List</code> of permissions that represent a union. + */ +@SuppressWarnings("serial") +public class PermissionsUnion extends Permission { + protected final List<Permission> permissionsList; + + public PermissionsUnion(String listName, List<Permission> permissionsList) { + super(listName); + this.permissionsList = permissionsList; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + try { + PermissionsUnion that = (PermissionsUnion) obj; + return this.permissionsList.equals(that.permissionsList); + } catch (Exception e) {} + return false; + } + + @Override + public String getActions() { + return null; + } + + @Override + public int hashCode() { + return permissionsList.hashCode(); + } + + /** Returns <code>true</code> if any of the contained permissions + * returns <code>true</code>. + */ + @Override + public boolean implies(Permission permission) { + try { + PermissionsUnion permissionsUnion = (PermissionsUnion) permission; + for (Permission perm : permissionsUnion.permissionsList) { + if (this.implies(perm)) { + return true; + } + } + return false; + } catch (Exception e) {} + try { + PermissionsIntersection permissionsIntersection = (PermissionsIntersection) permission; + for (Permission perm : permissionsIntersection.permissionsList) { + if (!this.implies(perm)) { + return false; + } + } + return true; + } catch (Exception e) {} + for (Permission perm : this.permissionsList) { + if (perm.implies(permission)) { + return true; + } + } + return false; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + for (Permission perm : this.permissionsList) { + sb.append(perm); + sb.append(" "); + } + return sb.toString().trim(); + } +} Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/PermissionsUnion.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/PermissionsUnion.java ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/PermissionsUnion.java ------------------------------------------------------------------------------ svn:mime-type = text/plain |
Free forum by Nabble | Edit this page |