All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.unboundid.scim.data.ChangePasswordConfig Maven / Gradle / Ivy

Go to download

The UnboundID SCIM SDK is a library that may be used to interact with various types of SCIM-enabled endpoints (such as the UnboundID server products) to perform lightweight, cloud-based identity management via the SCIM Protocol. See http://www.simplecloud.info for more information.

There is a newer version: 1.8.26
Show newest version
/*
 * Copyright 2011-2019 Ping Identity Corporation
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License (GPLv2 only)
 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see .
 */

package com.unboundid.scim.data;

import com.unboundid.scim.schema.AttributeDescriptor;
import com.unboundid.scim.sdk.InvalidResourceException;
import com.unboundid.scim.sdk.SCIMAttribute;
import com.unboundid.scim.sdk.SCIMAttributeValue;

import java.util.ArrayList;
import java.util.List;



/**
 * A complex type that specifies Change Password configuration options.
 */
public class ChangePasswordConfig
{
  private final boolean supported;



  /**
   * The AttributeValueResolver that resolves SCIM attribute values
   * to/from ChangePasswordConfig instances.
   */
  public static final AttributeValueResolver
      CHANGE_PASSWORD_CONFIG_RESOLVER =
      new AttributeValueResolver()
      {
        /**
         * {@inheritDoc}
         */
        @Override
        public ChangePasswordConfig toInstance(final SCIMAttributeValue value) {
          return new ChangePasswordConfig(
              value.getSubAttributeValue("supported",
                  BOOLEAN_RESOLVER));
        }

        /**
         * {@inheritDoc}
         */
        @Override
        public SCIMAttributeValue fromInstance(
            final AttributeDescriptor attributeDescriptor,
            final ChangePasswordConfig value)
            throws InvalidResourceException
        {
          final List subAttributes =
              new ArrayList(1);

          final AttributeDescriptor supportedDescriptor =
              attributeDescriptor.getSubAttribute("supported");
          subAttributes.add(
              SCIMAttribute.create(
                  supportedDescriptor,
                  BOOLEAN_RESOLVER.fromInstance(supportedDescriptor,
                      value.supported)));

          return SCIMAttributeValue.createComplexValue(subAttributes);
        }
      };



  /**
   * Create a ChangePasswordConfig instance.
   *
   * @param supported  Specifies whether the Change Password operation is
   *                   supported.
   */
  public ChangePasswordConfig(final boolean supported)
  {
    this.supported = supported;
  }



  /**
   * Indicates whether the Change Password operation is supported.
   * @return  {@code true} if the Change Password operation is supported.
   */
  public boolean isSupported()
  {
    return supported;
  }



  @Override
  public boolean equals(final Object o)
  {
    if (this == o)
    {
      return true;
    }
    if (o == null || getClass() != o.getClass())
    {
      return false;
    }

    final ChangePasswordConfig that = (ChangePasswordConfig) o;

    if (supported != that.supported)
    {
      return false;
    }

    return true;
  }



  @Override
  public int hashCode()
  {
    return (supported ? 1 : 0);
  }



  @Override
  public String toString()
  {
    final StringBuilder sb = new StringBuilder();
    sb.append("ChangePasswordConfig");
    sb.append("{supported=").append(supported);
    sb.append('}');
    return sb.toString();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy