Example usage for java.lang SecurityManager checkSetFactory

List of usage examples for java.lang SecurityManager checkSetFactory

Introduction

In this page you can find the example usage for java.lang SecurityManager checkSetFactory.

Prototype

public void checkSetFactory() 

Source Link

Document

Throws a SecurityException if the calling thread is not allowed to set the socket factory used by ServerSocket or Socket, or the stream handler factory used by URL.

Usage

From source file:Main.java

public static void main(String[] args) {

    System.setProperty("java.security.policy", "file:/C:/java.policy");

    SecurityManager sm = new Main();

    System.setSecurityManager(sm);

    sm.checkSetFactory();

    System.out.println("Allowed!");
}

From source file:se.tillvaxtverket.ttsigvalws.ttwebservice.TTSigValServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    this.context = config.getServletContext();
    // Remove any occurance of the BC provider
    Security.removeProvider("BC");
    // Insert the BC provider in a preferred position
    Security.insertProviderAt(new BouncyCastleProvider(), 1);
    try {// w  w  w.  j  a  v a 2  s .  c o  m
        SecurityManager secMan = new SecurityManager();
        secMan.checkSetFactory();
        HttpURLConnection.setContentHandlerFactory(new OCSPContentHandlerFactory());
        LOG.info("Setting URL Content handler factory to OCSPContentHandlerFactory");
    } catch (Exception ex) {
        LOG.warning("Error when setting URL content handler factory");
    }
    infoText = ResourceBundle.getBundle("infoText");
    LOG.info(currentDir);
    String dataDir = context.getInitParameter("DataDirectory");
    ConfigData conf = new ConfigData(dataDir);
    baseModel = new SigValidationBaseModel(conf);
    Locale.setDefault(new Locale(baseModel.getConf().getLanguageCode()));
}