Package org.nasutekds.arisid

Source Code of org.nasutekds.arisid.ArisIDPrivacyControlPlugin

/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License").  You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* trunk/nasutekds/resource/legal-notices/NasuTekDS.LICENSE
* or https://NasuTekDS.dev.java.net/NasuTekDS.LICENSE.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/nasutekds/resource/legal-notices/NasuTekDS.LICENSE.  If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
*      Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
*      Copyright 2010 Sun Microsystems, Inc.
*/
package org.nasutekds.arisid;



import java.util.Set;

import org.nasutekds.arisid.server.ArisidPrivacyControlPluginCfg;
import org.nasutekds.messages.Message;
import org.nasutekds.server.api.plugin.DirectoryServerPlugin;
import org.nasutekds.server.api.plugin.PluginResult;
import org.nasutekds.server.api.plugin.PluginType;
import org.nasutekds.server.config.ConfigException;
import org.nasutekds.server.loggers.ErrorLogger;
import org.nasutekds.server.types.CanceledOperationException;
import org.nasutekds.server.types.operation.*;



/**
* IGF ArisID Privacy Control Plugin implementation.
*/
public final class ArisIDPrivacyControlPlugin extends
    DirectoryServerPlugin<ArisidPrivacyControlPluginCfg>
{
  /**
   * {@inheritDoc}
   */
  @Override
  public PluginResult.PreOperation doPreOperation(
      PreOperationAddOperation addOperation)
      throws CanceledOperationException
  {
    handleOperation(addOperation);
    return PluginResult.PreOperation.continueOperationProcessing();
  }



  /**
   * {@inheritDoc}
   */
  @Override
  public PluginResult.PreOperation doPreOperation(
      PreOperationCompareOperation compareOperation)
      throws CanceledOperationException
  {
    handleOperation(compareOperation);
    return PluginResult.PreOperation.continueOperationProcessing();
  }



  /**
   * {@inheritDoc}
   */
  @Override
  public PluginResult.PreOperation doPreOperation(
      PreOperationDeleteOperation deleteOperation)
      throws CanceledOperationException
  {
    handleOperation(deleteOperation);
    return PluginResult.PreOperation.continueOperationProcessing();
  }



  /**
   * {@inheritDoc}
   */
  @Override
  public PluginResult.PreOperation doPreOperation(
      PreOperationExtendedOperation extendedOperation)
      throws CanceledOperationException
  {
    handleOperation(extendedOperation);
    return PluginResult.PreOperation.continueOperationProcessing();
  }



  /**
   * {@inheritDoc}
   */
  @Override
  public PluginResult.PreOperation doPreOperation(
      PreOperationModifyDNOperation modifyDNOperation)
      throws CanceledOperationException
  {
    handleOperation(modifyDNOperation);
    return PluginResult.PreOperation.continueOperationProcessing();
  }



  /**
   * {@inheritDoc}
   */
  @Override
  public PluginResult.PreOperation doPreOperation(
      PreOperationModifyOperation modifyOperation)
      throws CanceledOperationException
  {
    handleOperation(modifyOperation);
    return PluginResult.PreOperation.continueOperationProcessing();
  }



  /**
   * {@inheritDoc}
   */
  @Override
  public PluginResult.PreOperation doPreOperation(
      PreOperationSearchOperation searchOperation)
      throws CanceledOperationException
  {
    handleOperation(searchOperation);
    return PluginResult.PreOperation.continueOperationProcessing();
  }



  /**
   * {@inheritDoc}
   */
  @Override()
  public void initializePlugin(Set<PluginType> pluginTypes,
      ArisidPrivacyControlPluginCfg configuration)
      throws ConfigException
  {
    // This plugin may only be used as a pre-operation plugin.
    for (final PluginType t : pluginTypes)
    {
      switch (t)
      {
      case PRE_OPERATION_ADD:
      case PRE_OPERATION_COMPARE:
      case PRE_OPERATION_DELETE:
      case PRE_OPERATION_EXTENDED:
      case PRE_OPERATION_MODIFY:
      case PRE_OPERATION_MODIFY_DN:
      case PRE_OPERATION_SEARCH:
        // This is fine.
        break;
      default:
        throw new ConfigException(Message.raw("Invalid plugin type "
            + t + " for the IGF plugin."));
      }
    }

  }



  private void handleOperation(PreOperationOperation op)
  {
    try
    {
      final ArisIDPrivacyControl control = op
          .getRequestControl(ArisIDPrivacyControl.DECODER);
      if (control != null)
      {
        ErrorLogger.logError(Message.raw(control.toString()));
      }
    }
    catch (final Exception e)
    {
      ErrorLogger.logError(Message
          .raw("Unable to decode the IGF privacy" + " control:  " + e));
    }
  }
}
TOP

Related Classes of org.nasutekds.arisid.ArisIDPrivacyControlPlugin

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.