Home » geronimo-2.2-source-release » org.apache.geronimo.security.jaspi » [javadoc | source]

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one
    3    * or more contributor license agreements.  See the NOTICE file
    4    * distributed with this work for additional information
    5    * regarding copyright ownership.  The ASF licenses this file
    6    * to you under the Apache License, Version 2.0 (the
    7    * "License"); you may not use this file except in compliance
    8    * with the License.  You may obtain a copy of the License at
    9    *
   10    *  http://www.apache.org/licenses/LICENSE-2.0
   11    *
   12    * Unless required by applicable law or agreed to in writing,
   13    * software distributed under the License is distributed on an
   14    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   15    * KIND, either express or implied.  See the License for the
   16    * specific language governing permissions and limitations
   17    * under the License.
   18    */
   19   
   20   
   21   package org.apache.geronimo.security.jaspi;
   22   
   23   import javax.security.auth.message.config.AuthConfigFactory;
   24   
   25   import org.apache.geronimo.gbean.annotation.ParamAttribute;
   26   import org.apache.geronimo.gbean.annotation.ParamSpecial;
   27   import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
   28   
   29   /**
   30    * Installs the specified AuthConfigFactory
   31    *
   32    * @version $Rev: 772462 $ $Date: 2009-05-06 15:57:58 -0700 (Wed, 06 May 2009) $
   33    */
   34   public class AuthConfigFactoryGBean {
   35   
   36       public AuthConfigFactoryGBean(@ParamAttribute(name = "authConfigFactoryClassName") final String authConfigFactoryClassName,
   37                                     @ParamSpecial(type = SpecialAttributeType.classLoader) ClassLoader classLoader) {
   38   
   39           Thread currentThread = Thread.currentThread();
   40           ClassLoader oldClassLoader = currentThread.getContextClassLoader();
   41           currentThread.setContextClassLoader(classLoader);
   42           try {
   43               java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {
   44                           public Object run() {
   45                               java.security.Security.setProperty(AuthConfigFactory.DEFAULT_FACTORY_SECURITY_PROPERTY, authConfigFactoryClassName);
   46                               return null;
   47                           }
   48                       });
   49   
   50               AuthConfigFactory.getFactory();
   51   
   52           } finally {
   53               currentThread.setContextClassLoader(oldClassLoader);
   54           }
   55   
   56       }
   57   }

Home » geronimo-2.2-source-release » org.apache.geronimo.security.jaspi » [javadoc | source]