823N/A/*
823N/A * CDDL HEADER START
823N/A *
823N/A * The contents of this file are subject to the terms of the
823N/A * Common Development and Distribution License, Version 1.0 only
823N/A * (the "License"). You may not use this file except in compliance
823N/A * with the License.
823N/A *
823N/A * You can obtain a copy of the license at
823N/A * trunk/opends/resource/legal-notices/OpenDS.LICENSE
823N/A * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
823N/A * See the License for the specific language governing permissions
823N/A * and limitations under the License.
823N/A *
823N/A * When distributing Covered Code, include this CDDL HEADER in each
823N/A * file and include the License file at
823N/A * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
823N/A * add the following below this CDDL HEADER, with the fields enclosed
873N/A * by brackets "[]" replaced with your own identifying information:
823N/A * Portions Copyright [yyyy] [name of copyright owner]
823N/A *
823N/A * CDDL HEADER END
823N/A *
823N/A *
3215N/A * Copyright 2008 Sun Microsystems, Inc.
823N/A */
823N/A
823N/Apackage org.opends.server.authorization.dseecompat;
823N/A
823N/A/**
823N/A * This class provides an enumeration of the two access
823N/A * types (allow, deny).
823N/A */
823N/Apublic enum EnumAccessType {
897N/A
823N/A /**
823N/A * Allow access type.
823N/A */
823N/A ALLOW ("allow"),
823N/A /**
823N/A * Deny access type.
823N/A */
823N/A DENY ("deny");
823N/A
897N/A /*
897N/A * The access type string.
897N/A */
823N/A private final String accessType;
823N/A
823N/A /**
823N/A * Constructor that sets the accessType string.
823N/A * @param accessType The access type string to set.
823N/A */
823N/A EnumAccessType (String accessType){
823N/A this.accessType = accessType ;
823N/A }
823N/A
823N/A /**
823N/A * Checks if the access type is equal to the string
823N/A * representation passed in.
823N/A * @param type The string representation of the access type.
823N/A * @return True if the access types are equal.
823N/A */
823N/A public boolean isAccessType(String type){
823N/A return type.equalsIgnoreCase(accessType);
823N/A }
823N/A
823N/A /*
823N/A * TODO Make this method and all other Enum decode methods more efficient.
823N/A *
823N/A * Using the Enum.values() method is documented to be potentially slow.
823N/A * If we ever expect to use the decode() method in a performance-critical
823N/A * manner, then we should make it more efficient. The same thing applies
823N/A * to all of the other enumeration types defined in the package.
823N/A */
823N/A /**
823N/A * Decodes an access type enumeration from a string passed into the method.
823N/A * @param type The string representation of the access type.
823N/A * @return Return an EnumAccessType matching the string representation,
823N/A * or null if the string is not valid.
823N/A */
823N/A public static EnumAccessType decode(String type){
823N/A if (type != null){
823N/A for (EnumAccessType t : EnumAccessType.values()) {
823N/A if (t.isAccessType(type)){
823N/A return t;
823N/A }
823N/A }
823N/A }
823N/A return null;
823N/A }
823N/A}