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: AdminDNAction.java,v 1.5 2008/08/19 19:09:20 veiming Exp $
026 *
027 */
028
029package com.sun.identity.security;
030
031import java.security.PrivilegedAction;
032
033import com.iplanet.am.util.AdminUtils;
034
035/**
036 * The class is used to perform privileged operations using
037 * <code>java.security.AccessController.doPrivileged()
038 * </code> when using
039 * <code> com.iplanet.am.util.AdminUtils</code> to obtain Administrator DN.
040 * This class implements the interface <code>
041 * java.security.PrivilegedAction </code>
042 * with a non-default constructor. This class should be used in order to perform
043 * the privileged operation of
044 * <code> com.iplanet.am.util.AdminUtils.getAdminDN()</code>.
045 * 
046 * <PRE>
047 * 
048 * This line of code: String adminDN =
049 * com.iplanet.am.util.AdminUtils.getAdminDN(); should be replaced with: String
050 * adminDN = (String) AccessController.doPrivileged( new AdminDNAction()); If
051 * this is not done and Java security permissions check is enabled, then the
052 * operation will fail and return a null everytime.
053 * 
054 * Note: Java security permissions check for OpenSSO can be enabled
055 * by setting the property <code>com.sun.identity.security.checkcaller</code> to
056 * true in AMConfig properties file.
057 * 
058 * </PRE>
059 * 
060 * @supported.all.api
061 */
062public class AdminDNAction implements PrivilegedAction {
063
064    /**
065     * Default constructor
066     */
067    public AdminDNAction() {
068        super();
069    }
070
071    /*
072     * (non-Javadoc)
073     * 
074     * @see java.security.PrivilegedAction#run()
075     */
076    public Object run() {
077        return (AdminUtils.getAdminDN());
078    }
079
080}




























































Copyright © 2010-2017, ForgeRock All Rights Reserved.