151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski/*
251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * This code is free software; you can redistribute it and/or modify it
651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * under the terms of the GNU General Public License version 2 only, as
751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * published by the Free Software Foundation.  Oracle designates this
851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * particular file as subject to the "Classpath" exception as provided
951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * by Oracle in the LICENSE file that accompanied this code.
1051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
1151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * This code is distributed in the hope that it will be useful, but WITHOUT
1251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * version 2 for more details (a copy is included in the LICENSE file that
1551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * accompanied this code).
1651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
1751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * You should have received a copy of the GNU General Public License version
1851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 2 along with this work; if not, write to the Free Software Foundation,
1951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
2151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * or visit www.oracle.com if you need additional information or have any
2351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * questions.
2451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */
2551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
2651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskipackage sun.security.action;
2751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
2851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski/**
2951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * A convenience class for retrieving the boolean value of a system property
3051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * as a privileged action.
3151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
3251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>An instance of this class can be used as the argument of
3351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>AccessController.doPrivileged</code>.
3451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
3551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>The following code retrieves the boolean value of the system
3651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * property named <code>"prop"</code> as a privileged action: <p>
3751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
3851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <pre>
3951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * boolean b = java.security.AccessController.doPrivileged
4051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *              (new GetBooleanAction("prop")).booleanValue();
4151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * </pre>
4251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
4351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @author Roland Schemers
4451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see java.security.PrivilegedAction
4551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see java.security.AccessController
4651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.2
4751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */
4851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
4951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskipublic class GetBooleanAction
5051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski        implements java.security.PrivilegedAction<Boolean> {
5151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    private String theProp;
5251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
5351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    /**
5451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * Constructor that takes the name of the system property whose boolean
5551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * value needs to be determined.
5651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     *
5751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * @param theProp the name of the system property.
5851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     */
5951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    public GetBooleanAction(String theProp) {
6051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski        this.theProp = theProp;
6151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    }
6251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
6351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    /**
6451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * Determines the boolean value of the system property whose name was
6551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * specified in the constructor.
6651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     *
6751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * @return the <code>Boolean</code> value of the system property.
6851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     */
6951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    public Boolean run() {
7051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski        return Boolean.getBoolean(theProp);
7151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    }
7251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski}
73