0N/A/*
2362N/A * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.security.provider;
0N/A
0N/Aimport java.security.AccessController;
0N/Aimport java.security.PrivilegedAction;
0N/Aimport java.security.URIParameter;
0N/A
0N/Aimport javax.security.auth.login.Configuration;
0N/Aimport javax.security.auth.login.ConfigurationSpi;
0N/Aimport javax.security.auth.login.AppConfigurationEntry;
0N/A
0N/Aimport com.sun.security.auth.login.ConfigFile;
0N/A
0N/A/**
0N/A * This class wraps the ConfigFile subclass implementation of Configuration
0N/A * inside a ConfigurationSpi implementation that is available from the
0N/A * SUN provider via the Configuration.getInstance calls.
0N/A *
0N/A */
0N/Apublic final class ConfigSpiFile extends ConfigurationSpi {
0N/A
0N/A private ConfigFile cf;
0N/A
0N/A public ConfigSpiFile(final Configuration.Parameters params)
0N/A throws java.io.IOException {
0N/A
0N/A // call in a doPrivileged
0N/A //
0N/A // we have already passed the Configuration.getInstance
0N/A // security check. also this class is not freely accessible
0N/A // (it is in the "sun" package).
0N/A //
0N/A // we can not put doPrivileged calls into
0N/A // ConfigFile because it is a public com.sun class
0N/A
0N/A try {
0N/A AccessController.doPrivileged(new PrivilegedAction<Void>() {
0N/A public Void run() {
0N/A if (params == null) {
0N/A cf = new ConfigFile();
0N/A } else {
0N/A if (!(params instanceof URIParameter)) {
0N/A throw new IllegalArgumentException
0N/A ("Unrecognized parameter: " + params);
0N/A }
0N/A URIParameter uriParam = (URIParameter)params;
0N/A
0N/A cf = new ConfigFile(uriParam.getURI());
0N/A }
0N/A return null;
0N/A }
0N/A });
0N/A } catch (SecurityException se) {
0N/A
0N/A // if ConfigFile threw a standalone SecurityException
0N/A // (no cause), re-throw it.
0N/A //
0N/A // ConfigFile chains checked IOExceptions to SecurityException.
0N/A
0N/A Throwable cause = se.getCause();
0N/A if (cause != null && cause instanceof java.io.IOException) {
0N/A throw (java.io.IOException)cause;
0N/A }
0N/A
0N/A // unrecognized cause
0N/A throw se;
0N/A }
0N/A
0N/A // if ConfigFile throws some other RuntimeException,
0N/A // let it percolate up naturally.
0N/A }
0N/A
0N/A protected AppConfigurationEntry[] engineGetAppConfigurationEntry
0N/A (String name) {
0N/A return cf.getAppConfigurationEntry(name);
0N/A }
0N/A
0N/A protected void engineRefresh() {
0N/A cf.refresh();
0N/A }
0N/A}