8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * opensso/legal/CDDLv1.0.txt
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * at opensso/legal/CDDLv1.0.txt.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: IdOperation.java,v 1.4 2008/06/25 05:43:28 qcheng Exp $
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpackage com.sun.identity.idm;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The class <code>IdOperation</code> defines the types of operations
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * supported on managed identities, and provides static constants for these
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * operation. Currently defined operations on objects are
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>IdOperation.READ</code>, <code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * IdOperation.EDIT</code>, <code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * IdOperation.CREATE</code>,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code> IdOperation.DELETE
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * </code> and <code> IdOperation.SERVICE </code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The usage of the respective operations are defined along with their
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * declaration.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @supported.all.api
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublic class IdOperation {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String op;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Constructs an IdOperation of type string
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public IdOperation(String operation) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster op = operation;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code> READ </code> operation is supported by default for all
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * supported identities for all the plugins. This operation means that the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code> IdRepo SPI </code> for the configured plugins related to reading
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * identity attributes will be invoked.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final IdOperation READ = new IdOperation("read");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code> EDIT </code> operation is supported only for the plugins
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * configured for modifying and deleting attributes from the supported
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * identities. This means that the <code> IdRepo SPI
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * </code> for the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * configured plugins will be called for all modify attribute operations.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final IdOperation EDIT = new IdOperation("edit");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code> CREATE </code> operation is supported only for the plugins
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * configured for creating identities. Not all the configured identities for
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * a given <code> IdRepo plugin </code> might be supported. It is possible
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * that a plugin might support read operations on all <code> IdType </code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * but create operations only on the <code> IdType.USER </code>. In this
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * case the create operation for that plugin is only called for user
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * identities.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final IdOperation CREATE = new IdOperation("create");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code> DELETE </code> operation is supported only for the plugins
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * configured for creating identities. Not all the configured identities for
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * a given <code> IdRepo plugin </code> might be supported. It is possible
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * that a plugin might support read operations on all <code> IdType </code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * but create or delete operations only on the <code> IdType.USER </code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * In this case the delete operation for that plugin is only called for user
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * identities.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final IdOperation DELETE = new IdOperation("delete");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code> SERVICE </code> operation is supported only for service
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * related functions on an identity. Not all the configured identities for a
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * plugin might support services for all identities. It is possible that
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * service operations are supported only for one identity type for a plugin,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * say <code> IdType.USER </code>. In this case, all service related
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * operations like assignService, unassignService, modifyService etc. are
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * only called for user objects for that plugin.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final IdOperation SERVICE = new IdOperation("service");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code> equals </code> method compares the current IdOperation with
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the IdOperation passed in and returns true if the operations are same.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * it will return false if the operations are different.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param opObject
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * an IdOperation
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>true</code> if name opObject is same
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * else <code>false</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean equals(Object opObject) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (opObject instanceof IdOperation) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (((IdOperation) opObject).op.equalsIgnoreCase(this.op));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (false);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code> toString </code> method returns the same representation of
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the current IdOperation. The string returned is preceeded by the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the substring "Operation: ". For example: if the current IdOperation
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * is "CREATE" toString will return "Operation: create".
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * String representaton of IdOperation.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String toString() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return ("Operation: " + op);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the hash code of the object
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * int hash code of IdOperation.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public int hashCode() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return op.hashCode();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code> getName </code> method returns the name of the IdOperation
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * in string representaion. For example if the current IdOperation
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * is "CREATE" getName will return "create".
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * String name of IdOperation.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getName() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return op;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster}