001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2008 Sun Microsystems, Inc. 015 */ 016package org.opends.server.admin.std.meta; 017 018 019 020import org.forgerock.opendj.ldap.DN; 021import org.opends.server.admin.AdministratorAction; 022import org.opends.server.admin.BooleanPropertyDefinition; 023import org.opends.server.admin.ClassPropertyDefinition; 024import org.opends.server.admin.client.AuthorizationException; 025import org.opends.server.admin.client.CommunicationException; 026import org.opends.server.admin.client.ConcurrentModificationException; 027import org.opends.server.admin.client.ManagedObject; 028import org.opends.server.admin.client.MissingMandatoryPropertiesException; 029import org.opends.server.admin.client.OperationRejectedException; 030import org.opends.server.admin.DefaultBehaviorProvider; 031import org.opends.server.admin.DefinedDefaultBehaviorProvider; 032import org.opends.server.admin.ManagedObjectAlreadyExistsException; 033import org.opends.server.admin.ManagedObjectDefinition; 034import org.opends.server.admin.PropertyOption; 035import org.opends.server.admin.PropertyProvider; 036import org.opends.server.admin.server.ConfigurationChangeListener; 037import org.opends.server.admin.server.ServerManagedObject; 038import org.opends.server.admin.std.client.SaltedSHA256PasswordStorageSchemeCfgClient; 039import org.opends.server.admin.std.server.PasswordStorageSchemeCfg; 040import org.opends.server.admin.std.server.SaltedSHA256PasswordStorageSchemeCfg; 041import org.opends.server.admin.Tag; 042 043 044 045/** 046 * An interface for querying the Salted SHA256 Password Storage Scheme 047 * managed object definition meta information. 048 * <p> 049 * The Salted SHA256 Password Storage Scheme provides a mechanism for 050 * encoding user passwords using a salted form of the 256-bit SHA-2 051 * message digest algorithm. 052 */ 053public final class SaltedSHA256PasswordStorageSchemeCfgDefn extends ManagedObjectDefinition<SaltedSHA256PasswordStorageSchemeCfgClient, SaltedSHA256PasswordStorageSchemeCfg> { 054 055 // The singleton configuration definition instance. 056 private static final SaltedSHA256PasswordStorageSchemeCfgDefn INSTANCE = new SaltedSHA256PasswordStorageSchemeCfgDefn(); 057 058 059 060 // The "java-class" property definition. 061 private static final ClassPropertyDefinition PD_JAVA_CLASS; 062 063 064 065 // Build the "java-class" property definition. 066 static { 067 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 068 builder.setOption(PropertyOption.MANDATORY); 069 builder.setOption(PropertyOption.ADVANCED); 070 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "java-class")); 071 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.extensions.SaltedSHA256PasswordStorageScheme"); 072 builder.setDefaultBehaviorProvider(provider); 073 builder.addInstanceOf("org.opends.server.api.PasswordStorageScheme"); 074 PD_JAVA_CLASS = builder.getInstance(); 075 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 076 } 077 078 079 080 // Register the tags associated with this managed object definition. 081 static { 082 INSTANCE.registerTag(Tag.valueOf("user-management")); 083 } 084 085 086 087 /** 088 * Get the Salted SHA256 Password Storage Scheme configuration 089 * definition singleton. 090 * 091 * @return Returns the Salted SHA256 Password Storage Scheme 092 * configuration definition singleton. 093 */ 094 public static SaltedSHA256PasswordStorageSchemeCfgDefn getInstance() { 095 return INSTANCE; 096 } 097 098 099 100 /** 101 * Private constructor. 102 */ 103 private SaltedSHA256PasswordStorageSchemeCfgDefn() { 104 super("salted-sha256-password-storage-scheme", PasswordStorageSchemeCfgDefn.getInstance()); 105 } 106 107 108 109 /** 110 * {@inheritDoc} 111 */ 112 public SaltedSHA256PasswordStorageSchemeCfgClient createClientConfiguration( 113 ManagedObject<? extends SaltedSHA256PasswordStorageSchemeCfgClient> impl) { 114 return new SaltedSHA256PasswordStorageSchemeCfgClientImpl(impl); 115 } 116 117 118 119 /** 120 * {@inheritDoc} 121 */ 122 public SaltedSHA256PasswordStorageSchemeCfg createServerConfiguration( 123 ServerManagedObject<? extends SaltedSHA256PasswordStorageSchemeCfg> impl) { 124 return new SaltedSHA256PasswordStorageSchemeCfgServerImpl(impl); 125 } 126 127 128 129 /** 130 * {@inheritDoc} 131 */ 132 public Class<SaltedSHA256PasswordStorageSchemeCfg> getServerConfigurationClass() { 133 return SaltedSHA256PasswordStorageSchemeCfg.class; 134 } 135 136 137 138 /** 139 * Get the "enabled" property definition. 140 * <p> 141 * Indicates whether the Salted SHA256 Password Storage Scheme is 142 * enabled for use. 143 * 144 * @return Returns the "enabled" property definition. 145 */ 146 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 147 return PasswordStorageSchemeCfgDefn.getInstance().getEnabledPropertyDefinition(); 148 } 149 150 151 152 /** 153 * Get the "java-class" property definition. 154 * <p> 155 * Specifies the fully-qualified name of the Java class that 156 * provides the Salted SHA256 Password Storage Scheme implementation. 157 * 158 * @return Returns the "java-class" property definition. 159 */ 160 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 161 return PD_JAVA_CLASS; 162 } 163 164 165 166 /** 167 * Managed object client implementation. 168 */ 169 private static class SaltedSHA256PasswordStorageSchemeCfgClientImpl implements 170 SaltedSHA256PasswordStorageSchemeCfgClient { 171 172 // Private implementation. 173 private ManagedObject<? extends SaltedSHA256PasswordStorageSchemeCfgClient> impl; 174 175 176 177 // Private constructor. 178 private SaltedSHA256PasswordStorageSchemeCfgClientImpl( 179 ManagedObject<? extends SaltedSHA256PasswordStorageSchemeCfgClient> impl) { 180 this.impl = impl; 181 } 182 183 184 185 /** 186 * {@inheritDoc} 187 */ 188 public Boolean isEnabled() { 189 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 190 } 191 192 193 194 /** 195 * {@inheritDoc} 196 */ 197 public void setEnabled(boolean value) { 198 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 199 } 200 201 202 203 /** 204 * {@inheritDoc} 205 */ 206 public String getJavaClass() { 207 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 208 } 209 210 211 212 /** 213 * {@inheritDoc} 214 */ 215 public void setJavaClass(String value) { 216 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 217 } 218 219 220 221 /** 222 * {@inheritDoc} 223 */ 224 public ManagedObjectDefinition<? extends SaltedSHA256PasswordStorageSchemeCfgClient, ? extends SaltedSHA256PasswordStorageSchemeCfg> definition() { 225 return INSTANCE; 226 } 227 228 229 230 /** 231 * {@inheritDoc} 232 */ 233 public PropertyProvider properties() { 234 return impl; 235 } 236 237 238 239 /** 240 * {@inheritDoc} 241 */ 242 public void commit() throws ManagedObjectAlreadyExistsException, 243 MissingMandatoryPropertiesException, ConcurrentModificationException, 244 OperationRejectedException, AuthorizationException, 245 CommunicationException { 246 impl.commit(); 247 } 248 249 250 251 /** {@inheritDoc} */ 252 public String toString() { 253 return impl.toString(); 254 } 255 } 256 257 258 259 /** 260 * Managed object server implementation. 261 */ 262 private static class SaltedSHA256PasswordStorageSchemeCfgServerImpl implements 263 SaltedSHA256PasswordStorageSchemeCfg { 264 265 // Private implementation. 266 private ServerManagedObject<? extends SaltedSHA256PasswordStorageSchemeCfg> impl; 267 268 // The value of the "enabled" property. 269 private final boolean pEnabled; 270 271 // The value of the "java-class" property. 272 private final String pJavaClass; 273 274 275 276 // Private constructor. 277 private SaltedSHA256PasswordStorageSchemeCfgServerImpl(ServerManagedObject<? extends SaltedSHA256PasswordStorageSchemeCfg> impl) { 278 this.impl = impl; 279 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 280 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 281 } 282 283 284 285 /** 286 * {@inheritDoc} 287 */ 288 public void addSaltedSHA256ChangeListener( 289 ConfigurationChangeListener<SaltedSHA256PasswordStorageSchemeCfg> listener) { 290 impl.registerChangeListener(listener); 291 } 292 293 294 295 /** 296 * {@inheritDoc} 297 */ 298 public void removeSaltedSHA256ChangeListener( 299 ConfigurationChangeListener<SaltedSHA256PasswordStorageSchemeCfg> listener) { 300 impl.deregisterChangeListener(listener); 301 } 302 /** 303 * {@inheritDoc} 304 */ 305 public void addChangeListener( 306 ConfigurationChangeListener<PasswordStorageSchemeCfg> listener) { 307 impl.registerChangeListener(listener); 308 } 309 310 311 312 /** 313 * {@inheritDoc} 314 */ 315 public void removeChangeListener( 316 ConfigurationChangeListener<PasswordStorageSchemeCfg> listener) { 317 impl.deregisterChangeListener(listener); 318 } 319 320 321 322 /** 323 * {@inheritDoc} 324 */ 325 public boolean isEnabled() { 326 return pEnabled; 327 } 328 329 330 331 /** 332 * {@inheritDoc} 333 */ 334 public String getJavaClass() { 335 return pJavaClass; 336 } 337 338 339 340 /** 341 * {@inheritDoc} 342 */ 343 public Class<? extends SaltedSHA256PasswordStorageSchemeCfg> configurationClass() { 344 return SaltedSHA256PasswordStorageSchemeCfg.class; 345 } 346 347 348 349 /** 350 * {@inheritDoc} 351 */ 352 public DN dn() { 353 return impl.getDN(); 354 } 355 356 357 358 /** {@inheritDoc} */ 359 public String toString() { 360 return impl.toString(); 361 } 362 } 363}