2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org
.argeo
.security
.nature
;
19 import org
.argeo
.ArgeoException
;
20 import org
.argeo
.security
.AbstractUserNature
;
21 import org
.argeo
.security
.ArgeoUser
;
22 import org
.argeo
.security
.UserNature
;
25 public class SimpleUserNature
extends AbstractUserNature
{
27 * No PAI, for internal use within the Argeo Security framework. Will
28 * probably be removed.
30 public final static String TYPE
= "simpleUser";
32 private static final long serialVersionUID
= 1L;
34 private String firstName
;
35 private String lastName
;
36 private String description
;
38 public String
getEmail() {
42 public void setEmail(String email
) {
46 public String
getFirstName() {
50 public void setFirstName(String firstName
) {
51 this.firstName
= firstName
;
54 public String
getLastName() {
58 public void setLastName(String lastName
) {
59 this.lastName
= lastName
;
62 public String
getDescription() {
66 public void setDescription(String description
) {
67 this.description
= description
;
74 * Finds a user nature extending {@link SimpleUserNature} in the provided
79 * @param simpleNatureType
80 * the type under which a {@link SimpleUserNature} is registered,
81 * useful if there are many. can be null.
82 * @return the {@link SimpleUserNature}
83 * @throws ArgeoException
84 * if no simple user nature was found
86 public final static SimpleUserNature
findSimpleUserNature(ArgeoUser user
,
87 String simpleNatureType
) {
88 SimpleUserNature simpleNature
= null;
89 if (simpleNatureType
!= null)
90 simpleNature
= (SimpleUserNature
) user
.getUserNatures().get(
93 for (UserNature userNature
: user
.getUserNatures().values())
94 if (userNature
instanceof SimpleUserNature
)
95 simpleNature
= (SimpleUserNature
) userNature
;
97 if (simpleNature
== null)
98 throw new ArgeoException("No simple user nature in user " + user
);