(no commit message)
[utils] / security / usermgt / src / main / java / org / wamblee / security / authorization / AbstractAuthorizationService.java
1 /*
2  * Copyright 2005-2010 the original author or authors.
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * 
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  * 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.wamblee.security.authorization;
17
18 import javax.persistence.DiscriminatorColumn;
19 import javax.persistence.Entity;
20 import javax.persistence.GeneratedValue;
21 import javax.persistence.GenerationType;
22 import javax.persistence.Id;
23 import javax.persistence.Inheritance;
24 import javax.persistence.InheritanceType;
25 import javax.persistence.NamedQueries;
26 import javax.persistence.NamedQuery;
27 import javax.persistence.Table;
28 import javax.persistence.Version;
29
30 /**
31  * Service to determine if access to a certain resource is allowed.
32  * 
33  * @author Erik Brakkee
34  */
35 @Entity
36 @Table(name = "SEC_AUTH_SVC")
37 @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
38 @DiscriminatorColumn(name = "TYPE")
39 @NamedQueries(@NamedQuery(name = AbstractAuthorizationService.QUERY_FIND_BY_NAME, query = "select s from AbstractAuthorizationService s where s.name = :" +
40     AbstractAuthorizationService.NAME_PARAM))
41 public abstract class AbstractAuthorizationService implements
42     AuthorizationService {
43
44     public static final String QUERY_FIND_BY_NAME = "AuthorizationService.findByName";
45     public static final String NAME_PARAM = "name";
46
47     @Id
48     @GeneratedValue(strategy = GenerationType.AUTO)
49     private Long id;
50
51     @Version
52     private int version;
53
54     /**
55      * Name for this instance of the authorization service.
56      */
57     private String name;
58
59     public AbstractAuthorizationService() {
60         // Empty.
61     }
62
63     public AbstractAuthorizationService(String aName) {
64         name = aName;
65     }
66
67     public AbstractAuthorizationService(AbstractAuthorizationService aSvc) {
68         id = aSvc.id;
69         version = aSvc.version;
70         name = aSvc.name;
71     }
72
73     public String getName() {
74         return name;
75     }
76 }