01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. The ASF licenses this file to You
04: * under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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. For additional information regarding
15: * copyright in this work, please see the NOTICE file in the top level
16: * directory of this distribution.
17: */
18: package org.apache.roller.ui.core.security;
19:
20: import org.apache.commons.logging.Log;
21: import org.apache.commons.logging.LogFactory;
22: import org.apache.roller.RollerException;
23: import org.apache.roller.business.RollerFactory;
24: import org.apache.roller.business.UserManager;
25: import org.apache.roller.pojos.UserData;
26:
27: /**
28: * @author Elias Torres (<a href="mailto:eliast@us.ibm.com">eliast@us.ibm.com</a>)
29: *
30: */
31: public class BasicUserAutoProvision implements AutoProvision {
32:
33: private static Log log = LogFactory.getFactory().getInstance(
34: BasicUserAutoProvision.class);
35:
36: /*
37: * (non-Javadoc)
38: *
39: * @see org.apache.roller.ui.core.security.AutoProvision#execute()
40: */
41: public boolean execute() {
42: UserData ud = CustomUserRegistry
43: .getUserDetailsFromAuthentication();
44:
45: if (ud != null) {
46: UserManager mgr;
47: try {
48: mgr = RollerFactory.getRoller().getUserManager();
49: mgr.addUser(ud);
50: RollerFactory.getRoller().flush();
51: } catch (RollerException e) {
52: log.warn(
53: "Error while auto-provisioning user from SSO.",
54: e);
55: }
56: }
57:
58: return true;
59: }
60:
61: }
|