001/*
002 * (C) Copyright 2006-2007 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Nuxeo - initial API and implementation
018 */
019
020package org.nuxeo.ecm.platform.ui.web.auth.service;
021
022import java.util.HashMap;
023import java.util.Map;
024import org.nuxeo.common.xmap.annotation.XNode;
025import org.nuxeo.common.xmap.annotation.XNodeMap;
026import org.nuxeo.common.xmap.annotation.XObject;
027import org.nuxeo.ecm.core.api.NuxeoException;
028import org.nuxeo.ecm.platform.ui.web.auth.interfaces.NuxeoAuthenticationPlugin;
029
030@XObject("authenticationPlugin")
031public class AuthenticationPluginDescriptor {
032
033    @XNode("@name")
034    private String name;
035
036    @XNode("@enabled")
037    boolean enabled = true;
038
039    @XNode("@class")
040    Class<NuxeoAuthenticationPlugin> className;
041
042    private Boolean needStartingURLSaving;
043
044    @XNodeMap(value = "parameters/parameter", key = "@name", type = HashMap.class, componentType = String.class)
045    Map<String, String> parameters = new HashMap<>();
046
047    private Boolean stateful;
048
049    public Class<NuxeoAuthenticationPlugin> getClassName() {
050        return className;
051    }
052
053    public boolean getEnabled() {
054        return enabled;
055    }
056
057    public void setEnabled(boolean enabled) {
058        this.enabled = enabled;
059    }
060
061    public String getName() {
062        return name;
063    }
064
065    public Map<String, String> getParameters() {
066        return parameters;
067    }
068
069    public void setParameters(Map<String, String> parameters) {
070        this.parameters = parameters;
071    }
072
073    public boolean getNeedStartingURLSaving() {
074        if (needStartingURLSaving != null) {
075            return needStartingURLSaving;
076        }
077        return false;
078    }
079
080    public boolean getStateful() {
081        if (stateful != null) {
082            return stateful;
083        }
084        return Boolean.valueOf(getNeedStartingURLSaving());
085    }
086
087    public void setClassName(Class<NuxeoAuthenticationPlugin> className) {
088        this.className = className;
089    }
090
091    @XNode("needStartingURLSaving")
092    public void setNeedStartingURLSaving(boolean needStartingURLSaving) {
093        this.needStartingURLSaving = Boolean.valueOf(needStartingURLSaving);
094    }
095
096    @XNode("stateful")
097    public void setStateful(boolean stateful) {
098        this.stateful = Boolean.valueOf(stateful);
099    }
100
101}