All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sun.xml.wss.XWSSProcessorFactory Maven / Gradle / Ivy

There is a newer version: 4.0.4
Show newest version
/*
 * Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Distribution License v. 1.0, which is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

package com.sun.xml.wss;


import java.io.InputStream;
import javax.security.auth.callback.CallbackHandler;


/**
 *XWSSProcessorFactory is a factory for creating XWSSProcessor
 * Objects.
 * An XWSSProcessor Object can be used for
 *
    *
  • Securing an outbound SOAPMessage *
  • Verifying the security in an inbound SOAPMessage *
*/ public abstract class XWSSProcessorFactory { public static final String XWSS_PROCESSOR_FACTORY_PROPERTY = "com.sun.xml.wss.XWSSProcessorFactory"; public static final String DEFAULT_XWSS_PROCESSOR_FACTORY = "com.sun.xml.wss.impl.misc.XWSSProcessorFactory2_0Impl"; /** * Default constructor. */ protected XWSSProcessorFactory() {} /** * Creates a new instance of XWSSProcessorFactory * * @return a new instance of XWSSProcessorFactory * * @exception XWSSecurityException if there was an error in creating the * the XWSSProcessorFactory */ public static XWSSProcessorFactory newInstance() throws XWSSecurityException { ClassLoader classLoader; try { classLoader = Thread.currentThread().getContextClassLoader(); } catch (Exception x) { throw new XWSSecurityException(x.toString(), x); } // Use the system property first try { String systemProp = System.getProperty(XWSS_PROCESSOR_FACTORY_PROPERTY); if( systemProp!=null) { return newInstance(systemProp, classLoader); } else { return newInstance(DEFAULT_XWSS_PROCESSOR_FACTORY, classLoader); } } catch (SecurityException se) { throw new XWSSecurityException(se.toString(), se); } } /** * Creates a new instance of XWSSProcessor * * @param securityConfiguration an InputStream * for the SecurityConfiguration XML to be used * by the XWSSProcessor * * @param handler a JAAS CallbackHandler to be used by * the XWSSProcessor for Key and other Security * information retrieval * * @return a new instance of XWSSProcessor * * @exception XWSSecurityException if there was an error in creating the * the XWSSProcessor */ public abstract XWSSProcessor createProcessorForSecurityConfiguration( InputStream securityConfiguration, CallbackHandler handler) throws XWSSecurityException; /* * Creates a new instance of XWSSProcessor * * @param securityConfiguration an InputStream * for the JAXRPCSecurityConfiguration XML to be used * by the XWSSProcessor * * @return a new instance of XWSSProcessor * * @exception XWSSecurityException if there was an error in creating the * the XWSSProcessor public abstract XWSSProcessor createForApplicationSecurityConfiguration( InputStream securityConfiguration) throws XWSSecurityException; */ @SuppressWarnings({"unchecked"}) private static XWSSProcessorFactory newInstance(String className, ClassLoader classLoader) throws XWSSecurityException { try { Class spiClass; if (classLoader == null) { spiClass = (Class) Class.forName(className); } else { spiClass = (Class) classLoader.loadClass(className); } return spiClass.getConstructor().newInstance(); } catch (ClassNotFoundException x) { throw new XWSSecurityException( "Processor Factory " + className + " not found", x); } catch (Exception x) { throw new XWSSecurityException( "Processor Factory " + className + " could not be instantiated: " + x,x); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy