001/*
002 * Copyright 2011-2016 UnboundID Corp.
003 *
004 * This program is free software; you can redistribute it and/or modify
005 * it under the terms of the GNU General Public License (GPLv2 only)
006 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
007 * as published by the Free Software Foundation.
008 *
009 * This program is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012 * GNU General Public License for more details.
013 *
014 * You should have received a copy of the GNU General Public License
015 * along with this program; if not, see <http://www.gnu.org/licenses>.
016 */
017
018package com.unboundid.scim.data;
019
020import com.unboundid.scim.schema.ResourceDescriptor;
021import com.unboundid.scim.sdk.InvalidResourceException;
022import com.unboundid.scim.sdk.SCIMConstants;
023import com.unboundid.scim.sdk.SCIMObject;
024
025import java.util.Collection;
026
027
028
029/**
030 * This class represents the SCIM Service Provider Configuration.
031 */
032public class ServiceProviderConfig extends BaseResource
033{
034  /**
035   * A <code>ResourceFactory</code> for creating
036   * <code>ServiceProviderConfig</code> instances.
037   */
038  public static final ResourceFactory<ServiceProviderConfig>
039      SERVICE_PROVIDER_CONFIG_RESOURCE_FACTORY =
040      new ResourceFactory<ServiceProviderConfig>() {
041    public ServiceProviderConfig createResource(
042        final ResourceDescriptor resourceDescriptor,
043        final SCIMObject scimObject) {
044      return new ServiceProviderConfig(resourceDescriptor, scimObject);
045    }
046  };
047
048
049
050  /**
051   * Construct an empty <code>ServiceProviderConfig</code> with the specified
052   * <code>ResourceDescriptor</code>.
053   *
054   * @param resourceDescriptor The resource descriptor for this SCIM resource.
055   */
056  public ServiceProviderConfig(final ResourceDescriptor resourceDescriptor) {
057    super(resourceDescriptor);
058  }
059
060
061
062  /**
063   * Construct a <code>ServiceProviderConfig</code> with the specified
064   * <code>ResourceDescriptor</code> and backed by the given
065   * <code>SCIMObject</code>.
066   *
067   * @param resourceDescriptor The resource descriptor for this SCIM resource.
068   * @param scimObject         The <code>SCIMObject</code> containing all the
069   *                           SCIM attributes and their values.
070   */
071  public ServiceProviderConfig(final ResourceDescriptor resourceDescriptor,
072                               final SCIMObject scimObject) {
073    super(resourceDescriptor, scimObject);
074  }
075
076
077
078  /**
079   * Retrieves the PATCH configuration options.
080   *
081   * @return The PATCH configuration options.
082   */
083  public PatchConfig getPatchConfig()
084  {
085    return getSingularAttributeValue(SCIMConstants.SCHEMA_URI_CORE,
086        "patch", PatchConfig.PATCH_CONFIG_RESOLVER);
087  }
088
089
090
091  /**
092   * Specifies the PATCH configuration options.
093   *
094   * @param patchConfig The PATCH configuration options.
095   * @return this resource instance.
096   */
097  public ServiceProviderConfig setPatchConfig(final PatchConfig patchConfig)
098  {
099    try {
100      setSingularAttributeValue(SCIMConstants.SCHEMA_URI_CORE,
101          "patch", PatchConfig.PATCH_CONFIG_RESOLVER, patchConfig);
102    } catch (InvalidResourceException e) {
103      // This should never happen as these are core attributes...
104      throw new RuntimeException(e);
105    }
106    return this;
107  }
108
109
110
111  /**
112   * Retrieves the BULK configuration options.
113   *
114   * @return The BULK configuration options.
115   */
116  public BulkConfig getBulkConfig()
117  {
118    return getSingularAttributeValue(SCIMConstants.SCHEMA_URI_CORE,
119        "bulk", BulkConfig.BULK_CONFIG_RESOLVER);
120  }
121
122
123
124  /**
125   * Specifies the BULK configuration options.
126   *
127   * @param bulkConfig The BULK configuration options.
128   * @return this resource instance.
129   */
130  public ServiceProviderConfig setBulkConfig(final BulkConfig bulkConfig)
131  {
132    try {
133      setSingularAttributeValue(SCIMConstants.SCHEMA_URI_CORE,
134          "bulk", BulkConfig.BULK_CONFIG_RESOLVER, bulkConfig);
135    } catch (InvalidResourceException e) {
136      // This should never happen as these are core attributes...
137      throw new RuntimeException(e);
138    }
139    return this;
140  }
141
142
143
144  /**
145   * Retrieves the FILTER configuration options.
146   *
147   * @return The FILTER configuration options.
148   */
149  public FilterConfig getFilterConfig()
150  {
151    return getSingularAttributeValue(SCIMConstants.SCHEMA_URI_CORE,
152        "filter", FilterConfig.FILTER_CONFIG_RESOLVER);
153  }
154
155
156
157  /**
158   * Specifies the FILTER configuration options.
159   *
160   * @param filterConfig The FILTER configuration options.
161   * @return this resource instance.
162   */
163  public ServiceProviderConfig setFilterConfig(final FilterConfig filterConfig)
164  {
165    try {
166      setSingularAttributeValue(SCIMConstants.SCHEMA_URI_CORE,
167          "filter", FilterConfig.FILTER_CONFIG_RESOLVER, filterConfig);
168    } catch (InvalidResourceException e) {
169      // This should never happen as these are core attributes...
170      throw new RuntimeException(e);
171    }
172    return this;
173  }
174
175
176
177  /**
178   * Retrieves the Change Password configuration options.
179   *
180   * @return The Change Password configuration options.
181   */
182  public ChangePasswordConfig getChangePasswordConfig()
183  {
184    return getSingularAttributeValue(SCIMConstants.SCHEMA_URI_CORE,
185        "changePassword", ChangePasswordConfig.CHANGE_PASSWORD_CONFIG_RESOLVER);
186  }
187
188
189
190  /**
191   * Specifies the Change Password configuration options.
192   *
193   * @param changePasswordConfig The Change Password configuration options.
194   * @return this resource instance.
195   */
196  public ServiceProviderConfig setChangePasswordConfig(
197      final ChangePasswordConfig changePasswordConfig)
198  {
199    try {
200      setSingularAttributeValue(SCIMConstants.SCHEMA_URI_CORE,
201          "changePassword",
202          ChangePasswordConfig.CHANGE_PASSWORD_CONFIG_RESOLVER,
203          changePasswordConfig);
204    } catch (InvalidResourceException e) {
205      // This should never happen as these are core attributes...
206      throw new RuntimeException(e);
207    }
208    return this;
209  }
210
211
212
213  /**
214   * Retrieves the SORT configuration options.
215   *
216   * @return The SORT configuration options.
217   */
218  public SortConfig getSortConfig()
219  {
220    return getSingularAttributeValue(SCIMConstants.SCHEMA_URI_CORE,
221        "sort", SortConfig.SORT_CONFIG_RESOLVER);
222  }
223
224
225
226  /**
227   * Specifies the SORT configuration options.
228   *
229   * @param sortConfig The SORT configuration options.
230   * @return this resource instance.
231   */
232  public ServiceProviderConfig setSortConfig(final SortConfig sortConfig)
233  {
234    try {
235      setSingularAttributeValue(SCIMConstants.SCHEMA_URI_CORE,
236          "sort", SortConfig.SORT_CONFIG_RESOLVER, sortConfig);
237    } catch (InvalidResourceException e) {
238      // This should never happen as these are core attributes...
239      throw new RuntimeException(e);
240    }
241    return this;
242  }
243
244
245
246  /**
247   * Retrieves the ETag configuration options.
248   *
249   * @return The ETag configuration options.
250   */
251  public ETagConfig getETagConfig()
252  {
253    return getSingularAttributeValue(SCIMConstants.SCHEMA_URI_CORE,
254        "etag", ETagConfig.ETAG_CONFIG_RESOLVER);
255  }
256
257
258
259  /**
260   * Specifies the ETag configuration options.
261   *
262   * @param etagConfig The ETag configuration options.
263   * @return this resource instance.
264   */
265  public ServiceProviderConfig setETagConfig(final ETagConfig etagConfig)
266  {
267    try {
268      setSingularAttributeValue(SCIMConstants.SCHEMA_URI_CORE,
269          "etag", ETagConfig.ETAG_CONFIG_RESOLVER, etagConfig);
270    } catch (InvalidResourceException e) {
271      // This should never happen as these are core attributes...
272      throw new RuntimeException(e);
273    }
274    return this;
275  }
276
277
278
279  /**
280   * Retrieves the supported Authentication Schemes.
281   *
282   * @return The supported Authentication Schemes.
283   */
284  public Collection<AuthenticationScheme> getAuthenticationSchemes()
285  {
286    return getAttributeValues(
287        SCIMConstants.SCHEMA_URI_CORE,
288        "authenticationSchemes",
289        AuthenticationScheme.AUTHENTICATION_SCHEME_RESOLVER);
290  }
291
292
293
294  /**
295   * Sets the supported Authentication Schemes.
296   *
297   * @param authenticationSchemes The supported Authentication Schemes.
298   * @return this resource instance.
299   */
300  public ServiceProviderConfig setAuthenticationSchemes(
301      final Collection<AuthenticationScheme> authenticationSchemes)
302  {
303    try {
304      setAttributeValues(SCIMConstants.SCHEMA_URI_CORE,
305                         "authenticationSchemes",
306                         AuthenticationScheme.AUTHENTICATION_SCHEME_RESOLVER,
307                         authenticationSchemes);
308    } catch (InvalidResourceException e) {
309      // This should never happen as these are core attributes...
310      throw new RuntimeException(e);
311    }
312    return this;
313  }
314
315
316
317  /**
318   * Retrieves the XML data format configuration options.
319   *
320   * @return The XML data format configuration options.
321   */
322  public XmlDataFormatConfig getXmlDataFormatConfig()
323  {
324    return getSingularAttributeValue(
325        SCIMConstants.SCHEMA_URI_CORE,
326        "xmlDataFormat",
327        XmlDataFormatConfig.XML_DATA_FORMAT_CONFIG_RESOLVER);
328  }
329
330
331
332  /**
333   * Specifies the XML data format configuration options.
334   *
335   * @param xmlDataFormatConfig The XML data format configuration options.
336   * @return this resource instance.
337   */
338  public ServiceProviderConfig setXmlDataFormatConfig(
339      final XmlDataFormatConfig xmlDataFormatConfig)
340  {
341    try {
342      setSingularAttributeValue(
343          SCIMConstants.SCHEMA_URI_CORE,
344          "xmlDataFormat",
345          XmlDataFormatConfig.XML_DATA_FORMAT_CONFIG_RESOLVER,
346          xmlDataFormatConfig);
347    } catch (InvalidResourceException e) {
348      // This should never happen as these are core attributes...
349      throw new RuntimeException(e);
350    }
351    return this;
352  }
353}