1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.model.common;
|
11
|
|
12
|
import javax.persistence.Entity;
|
13
|
import javax.xml.bind.annotation.XmlAccessType;
|
14
|
import javax.xml.bind.annotation.XmlAccessorType;
|
15
|
import javax.xml.bind.annotation.XmlElement;
|
16
|
import javax.xml.bind.annotation.XmlRootElement;
|
17
|
import javax.xml.bind.annotation.XmlType;
|
18
|
|
19
|
import org.apache.log4j.Logger;
|
20
|
import org.hibernate.annotations.NaturalId;
|
21
|
import org.springframework.security.core.GrantedAuthority;
|
22
|
|
23
|
@XmlAccessorType(XmlAccessType.FIELD)
|
24
|
@XmlType(name = "GrantedAuthority", propOrder = { "authority" })
|
25
|
@XmlRootElement(name = "Group")
|
26
|
@Entity
|
27
|
public class GrantedAuthorityImpl extends CdmBase implements GrantedAuthority {
|
28
|
private static final long serialVersionUID = 2651969425860655040L;
|
29
|
private static final Logger logger = Logger
|
30
|
.getLogger(GrantedAuthority.class);
|
31
|
|
32
|
@XmlElement(name = "Authority")
|
33
|
@NaturalId
|
34
|
private String authority;
|
35
|
|
36
|
protected GrantedAuthorityImpl() {
|
37
|
super();
|
38
|
}
|
39
|
|
40
|
public static GrantedAuthorityImpl NewInstance() {
|
41
|
return new GrantedAuthorityImpl();
|
42
|
}
|
43
|
|
44
|
public String getAuthority() {
|
45
|
return authority;
|
46
|
}
|
47
|
|
48
|
public void setAuthority(String authority) {
|
49
|
this.authority = authority;
|
50
|
}
|
51
|
|
52
|
public int compareTo(Object o) {
|
53
|
if (o instanceof GrantedAuthority) {
|
54
|
return this.authority.compareTo(((GrantedAuthority) o)
|
55
|
.getAuthority());
|
56
|
}
|
57
|
return 0;
|
58
|
}
|
59
|
|
60
|
// *********** CLONE **********************************/
|
61
|
|
62
|
/**
|
63
|
* Clones <i>this</i> Granted Authority. This is a shortcut that enables to
|
64
|
* create a new instance that differs only slightly from <i>this</i> Granted
|
65
|
* Authority by modifying only some of the attributes.<BR>
|
66
|
*
|
67
|
*
|
68
|
*
|
69
|
* @see eu.etaxonomy.cdm.model.common.CdmBase#clone()
|
70
|
* @see java.lang.Object#clone()
|
71
|
*/
|
72
|
@Override
|
73
|
public Object clone() {
|
74
|
GrantedAuthority result;
|
75
|
try {
|
76
|
result = (GrantedAuthority) super.clone();
|
77
|
// no changes to authority
|
78
|
return result;
|
79
|
} catch (CloneNotSupportedException e) {
|
80
|
logger.warn("Object does not implement cloneable");
|
81
|
e.printStackTrace();
|
82
|
return null;
|
83
|
}
|
84
|
}
|
85
|
}
|