1 /* Copyright (C) 2000 Free Software Foundation
3 This file is part of libgcj.
5 This software is copyrighted work licensed under the terms of the
6 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
11 import java.util.Enumeration;
12 import java.util.Properties;
13 import java.util.Vector;
16 * @author Tom Tromey <tromey@cygnus.com>
17 * @date February 8, 2000.
21 * Written using on-line Java Platform 1.2 API Specification.
22 * Status: Still missing the deprecated getAlgorithmProperty method.
25 public final class Security
27 public static int insertProviderAt (Provider provider, int position)
29 SecurityManager sm = System.getSecurityManager ();
32 // FIXME: need SecurityPermission.
33 // sm.checkSecurityAccess ("insertProvider." + provider.getName ());
35 if (providers.indexOf (provider) != -1)
37 if (position > providers.size ())
38 position = providers.size ();
39 providers.insertElementAt (provider, position);
40 return providers.indexOf (provider);
43 public static int addProvider (Provider provider)
45 return insertProviderAt (provider, providers.size ());
48 public static void removeProvider (String name)
50 SecurityManager sm = System.getSecurityManager ();
53 // FIXME: need SecurityPermission.
54 // sm.checkSecurityAccess ("removeProvider." + name);
56 Provider p = getProvider (name);
58 providers.removeElement (p);
61 public static Provider[] getProviders ()
63 Provider[] r = new Provider[providers.size ()];
64 providers.copyInto (r);
68 public static Provider getProvider (String name)
70 Enumeration e = providers.elements ();
71 while (e.hasMoreElements ())
73 Provider p = (Provider) e.nextElement ();
74 if (name.equals (p.getName ()))
80 public static String getProperty (String key)
82 SecurityManager sm = System.getSecurityManager ();
85 // FIXME: need SecurityPermission.
86 // sm.checkSecurityAccess ("getProperty." + key);
88 return props.getProperty (key);
91 public static void setProperty (String key, String value)
93 SecurityManager sm = System.getSecurityManager ();
96 // FIXME: need SecurityPermission.
97 // sm.checkSecurityAccess ("setProperty." + key);
99 props.setProperty (key, value);
102 // The providers we list.
103 private static Vector providers = new Vector ();
105 // Security propertiesl
106 private static Properties props = new Properties ();