001package org.apache.archiva.redback.rbac.jpa.model; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import org.apache.archiva.redback.rbac.Operation; 023import org.apache.archiva.redback.rbac.Permission; 024import org.apache.archiva.redback.rbac.Resource; 025import org.apache.archiva.redback.rbac.jpa.JpaRbacManager; 026 027import javax.persistence.*; 028import java.io.Serializable; 029 030/** 031 * Created by martin on 25.09.16. 032 */ 033@Entity 034@Table(name="SECURITY_PERMISSIONS") 035public class JpaPermission implements Permission,Serializable { 036 037 @Id 038 @Column(name="NAME") 039 private String name; 040 @Column(name="DESCRIPTION") 041 private String description; 042 @Column(name="PERMANENT", nullable = false) 043 private Boolean permanent = false; 044 @ManyToOne(cascade = CascadeType.ALL) 045 @JoinColumn( 046 name="OPERATION_NAME_OID", 047 referencedColumnName = "NAME" 048 ) 049 private JpaOperation operation; 050 @ManyToOne(cascade = CascadeType.ALL) 051 @JoinColumn( 052 name="RESOURCE_IDENTIFIER_OID", 053 referencedColumnName = "IDENTIFIER" 054 ) 055 private JpaResource resource; 056 057 058 @Override 059 public String getName() { 060 return name; 061 } 062 063 @Override 064 public void setName(String name) { 065 this.name = name; 066 } 067 068 @Override 069 public String getDescription() { 070 return description; 071 } 072 073 @Override 074 public void setDescription(String description) { 075 this.description = description; 076 } 077 078 @Override 079 public boolean isPermanent() { 080 return permanent; 081 } 082 083 @Override 084 public void setPermanent(boolean permanent) { 085 this.permanent = permanent; 086 } 087 088 @Override 089 public Operation getOperation() { 090 return operation; 091 } 092 093 @Override 094 public void setOperation(Operation operation) { 095 this.operation = (JpaOperation)operation; 096 } 097 098 @Override 099 public Resource getResource() { 100 return resource; 101 } 102 103 @Override 104 public void setResource(Resource resource) { 105 this.resource = (JpaResource)resource; 106 } 107 108 @Override 109 public boolean equals(Object o) { 110 if (this == o) return true; 111 if (o == null || getClass() != o.getClass()) return false; 112 113 JpaPermission that = (JpaPermission) o; 114 115 return name.equals(that.name); 116 117 } 118 119 @Override 120 public int hashCode() { 121 return name.hashCode(); 122 } 123}