Example usage for javax.servlet ServletConfig getInitParameter

List of usage examples for javax.servlet ServletConfig getInitParameter

Introduction

In this page you can find the example usage for javax.servlet ServletConfig getInitParameter.

Prototype

public String getInitParameter(String name);

Source Link

Document

Gets the value of the initialization parameter with the given name.

Usage

From source file:org.apache.axis2.soapmonitor.servlet.SOAPMonitorService.java

/**
 * Servlet initialiation/*from w ww . j  a v  a  2 s .c o m*/
 */
public void init() throws ServletException {
    if (connections == null) {
        // Create vector to hold connection information
        connections = new Vector();
    }
    if (serverSocket == null) {
        // Get the server socket port from the init params
        ServletConfig config = super.getServletConfig();
        String hostName = config.getInitParameter(SOAPMonitorConstants.SOAP_MONITOR_HOST_NAME);
        String port = config.getInitParameter(SOAPMonitorConstants.SOAP_MONITOR_PORT);
        if (port == null) {
            log.error("SOAPMonitorService can't find ServletConfig init parameter 'port'");
            port = "0";
        }
        try {
            if (hostName != null) {
                serverSocket = new ServerSocket(Integer.parseInt(port), 50, InetAddress.getByName(hostName));
            } else {
                serverSocket = new ServerSocket(Integer.parseInt(port));
            }
        } catch (Exception ex) {
            // Let someone know we could not open the socket
            log.error("Unable to open server socket using port: " + port);
            log.error(ex.getMessage(), ex);
            // Fail as loudly as possible for those without logging configured
            config.getServletContext().log("Unable to open server socket using port " + port + ":", ex);
            serverSocket = null;
        }
        if (serverSocket != null) {
            // Start the server socket thread
            new Thread(new ServerSocketThread()).start();
        }
    }
}

From source file:org.apache.abdera.protocol.server.servlet.AbderaServlet.java

protected Map<String, String> getProperties(ServletConfig config) {
    Map<String, String> properties = new HashMap<String, String>();
    Enumeration<String> e = config.getInitParameterNames();
    while (e.hasMoreElements()) {
        String key = e.nextElement();
        String val = config.getInitParameter(key);
        properties.put(key, val);
    }//from w  ww .j  a v  a 2 s.  c  om
    return properties;
}

From source file:com.surevine.chat.view.server.authentication.CredentialServiceImpl.java

/**
 * {@inheritDoc}./*  ww  w . ja  va 2  s  .  co m*/
 */
@Override
public void init(final ServletConfig config) throws ServletException {
    super.init(config);

    if (LOG.isDebugEnabled()) {
        LOG.debug("Initialising " + SERVICE_URL_INIT_PARAM + " with "
                + config.getInitParameter(SERVICE_URL_INIT_PARAM));
    }

    setServiceUrl(config.getInitParameter(SERVICE_URL_INIT_PARAM));

    if (LOG.isDebugEnabled()) {
        LOG.debug("Initialising " + CAS_SERVER_LOGON_URL_INIT_PARAM + " with "
                + config.getInitParameter(CAS_SERVER_LOGON_URL_INIT_PARAM));
    }

    casServerLoginUrl = config.getInitParameter(CAS_SERVER_LOGON_URL_INIT_PARAM);
}

From source file:com.swdouglass.joid.server.OpenIdServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    String storeClassName = (config.getInitParameter(INIT_STORE_CLASS) == null ? INIT_STORE_CLASS_DEFAULT
            : config.getInitParameter(INIT_STORE_CLASS));
    String userManagerClassName = (config.getInitParameter(INIT_USER_CLASS) == null ? INIT_USER_CLASS_DEFAULT
            : config.getInitParameter(INIT_USER_CLASS));
    this.loginPage = (config.getInitParameter(INIT_LOGIN_PAGE) == null ? INIT_LOGIN_PAGE_DEFAULT
            : config.getInitParameter(INIT_LOGIN_PAGE));
    this.captchaPrivateKey = config.getInitParameter(INIT_CAPTCHA_PRIVATE_KEY);

    String endPointUrl = config.getInitParameter(INIT_ENDPOINT_URL);

    this.store = Store.getInstance(storeClassName);
    this.store.setAssociationLifetime(600);
    OpenIdServlet.userManager = (UserManager) DependencyUtils.newInstance(userManagerClassName);
    this.crypto = new Crypto();
    OpenIdServlet.openId = new OpenId(new ServerInfo(endPointUrl, store, crypto));
}

From source file:aaf.vhr.idp.http.VhrRemoteUserAuthServlet.java

/** {@inheritDoc} */
@Override/*from w  w  w  .j a v  a 2s.com*/
public void init(final ServletConfig config) throws ServletException {
    super.init(config);

    // VHR-specific initalization
    vhrLoginEndpoint = config.getInitParameter("loginEndpoint");
    String apiServer = config.getInitParameter("apiServer");
    String apiEndpoint = config.getInitParameter("apiEndpoint");
    String apiToken = config.getInitParameter("apiToken");
    String apiSecret = config.getInitParameter("apiSecret");
    String requestingHost = config.getInitParameter("requestingHost");

    // Consent revocation parameter name: override default if set
    String crpn = config.getInitParameter("consentRevocationParamName");
    if (crpn != null) {
        consentRevocationParamName = crpn;
    }
    ;

    vhrSessionValidator = new VhrSessionValidator(apiServer, apiEndpoint, apiToken, apiSecret, requestingHost);

}

From source file:org.etudes.ambrosia.util.AmbrosiaServlet.java

/**
 * Initialize the servlet.//from   ww  w.j  a  va 2 s  .  c o m
 * 
 * @param config
 *        The servlet config.
 * @throws ServletException
 */
public void init(ServletConfig config) throws ServletException {
    super.init(config);

    // toolId, resourcePaths, defaultView
    this.toolId = config.getInitParameter("toolId");

    String resourcePaths = config.getInitParameter("resourcePaths");
    if (resourcePaths != null)
        this.resourcePaths.add(resourcePaths);

    this.defaultView = config.getInitParameter("defaultView");

    String errorView = config.getInitParameter("errorView");
    if (errorView != null)
        this.errorView = errorView;

    // self-inject
    ui = (UiService) ComponentManager.get(UiService.class);
    toolManager = (ToolManager) ComponentManager.get(ToolManager.class);

    M_log.info("init()");
}

From source file:org.opennms.web.asset.ImportAssetsServlet.java

/**
 * Looks up the <code>redirect.success</code> parameter in the servlet's
 * configuration. If not present, this servlet will throw an exception so it will
 * be marked unavailable.//from w  w w . j a v  a2s . c  o  m
 *
 * @throws javax.servlet.ServletException if any.
 */
@Override
public void init() throws ServletException {
    ServletConfig config = this.getServletConfig();

    this.redirectSuccess = config.getInitParameter("redirect.success");

    if (this.redirectSuccess == null) {
        throw new UnavailableException("Require a redirect.success init parameter.");
    }

    this.model = new AssetModel();
}

From source file:edu.internet2.middleware.shibboleth.idp.StatusServlet.java

/** {@inheritDoc} */
public void init(ServletConfig config) throws ServletException {
    super.init(config);

    allowedIPs = new LazyList<IPRange>();

    String cidrBlocks = DatatypeHelper.safeTrimOrNullString(config.getInitParameter(IP_PARAM_NAME));
    if (cidrBlocks != null) {
        for (String cidrBlock : cidrBlocks.split(" ")) {
            allowedIPs.add(IPRange.parseCIDRBlock(cidrBlock));
        }/*from  w w  w.  j  a  va2 s  .  c o  m*/
    }

    dateFormat = ISODateTimeFormat.dateTimeNoMillis();
    startTime = new DateTime(ISOChronology.getInstanceUTC());
    attributeResolver = HttpServletHelper.getAttributeResolver(config.getServletContext());
    rpConfigManager = HttpServletHelper.getRelyingPartyConfirmationManager(config.getServletContext());
}

From source file:com.netspective.sparx.security.authenticator.SingleUserServletLoginAuthenticator.java

public boolean isUserValid(HttpLoginManager loginManager, LoginDialogContext loginDialogContext) {
    if (userId != null && (plainTextPassword != null || encryptedPassword != null)) {
        String loginPasswordEncrypted = encryptedPassword;
        if (loginPasswordEncrypted == null)
            loginPasswordEncrypted = loginDialogContext.encryptPlainTextPassword(plainTextPassword);

        if (!userId.equals(loginDialogContext.getUserIdInput()))
            return false;

        if (!loginPasswordEncrypted
                .equals(loginDialogContext.getPasswordInput(!loginDialogContext.hasEncryptedPassword())))
            return false;
    } else {/* w w w .j a  v a 2s .c  o m*/
        ServletConfig servletConfig = loginDialogContext.getServlet().getServletConfig();
        LoginDialog loginDialog = loginDialogContext.getLoginDialog();
        String optionsText = servletConfig.getInitParameter(optionsInitParamsName);
        if (optionsText == null) {
            log.error("Servlet param " + optionsInitParamsName + " not specified.");
            loginDialog.getUserIdField().invalidate(loginDialogContext,
                    "Servlet param " + optionsInitParamsName + " not specified.");
            return false;
        }

        CommandLine commandLine = getOptionsCommandLine(loginDialogContext, optionsText);
        if (commandLine == null)
            return false;

        String loginUserId = commandLine.getOptionValue('u');
        String loginPasswordEncrypted = commandLine.getOptionValue('P');
        if (loginPasswordEncrypted == null) {
            String loginPasswordUnencrypted = commandLine.getOptionValue('p');
            if (loginPasswordUnencrypted != null)
                loginPasswordEncrypted = loginDialogContext.encryptPlainTextPassword(loginPasswordUnencrypted);
        }

        if (commandLine.hasOption('s'))
            System.out.println(TextUtils.getInstance().getClassNameWithoutPackage(getClass().getName())
                    + " encrypted password is " + loginPasswordEncrypted);

        if (!loginUserId.equals(loginDialogContext.getUserIdInput()))
            return false;

        if (!loginPasswordEncrypted
                .equals(loginDialogContext.getPasswordInput(!loginDialogContext.hasEncryptedPassword())))
            return false;
    }
    return true;
}

From source file:edu.ucsd.xmlrpc.xmlrpc.webserver.XmlRpcServlet.java

private void handleInitParameters(ServletConfig pConfig) throws ServletException {
    for (Enumeration en = pConfig.getInitParameterNames(); en.hasMoreElements();) {
        String name = (String) en.nextElement();
        String value = pConfig.getInitParameter(name);
        try {/*from   w w  w  . jav  a  2s .co m*/
            if (!ReflectionUtil.setProperty(this, name, value)
                    && !ReflectionUtil.setProperty(server, name, value)
                    && !ReflectionUtil.setProperty(server.getConfig(), name, value)) {
                throw new ServletException("Unknown init parameter " + name);
            }
        } catch (IllegalAccessException e) {
            throw new ServletException("Illegal access to instance of " + server.getClass().getName()
                    + " while setting property " + name + ": " + e.getMessage(), e);
        } catch (InvocationTargetException e) {
            Throwable t = e.getTargetException();
            throw new ServletException("Failed to invoke setter for property " + name + " on instance of "
                    + server.getClass().getName() + ": " + t.getMessage(), t);
        }
    }
}