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
;
24 public class SimpleUserNature
extends AbstractUserNature
{
26 * No PAI, for internal use within the Argeo Security framework. Will
27 * probably be removed.
29 public final static String TYPE
= "simpleUser";
31 private static final long serialVersionUID
= 1L;
33 private String firstName
;
34 private String lastName
;
35 private String description
;
37 public String
getEmail() {
41 public void setEmail(String email
) {
45 public String
getFirstName() {
49 public void setFirstName(String firstName
) {
50 this.firstName
= firstName
;
53 public String
getLastName() {
57 public void setLastName(String lastName
) {
58 this.lastName
= lastName
;
61 public String
getDescription() {
65 public void setDescription(String description
) {
66 this.description
= description
;
73 * Finds a user nature extending {@link SimpleUserNature} in the provided
78 * @param simpleNatureType
79 * the type under which a {@link SimpleUserNature} is registered,
80 * useful if there are many. can be null.
81 * @return the {@link SimpleUserNature}
82 * @throws ArgeoException
83 * if no simple user nature was found
85 public final static SimpleUserNature
findSimpleUserNature(ArgeoUser user
,
86 String simpleNatureType
) {
87 SimpleUserNature simpleNature
= null;
88 if (simpleNatureType
!= null)
89 simpleNature
= (SimpleUserNature
) user
.getUserNatures().get(
92 for (UserNature userNature
: user
.getUserNatures().values())
93 if (userNature
instanceof SimpleUserNature
)
94 simpleNature
= (SimpleUserNature
) userNature
;
96 if (simpleNature
== null)
97 throw new ArgeoException("No simple user nature in user " + user
);