From: <fc...@us...> - 2008-02-25 09:56:09
|
Revision: 693 http://openutils.svn.sourceforge.net/openutils/?rev=693&view=rev Author: fcarone Date: 2008-02-25 01:56:14 -0800 (Mon, 25 Feb 2008) Log Message: ----------- Copyright updated Modified Paths: -------------- trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/dao/SecurityRuleDAO.java trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/dao/impl/SecurityRuleDAOImpl.java trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/dataobject/ModifierEnum.java trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/dataobject/PermissionEnum.java trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/dataobject/SecurityRule.java trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/filter/JavaBeanFilter.java trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/filter/SecurityRuleBaseHandler.java trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/services/SecurityRuleManager.java Modified: trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/dao/SecurityRuleDAO.java =================================================================== --- trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/dao/SecurityRuleDAO.java 2008-02-25 09:26:33 UTC (rev 692) +++ trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/dao/SecurityRuleDAO.java 2008-02-25 09:56:14 UTC (rev 693) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * 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. */ package it.openutils.hibernate.security.dao; Modified: trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/dao/impl/SecurityRuleDAOImpl.java =================================================================== --- trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/dao/impl/SecurityRuleDAOImpl.java 2008-02-25 09:26:33 UTC (rev 692) +++ trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/dao/impl/SecurityRuleDAOImpl.java 2008-02-25 09:56:14 UTC (rev 693) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * 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. */ package it.openutils.hibernate.security.dao.impl; Modified: trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/dataobject/ModifierEnum.java =================================================================== --- trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/dataobject/ModifierEnum.java 2008-02-25 09:26:33 UTC (rev 692) +++ trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/dataobject/ModifierEnum.java 2008-02-25 09:56:14 UTC (rev 693) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * 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. */ package it.openutils.hibernate.security.dataobject; Modified: trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/dataobject/PermissionEnum.java =================================================================== --- trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/dataobject/PermissionEnum.java 2008-02-25 09:26:33 UTC (rev 692) +++ trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/dataobject/PermissionEnum.java 2008-02-25 09:56:14 UTC (rev 693) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * 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. */ package it.openutils.hibernate.security.dataobject; @@ -24,7 +36,7 @@ this.value = value; } - + /** * Returns the value. * @return the value Modified: trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/dataobject/SecurityRule.java =================================================================== --- trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/dataobject/SecurityRule.java 2008-02-25 09:26:33 UTC (rev 692) +++ trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/dataobject/SecurityRule.java 2008-02-25 09:56:14 UTC (rev 693) @@ -5,6 +5,7 @@ import java.io.Serializable; import java.util.List; +import java.util.Map; import javax.persistence.Column; import javax.persistence.Entity; @@ -21,6 +22,10 @@ import org.hibernate.annotations.CollectionOfElements; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; +import org.hibernate.annotations.Filter; +import org.hibernate.annotations.FilterDef; +import org.hibernate.annotations.FilterDefs; +import org.hibernate.annotations.Filters; import org.apache.commons.lang.builder.ToStringBuilder; @@ -30,6 +35,8 @@ */ @Entity @Table(name = "SECURITY_RULE") +@FilterDefs({@FilterDef(name = "notDeletedRules", defaultCondition = "DELETED != '1'") }) +@Filters({@Filter(name = "notDeletedRules") }) public class SecurityRule implements Serializable { @@ -66,6 +73,20 @@ @Fetch(FetchMode.SUBSELECT) private List<PermissionEnum> permissions; + @Enumerated(EnumType.STRING) + @Column(name = "STATUS", nullable = false) + private StatusEnum status; + + @Column(name = "DELETED", length = 1, nullable = false) + private Boolean deleted; + + @CollectionOfElements(fetch = FetchType.EAGER) + @org.hibernate.annotations.MapKey(columns = @Column(name = "REFERENCED_CLASS")) + @JoinTable(name = "SECRULE_ENTITY", joinColumns = {@JoinColumn(name = "ID_SECURITY_RULE") }) + @Column(name = "REFERENCED_ID", length = 60) + @Fetch(FetchMode.SUBSELECT) + private Map<String, String> entities; + /** * Returns the role. * @return the role @@ -209,4 +230,72 @@ .toString(); } + /** + * Returns the status. + * @return the status + */ + public StatusEnum getStatus() + { + return status; + } + + /** + * Sets the status. + * @param status the status to set + */ + public void setStatus(StatusEnum status) + { + this.status = status; + } + + /** + * @return True if the rule is enabled + */ + public boolean isEnabled() + { + if (status == null) + { + return false; + } + return status.equals(StatusEnum.ENABLED); + } + + /** + * Returns the entities. + * @return the entities + */ + public Map<String, String> getEntities() + { + return entities; + } + + /** + * Sets the entities. + * @param entities the entities to set + */ + public void setEntities(Map<String, String> entities) + { + this.entities = entities; + } + + + /** + * Returns the deleted. + * @return the deleted + */ + public Boolean getDeleted() + { + return deleted; + } + + + /** + * Sets the deleted. + * @param deleted the deleted to set + */ + public void setDeleted(Boolean deleted) + { + this.deleted = deleted; + } + } Modified: trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/filter/JavaBeanFilter.java =================================================================== --- trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/filter/JavaBeanFilter.java 2008-02-25 09:26:33 UTC (rev 692) +++ trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/filter/JavaBeanFilter.java 2008-02-25 09:56:14 UTC (rev 693) @@ -92,6 +92,11 @@ Map<String, List<SecurityRule>> roleRuleMap = new LinkedHashMap<String, List<SecurityRule>>(); for (SecurityRule securityRule : securityRules) { + if (!securityRule.isEnabled()) + { + continue; + } + if (!roleRuleMap.containsKey(securityRule.getRole())) { roleRuleMap.put(securityRule.getRole(), new ArrayList<SecurityRule>()); Modified: trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/filter/SecurityRuleBaseHandler.java =================================================================== --- trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/filter/SecurityRuleBaseHandler.java 2008-02-25 09:26:33 UTC (rev 692) +++ trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/filter/SecurityRuleBaseHandler.java 2008-02-25 09:56:14 UTC (rev 693) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * 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. */ package it.openutils.hibernate.security.filter; Modified: trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/services/SecurityRuleManager.java =================================================================== --- trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/services/SecurityRuleManager.java 2008-02-25 09:26:33 UTC (rev 692) +++ trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/services/SecurityRuleManager.java 2008-02-25 09:56:14 UTC (rev 693) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * 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. */ package it.openutils.hibernate.security.services; @@ -41,10 +53,9 @@ SecurityRule loadIfAvailable(Long id); /** - * @param id The security rule id - * @return The removed {@link SecurityRule} + * @param securityRule The security rule to remove */ - boolean delete(Long id); + void delete(SecurityRule securityRule); /** * @param securityRule The {@link SecurityRule} to save or update This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |