001/* 002 * Copyright 2016 Anyware Services 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 */ 016package org.ametys.core.authentication; 017 018import java.util.Map; 019 020import org.apache.avalon.framework.configuration.Configuration; 021 022import org.ametys.runtime.i18n.I18nizableText; 023import org.ametys.runtime.model.ElementDefinition; 024import org.ametys.runtime.model.checker.ItemCheckerDescriptor; 025 026/** 027 * Default implementation of {@link CredentialProviderModel} 028 */ 029public class DefaultCredentialProviderModel implements CredentialProviderModel 030{ 031 private String _id; 032 private Class<CredentialProvider> _cpClass; 033 private Configuration _cpConfig; 034 private I18nizableText _label; 035 private I18nizableText _description; 036 private I18nizableText _connectionLabel; 037 private String _iconGlyph; 038 private String _iconDecorator; 039 private String _iconSmall; 040 private String _iconMedium; 041 private String _iconLarge; 042 private String _color; 043 private Map<String, ? extends ElementDefinition> _parameters; 044 private Map<String, ? extends ItemCheckerDescriptor> _parameterCheckers; 045 private String _pluginName; 046 047 /** 048 * Constructor 049 * @param id The unique identifier of this credential provider model 050 * @param udClass The {@link CredentialProvider} class 051 * @param cpConfig Additional configuration for {@link CredentialProvider} class. Can be empty. 052 * @param label The i18n label 053 * @param description The i18n description 054 * @param connectionLabel The i18n label for the connection screen 055 * @param iconGlyph The CSS class for glyph icon 056 * @param iconDecorator The CSS class for glyph decorator icon 057 * @param iconSmall The path of the small icon resource 058 * @param iconMedium The path of the medium icon resource 059 * @param iconLarge The path of the large icon resource 060 * @param color The string representation of the color which will be used for the button in the connection screen 061 * @param parameters The parameters 062 * @param parameterCheckers the parameter checkers 063 * @param pluginName The plugin's name of declaration (for debug purpose) 064 */ 065 public DefaultCredentialProviderModel (String id, Class<CredentialProvider> udClass, Configuration cpConfig, I18nizableText label, I18nizableText description, I18nizableText connectionLabel, String iconGlyph, String iconDecorator, String iconSmall, String iconMedium, String iconLarge, String color, Map<String, ? extends ElementDefinition> parameters, Map<String, ? extends ItemCheckerDescriptor> parameterCheckers, String pluginName) 066 { 067 _id = id; 068 _cpClass = udClass; 069 _cpConfig = cpConfig; 070 _label = label; 071 _description = description; 072 _connectionLabel = connectionLabel; 073 _iconGlyph = iconGlyph; 074 _iconDecorator = iconDecorator; 075 _iconSmall = iconSmall; 076 _iconLarge = iconLarge; 077 _color = color; 078 _parameters = parameters; 079 _parameterCheckers = parameterCheckers; 080 _pluginName = pluginName; 081 } 082 083 @Override 084 public String getId() 085 { 086 return _id; 087 } 088 089 @Override 090 public I18nizableText getLabel() 091 { 092 return _label; 093 } 094 095 @Override 096 public I18nizableText getDescription() 097 { 098 return _description; 099 } 100 101 @Override 102 public I18nizableText getConnectionLabel() 103 { 104 return _connectionLabel; 105 } 106 107 @Override 108 public String getIconGlyph() 109 { 110 return _iconGlyph; 111 } 112 113 @Override 114 public String getIconDecorator() 115 { 116 return _iconDecorator; 117 } 118 119 @Override 120 public String getIconSmall() 121 { 122 return _iconSmall; 123 } 124 125 @Override 126 public String getIconMedium() 127 { 128 return _iconMedium; 129 } 130 131 @Override 132 public String getIconLarge() 133 { 134 return _iconLarge; 135 } 136 137 @Override 138 public String getColor() 139 { 140 return _color; 141 } 142 143 @Override 144 public Map<String, ? extends ElementDefinition> getParameters() 145 { 146 return _parameters; 147 } 148 149 @Override 150 public Map<String, ? extends ItemCheckerDescriptor> getParameterCheckers() 151 { 152 return _parameterCheckers; 153 } 154 155 @Override 156 public String getPluginName() 157 { 158 return _pluginName; 159 } 160 161 @Override 162 public Class<CredentialProvider> getCredentialProviderClass() 163 { 164 return _cpClass; 165 } 166 167 @Override 168 public Configuration getCredentialProviderConfiguration () 169 { 170 return _cpConfig; 171 } 172 173}