001/**
002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003 *
004 * Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
005 *
006 * The contents of this file are subject to the terms
007 * of the Common Development and Distribution License
008 * (the License). You may not use this file except in
009 * compliance with the License.
010 *
011 * You can obtain a copy of the License at
012 * https://opensso.dev.java.net/public/CDDLv1.0.html or
013 * opensso/legal/CDDLv1.0.txt
014 * See the License for the specific language governing
015 * permission and limitations under the License.
016 *
017 * When distributing Covered Code, include this CDDL
018 * Header Notice in each file and include the License file
019 * at opensso/legal/CDDLv1.0.txt.
020 * If applicable, add the following below the CDDL Header,
021 * with the fields enclosed by brackets [] replaced by
022 * your own identifying information:
023 * "Portions Copyrighted [year] [name of copyright owner]"
024 *
025 * $Id: IdType.java,v 1.9 2008/08/19 19:09:10 veiming Exp $
026 *
027 */
028
029package com.sun.identity.idm;
030
031import java.util.Collections;
032import java.util.Set;
033
034/**
035 * The class <code>IdType</code> defines the types of supported identities,
036 * and provides static constants for these identities. Currently defined
037 * identities are <code>IdType.USER</code>, <code>IdType.ROLE</code>,
038 * <code>IdType.GROUP</code> and <code>IdType.AGENT</code>. The usage of
039 * the respective types are defined along with their declaration.
040 *
041 * @supported.all.api
042 */
043public class IdType implements java.io.Serializable {
044    private String idType;
045
046    protected IdType(String type) {
047        idType = type;
048    }
049
050    /**
051     * Identity type of USER
052     */
053    public static final IdType USER = new IdType("user");
054
055    /**
056     * Identity type of ROLE
057     */
058    public static final IdType ROLE = new IdType("role");
059
060    /**
061     * Identity type of GROUP
062     */
063    public static final IdType GROUP = new IdType("group");
064
065    /**
066     * Identity type of AGENT
067     * Also from OpenSSO 8.0 onwards, this is the Identity type of
068     * the union of agents and those under the agent groups.
069     */
070    public static final IdType AGENT = new IdType("agent");
071
072    /**
073     * Identity type of filter role.
074     */
075    public static final IdType FILTEREDROLE = new IdType("filteredrole");
076
077    public static final IdType REALM = new IdType("realm");
078
079    /**
080     * Identity type of OpenSSO agent only.
081     */
082    public static final IdType AGENTONLY = new IdType("agentonly");
083
084    /**
085     * Identity type of OpenSSO agents under the OpenSSO
086     * agent groups.
087     */
088    public static final IdType AGENTGROUP = new IdType("agentgroup");
089
090    public boolean equals(Object type) {
091        if (type instanceof IdType) {
092            return (((IdType) type).idType.equalsIgnoreCase(this.idType));
093        }
094        return (false);
095    }
096
097    public String toString() {
098        return ("IdType: " + idType);
099    }
100
101    /**
102     * Returns the hash code of the object
103     */
104    public int hashCode() {
105        return idType.hashCode();
106    }
107
108    /**
109     * Returns the name of this type, for example <code> user </code> for type
110     * User.
111     * 
112     * @return Name of the this type.
113     */
114    public String getName() {
115        return idType;
116    }
117
118    /**
119     * Returns a set of types of identities this type can hav as its' members.
120     * 
121     * @return Set of <code>IdType</code> which can be members of this
122     *         identity type.
123     */
124    public Set canHaveMembers() {
125        Set results = (Set) IdUtils.typesCanHaveMembers.get(getName());
126        return (results == null) ? Collections.EMPTY_SET : results;
127    }
128
129    /**
130     * Returns a set of types of identities that this type can be a member of.
131     * 
132     * @return Set of <code>IdType</code>.
133     */
134    public Set canBeMemberOf() {
135        Set results = (Set) IdUtils.typesCanBeMemberOf.get(getName());
136        return (results == null) ? Collections.EMPTY_SET : results;
137    }
138
139    /**
140     * Returns a set of types of identities that this type can add as members.
141     * 
142     * @return Set of <code>IdType</code>.
143     */
144    public Set canAddMembers() {
145        Set results = (Set) IdUtils.typesCanAddMembers.get(getName());
146        return (results == null) ? Collections.EMPTY_SET : results;
147    }
148}




























































Copyright © 2010-2017, ForgeRock All Rights Reserved.