/
Principal.java
83 lines (66 loc) · 1.96 KB
/
Principal.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* Copyright 2006-2014 University of Dundee. All rights reserved.
* Use is subject to license terms supplied in LICENSE.txt
*/
package ome.system;
import java.io.Serializable;
import ome.model.enums.EventType;
import ome.model.internal.Permissions;
import ome.model.meta.ExperimenterGroup;
/**
* implementation of {@link java.security.Principal}. Specialized for Omero to
* carry a {@link ExperimenterGroup group}, an {@link EventType event type} and
* a {@link Permissions umask}.
*
* @author Josh Moore, josh.moore at gmx.de
* @version $Revision$, $Date$
* @see EventType
* @see ExperimenterGroup
* @see Permissions
* @since 3.0
*/
public class Principal implements java.security.Principal, Serializable {
private static final long serialVersionUID = 3761954018296933086L;
protected String name;
protected String group;
protected String type;
private final PreferenceContext preferences = new PreferenceContext();
/**
* Creates a Principal with null group and event type. These must be taken
* from the session.
*
* @param name
*/
public Principal(String name) {
this(name, null, null);
}
public Principal(String name, String group, String eventType) {
if (Boolean.parseBoolean(preferences
.getProperty("omero.security.ignore_case"))) {
name = name.toLowerCase();
}
this.name = name;
this.group = group;
this.type = eventType;
}
// IMMUTABLE
public String getName() {
return this.name;
}
public String getGroup() {
return this.group;
}
public String getEventType() {
return this.type;
}
/**
* returns only the name of the instance because that is the expected
* behavior of {@link java.security.Principal} implementations
*
* @return value of {@link #name}
*/
@Override
public String toString() {
return this.name;
}
}