001/**
002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003 *
004 * Copyright (c) 2007 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: SecurityPrincipal.java,v 1.6 2009/05/20 03:32:10 mallas Exp $
026 *
027 */
028
029package com.sun.identity.wss.security;
030
031import java.io.Serializable;
032import  java.security.Principal;
033
034/**
035 * This class <code>SecurityPrincipal</code> exposes the authenticated
036 * principal via the message level security.
037 * It implements <code>Principal</code> and <code>Serializable</code>
038 * interfaces.
039 * 
040 * @supported.all.api
041 */
042public class SecurityPrincipal implements Principal, Serializable {
043
044    private String name;
045
046    /**
047     * Constructs SecurityPrincipal object.
048     * @param name the name of the principal
049     */
050    public SecurityPrincipal(String name) {
051        this.name = name;
052    }
053
054    /**
055     * Compares with given object.
056     * @param o the given object
057     * @return false if the given object is not equal to this principal.
058     */
059    public boolean equals(Object o) {
060        if(this == o) {
061           return true;
062        } else if (o == null || getClass() != o.getClass()) {
063            return false;
064        }
065        
066        if(name == null) {
067           return false;
068        }
069        return name.equals(((SecurityPrincipal)o).getName());        
070       
071    }
072
073    /**
074     * Returns the name of the principal.
075     * @return the name of the principal.
076     */
077    public String getName() {
078        return name;
079    }
080
081    /**
082     * Converts to string.
083     * @return String the principal name string.
084     */
085    public String toString() {
086       return name;
087    }
088}




























































Copyright © 2010-2017, ForgeRock All Rights Reserved.