Coverage Report - javax.security.auth.message.config.AuthConfigFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
AuthConfigFactory
0%
0/26
0%
0/10
1.444
AuthConfigFactory$1
0%
0/2
N/A
1.444
AuthConfigFactory$2
0%
0/2
N/A
1.444
AuthConfigFactory$3
0%
0/2
N/A
1.444
AuthConfigFactory$RegistrationContext
N/A
N/A
1.444
 
 1  
 /**
 2  
  *  Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  *  contributor license agreements.  See the NOTICE file distributed with
 4  
  *  this work for additional information regarding copyright ownership.
 5  
  *  The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  *  (the "License"); you may not use this file except in compliance with
 7  
  *  the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *     http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  *  Unless required by applicable law or agreed to in writing, software
 12  
  *  distributed under the License is distributed on an "AS IS" BASIS,
 13  
  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  *  See the License for the specific language governing permissions and
 15  
  *  limitations under the License.
 16  
  */
 17  
 package javax.security.auth.message.config;
 18  
 
 19  
 import java.security.PrivilegedActionException;
 20  
 import java.util.Map;
 21  
 
 22  
 import javax.security.auth.AuthPermission;
 23  
 import javax.security.auth.message.AuthException;
 24  
 
 25  
 /**
 26  
  * @version $Rev: 780105 $ $Date: 2009-05-29 13:42:00 -0700 (Fri, 29 May 2009) $
 27  
  */
 28  0
 public abstract class AuthConfigFactory {
 29  
 
 30  
     public static final String DEFAULT_FACTORY_SECURITY_PROPERTY = "authconfigprovider.factory";
 31  
     private static final String DEFAULT_JASPI_AUTHCONFIGFACTORYIMPL = "org.apache.geronimo.components.jaspi.AuthConfigFactoryImpl";
 32  
 
 33  
     private static AuthConfigFactory factory;
 34  
     private static ClassLoader contextClassLoader;
 35  
 
 36  
     static {
 37  0
         contextClassLoader = (ClassLoader) java.security.AccessController
 38  0
                 .doPrivileged(new java.security.PrivilegedAction() {
 39  
                     public Object run() {
 40  0
                         return Thread.currentThread().getContextClassLoader();
 41  
                     }
 42  
                 });
 43  0
     }
 44  
 
 45  
     public static AuthConfigFactory getFactory() {
 46  0
         SecurityManager sm = System.getSecurityManager();
 47  0
         if (sm != null) {
 48  0
             sm.checkPermission(new AuthPermission("getAuthConfigFactory"));
 49  
         }
 50  0
         if (factory == null) {
 51  0
             String className = (String) java.security.AccessController
 52  0
                     .doPrivileged(new java.security.PrivilegedAction() {
 53  
                         public Object run() {
 54  0
                             return java.security.Security.getProperty(DEFAULT_FACTORY_SECURITY_PROPERTY);
 55  
                         }
 56  
                     });
 57  0
             if (className == null) {
 58  0
                 className = DEFAULT_JASPI_AUTHCONFIGFACTORYIMPL;
 59  
             }
 60  
             try {
 61  0
                 final String finalClassName = className;
 62  0
                 factory = (AuthConfigFactory) java.security.AccessController
 63  0
                         .doPrivileged(new java.security.PrivilegedExceptionAction() {
 64  
                             public Object run() throws ClassNotFoundException, InstantiationException,
 65  
                                     IllegalAccessException {
 66  0
                                 return Class.forName(finalClassName, true, contextClassLoader).newInstance();
 67  
                             }
 68  
                         });
 69  0
             } catch (PrivilegedActionException e) {
 70  0
                 Exception inner = e.getException();
 71  0
                 if (inner instanceof InstantiationException) {
 72  0
                     throw (SecurityException) new SecurityException("AuthConfigFactory error:"
 73  
                             + inner.getCause().getMessage()).initCause(inner.getCause());
 74  
                 } else {
 75  0
                     throw (SecurityException) new SecurityException("AuthConfigFactory error: " + inner).initCause(inner);
 76  
                 }
 77  0
             }
 78  
         }
 79  0
         return factory;
 80  
     }
 81  
 
 82  
     public static void setFactory(AuthConfigFactory factory) {
 83  0
         SecurityManager sm = System.getSecurityManager();
 84  0
         if (sm != null) {
 85  0
             sm.checkPermission(new AuthPermission("setAuthConfigFactory"));
 86  
         }
 87  0
         AuthConfigFactory.factory = factory;
 88  0
     }
 89  
 
 90  
 
 91  0
     public AuthConfigFactory() {
 92  0
     }
 93  
 
 94  
     public abstract String[] detachListener(RegistrationListener listener, String layer, String appContext);
 95  
 
 96  
     public abstract AuthConfigProvider getConfigProvider(String layer, String appContext, RegistrationListener listener);
 97  
 
 98  
     public abstract RegistrationContext getRegistrationContext(String registrationID);
 99  
 
 100  
     public abstract String[] getRegistrationIDs(AuthConfigProvider provider);
 101  
 
 102  
     public abstract void refresh();
 103  
 
 104  
     public abstract String registerConfigProvider(AuthConfigProvider provider, String layer, String appContext, String description);
 105  
 
 106  
     public abstract String registerConfigProvider(String className, Map properties, String layer, String appContext, String description);
 107  
 
 108  
     public abstract boolean removeRegistration(String registrationID);
 109  
 
 110  
     public static interface RegistrationContext {
 111  
 
 112  
         String getAppContext();
 113  
 
 114  
         String getDescription();
 115  
 
 116  
         String getMessageLayer();
 117  
 
 118  
         boolean isPersistent();
 119  
 
 120  
     }
 121  
 
 122  
 }