01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.jetspeed.security.impl;
18:
19: import java.util.prefs.Preferences;
20:
21: import javax.security.auth.Subject;
22:
23: import org.apache.jetspeed.security.User;
24:
25: /**
26: * <p>A user made of a {@link Subject} and the user {@link Preferences}.</p>
27: * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
28: */
29: public class UserImpl implements User {
30: private Subject subject;
31: private Preferences preferences;
32:
33: /**
34: * <p>Default constructor.</p>
35: */
36: public UserImpl() {
37: }
38:
39: /**
40: * <p>{@link User} constructor given a subject and preferences.</p>
41: * @param subject The subject.
42: * @param preferences The preferences.
43: */
44: public UserImpl(Subject subject, Preferences preferences) {
45: this .subject = subject;
46: this .preferences = preferences;
47: }
48:
49: /**
50: * @see org.apache.jetspeed.security.User#getSubject()
51: */
52: public Subject getSubject() {
53: return subject;
54: }
55:
56: /**
57: * @see org.apache.jetspeed.security.User#setSubject(javax.security.auth.Subject)
58: */
59: public void setSubject(Subject subject) {
60: this .subject = subject;
61: }
62:
63: /**
64: * @see org.apache.jetspeed.security.User#getPreferences()
65: */
66: public Preferences getPreferences() {
67: return preferences;
68: }
69:
70: /**
71: * @see org.apache.jetspeed.security.User#setPreferences(java.util.prefs.Preferences)
72: */
73: public void setPreferences(Preferences preferences) {
74: this .preferences = preferences;
75: }
76:
77: public Preferences getUserAttributes() {
78: if (preferences != null) {
79: return preferences.node(USER_INFO_PROPERTY_SET);
80: }
81: return null;
82: }
83: }
|