Java Code Examples for org.jivesoftware.util.JiveGlobals#getIntProperty()

The following examples show how to use org.jivesoftware.util.JiveGlobals#getIntProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConnectionListener.java    From Openfire with Apache License 2.0 5 votes vote down vote up
/**
 * The TCP port number on which connections will be accepted when this listener is enabled.
 *
 * @return A port number.
 */
public int getPort()
{
    if ( tcpPortPropertyName != null )
    {
        return JiveGlobals.getIntProperty( tcpPortPropertyName, defaultPort );
    }
    else
    {
        return defaultPort;
    }
}
 
Example 2
Source File: RemoteServerManager.java    From Openfire with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the remote port to connect for the specified remote server. If no port was
 * defined then use the default port (e.g. 5269).
 *
 * @param domain the domain of the remote server to get the remote port to connect to.
 * @return the remote port to connect for the specified remote server.
 */
public static int getPortForServer(String domain) {
    int port = JiveGlobals.getIntProperty(ConnectionSettings.Server.REMOTE_SERVER_PORT, ConnectionManager.DEFAULT_SERVER_PORT);
    RemoteServerConfiguration config = getConfiguration(domain);
    if (config != null) {
        port = config.getRemotePort();
        if (port == 0) {
            port = JiveGlobals
                    .getIntProperty(ConnectionSettings.Server.REMOTE_SERVER_PORT, ConnectionManager.DEFAULT_SERVER_PORT);
        }
    }
    return port;
}
 
Example 3
Source File: AuditManagerImpl.java    From Openfire with Apache License 2.0 5 votes vote down vote up
@Override
    public void initialize(XMPPServer server) {
        super.initialize(server);
        enabled = JiveGlobals.getBooleanProperty("xmpp.audit.active");
        auditMessage = JiveGlobals.getBooleanProperty("xmpp.audit.message");
        auditPresence = JiveGlobals.getBooleanProperty("xmpp.audit.presence");
        auditIQ = JiveGlobals.getBooleanProperty("xmpp.audit.iq");
        auditXPath = JiveGlobals.getBooleanProperty("xmpp.audit.xpath");
        // TODO: load xpath values!
//        String[] filters = context.getProperties("xmpp.audit.filter.xpath");
//        for (int i = 0; i < filters.length; i++) {
//            xpath.add(filters[i]);
//        }
        maxTotalSize = JiveGlobals.getIntProperty("xmpp.audit.totalsize", MAX_TOTAL_SIZE);
        maxFileSize = JiveGlobals.getIntProperty("xmpp.audit.filesize", MAX_FILE_SIZE);
        maxDays = JiveGlobals.getIntProperty("xmpp.audit.days", MAX_DAYS);
        logTimeout = JiveGlobals.getIntProperty("xmpp.audit.logtimeout", DEFAULT_LOG_TIMEOUT);
        logDir = JiveGlobals.getProperty("xmpp.audit.logdir", JiveGlobals.getHomeDirectory() +
                File.separator + "logs");
        processIgnoreString(JiveGlobals.getProperty("xmpp.audit.ignore", ""));

        auditor = new AuditorImpl(this);
        auditor.setMaxValues(maxTotalSize, maxFileSize, maxDays);
        auditor.setLogDir(logDir);
        auditor.setLogTimeout(logTimeout);

        interceptor = new AuditorInterceptor();
        processEnabled(enabled);
        PropertyEventDispatcher.addListener(this);
    }
 
Example 4
Source File: OpenfireWebSocketServlet.java    From Openfire with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(WebSocketServletFactory factory)
{
    if (XmppWebSocket.isCompressionEnabled()) {
        factory.getExtensionFactory().register("permessage-deflate", PerMessageDeflateExtension.class);
    }
    final int messageSize = JiveGlobals.getIntProperty("xmpp.parser.buffer.size", 1048576);
    factory.getPolicy().setMaxTextMessageBufferSize(messageSize * 5);
    factory.getPolicy().setMaxTextMessageSize(messageSize);
    factory.setCreator(new WebSocketCreator() {
        @Override
        public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp)
        {
            try {
                for (String subprotocol : req.getSubProtocols())
                {
                    if ("xmpp".equals(subprotocol))
                    {
                        resp.setAcceptedSubProtocol(subprotocol);
                        return new XmppWebSocket();
                    }
                }
            } catch (Exception e) {
                Log.warn(MessageFormat.format("Unable to load websocket factory: {0} ({1})", e.getClass().getName(), e.getMessage()));
            }
            Log.warn("Failed to create websocket for {}:{} make a request at {}", req.getRemoteAddress(), req.getRemotePort(), req.getRequestPath() );
            return null;
        }
    });
}
 
Example 5
Source File: ComponentConnectionHandler.java    From Openfire with Apache License 2.0 4 votes vote down vote up
@Override
int getMaxIdleTime() {
    return JiveGlobals.getIntProperty("xmpp.component.idle", 6 * 60 * 1000) / 1000;
}
 
Example 6
Source File: ServerConnectionHandler.java    From Openfire with Apache License 2.0 4 votes vote down vote up
@Override
int getMaxIdleTime()
{
    return JiveGlobals.getIntProperty( "xmpp.server.idle", 6 * 60 * 1000 ) / 1000;
}
 
Example 7
Source File: SessionManager.java    From Openfire with Apache License 2.0 4 votes vote down vote up
public int getServerSessionIdleTime() {
    return JiveGlobals.getIntProperty("xmpp.server.session.idle", 10 * 60 * 1000);
}
 
Example 8
Source File: JDBCAuthProvider.java    From Openfire with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs a new JDBC authentication provider.
 */
public JDBCAuthProvider() {
    // Convert XML based provider setup to Database based
    JiveGlobals.migrateProperty("jdbcProvider.driver");
    JiveGlobals.migrateProperty("jdbcProvider.connectionString");
    JiveGlobals.migrateProperty("jdbcAuthProvider.passwordSQL");
    JiveGlobals.migrateProperty("jdbcAuthProvider.passwordType");
    JiveGlobals.migrateProperty("jdbcAuthProvider.setPasswordSQL");
    JiveGlobals.migrateProperty("jdbcAuthProvider.allowUpdate");
    JiveGlobals.migrateProperty("jdbcAuthProvider.bcrypt.cost");
    JiveGlobals.migrateProperty("jdbcAuthProvider.useConnectionProvider");
    JiveGlobals.migrateProperty("jdbcAuthProvider.acceptPreHashedPassword");
    
    useConnectionProvider = JiveGlobals.getBooleanProperty("jdbcAuthProvider.useConnectionProvider");
    
    if (!useConnectionProvider) {
        // Load the JDBC driver and connection string.
        String jdbcDriver = JiveGlobals.getProperty("jdbcProvider.driver");
        try {
           Class.forName(jdbcDriver).newInstance();
        }
        catch (Exception e) {
            Log.error("Unable to load JDBC driver: " + jdbcDriver, e);
            return;
        }
        connectionString = JiveGlobals.getProperty("jdbcProvider.connectionString");
    }

    // Load SQL statements.
    passwordSQL = JiveGlobals.getProperty("jdbcAuthProvider.passwordSQL");
    setPasswordSQL = JiveGlobals.getProperty("jdbcAuthProvider.setPasswordSQL");

    allowUpdate = JiveGlobals.getBooleanProperty("jdbcAuthProvider.allowUpdate",false);

    setPasswordTypes(JiveGlobals.getProperty("jdbcAuthProvider.passwordType", "plain"));
    bcryptCost = JiveGlobals.getIntProperty("jdbcAuthProvider.bcrypt.cost", -1);
    PropertyEventDispatcher.addListener(this);
    if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) {
        java.security.Security.addProvider(new BouncyCastleProvider());
    }
}
 
Example 9
Source File: MUCPersistenceManager.java    From Openfire with Apache License 2.0 4 votes vote down vote up
private static void loadHistory(Long serviceID, Map<Long, LocalMUCRoom> rooms) throws SQLException {
    Connection connection = null;
    PreparedStatement statement = null;
    ResultSet resultSet = null;
    try {
        connection = DbConnectionManager.getConnection();
        statement = connection.prepareStatement(LOAD_ALL_HISTORY);

        // Reload the history, using "muc.history.reload.limit" (days) if present
        long from = 0;
        String reloadLimit = JiveGlobals.getProperty(MUC_HISTORY_RELOAD_LIMIT);
        if (reloadLimit != null) {
            // if the property is defined, but not numeric, default to 2 (days)
            int reloadLimitDays = JiveGlobals.getIntProperty(MUC_HISTORY_RELOAD_LIMIT, 2);
            Log.warn("MUC history reload limit set to " + reloadLimitDays + " days");
            from = System.currentTimeMillis() - (BigInteger.valueOf(86400000).multiply(BigInteger.valueOf(reloadLimitDays))).longValue();
        }
        statement.setLong(1, serviceID);
        statement.setString(2, StringUtils.dateToMillis(new Date(from)));
        resultSet = statement.executeQuery();

        while (resultSet.next()) {
            try {
                LocalMUCRoom room = rooms.get(resultSet.getLong(1));
                // Skip to the next position if the room does not exist or if history is disabled
                if (room == null || !room.isLogEnabled()) {
                    continue;
                }
                String senderJID = resultSet.getString(2);
                String nickname  = resultSet.getString(3);
                Date sentDate    = new Date(Long.parseLong(resultSet.getString(4).trim()));
                String subject   = resultSet.getString(5);
                String body      = resultSet.getString(6);
                String stanza = resultSet.getString(7);
                room.getRoomHistory().addOldMessage(senderJID, nickname, sentDate, subject, body, stanza);
            } catch (SQLException e) {
                Log.warn("A database exception prevented the history for one particular MUC room to be loaded from the database.", e);
            }
        }
    } finally {
        DbConnectionManager.closeConnection(resultSet, statement, connection);
    }

    // Add the last known room subject to the room history only for those rooms that still
    // don't have in their histories the last room subject
    for (MUCRoom loadedRoom : rooms.values())
    {
        if (!loadedRoom.getRoomHistory().hasChangedSubject()
            && loadedRoom.getSubject() != null
            && loadedRoom.getSubject().length() > 0)
        {
            loadedRoom.getRoomHistory().addOldMessage(  loadedRoom.getRole().getRoleAddress().toString(),
                                                        null,
                                                        loadedRoom.getModificationDate(),
                                                        loadedRoom.getSubject(),
                                                        null,
                                                        null);
        }
    }
}
 
Example 10
Source File: OFMeetConfig.java    From openfire-ofmeet-plugin with Apache License 2.0 4 votes vote down vote up
public int getFilmstripMaxHeight()
{
    return JiveGlobals.getIntProperty( "org.jitsi.videobridge.ofmeet.film.strip.max.height", 120 );
}
 
Example 11
Source File: OFMeetConfig.java    From openfire-ofmeet-plugin with Apache License 2.0 4 votes vote down vote up
public int getVideoConstraintsMinHeight()
{
    final int value = JiveGlobals.getIntProperty( "org.jitsi.videobridge.ofmeet.constraints.video.height.min", getVideoConstraintsIdealHeight() / 3 );
    return Math.min( value, getVideoConstraintsIdealHeight() ); // don't have a 'min' that is lower than 'ideal'.
}
 
Example 12
Source File: OFMeetConfig.java    From openfire-ofmeet-plugin with Apache License 2.0 4 votes vote down vote up
public int getVideoConstraintsMaxHeight()
{
    final int value = JiveGlobals.getIntProperty( "org.jitsi.videobridge.ofmeet.constraints.video.height.max", getVideoConstraintsIdealHeight() * 3 );
    return Math.max( value, getVideoConstraintsIdealHeight() ); // don't have a 'max' that is lower than 'ideal'.
}
 
Example 13
Source File: OFMeetConfig.java    From openfire-ofmeet-plugin with Apache License 2.0 4 votes vote down vote up
public int getVideoConstraintsIdealHeight()
{
    return JiveGlobals.getIntProperty( "org.jitsi.videobridge.ofmeet.constraints.video.height.ideal", getResolution() );
}
 
Example 14
Source File: SessionManager.java    From Openfire with Apache License 2.0 3 votes vote down vote up
/**
 * Sets if remote servers are allowed to have more than one connection to this
 * server. Having more than one connection may improve number of packets that can be
 * transfered per second. This setting only used by the server dialback mehod.<p>
 *
 * It is highly recommended that {@link #getServerSessionTimeout()} is enabled so that
 * dead connections to this server can be easily discarded.
 *
 * @param allowed true if remote servers are allowed to have more than one connection to this
 *        server.
 */
public void setMultipleServerConnectionsAllowed(boolean allowed) {
    JiveGlobals.setProperty("xmpp.server.session.allowmultiple", Boolean.toString(allowed));
    if (allowed && JiveGlobals.getIntProperty("xmpp.server.session.idle", 10 * 60 * 1000) <= 0)
    {
        Log.warn("Allowing multiple S2S connections for each domain, without setting a " +
                "maximum idle timeout for these connections, is unrecommended! Either " +
                "set xmpp.server.session.allowmultiple to 'false' or change " +
                "xmpp.server.session.idle to a (large) positive value.");
    }
}
 
Example 15
Source File: HttpBindManager.java    From Openfire with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the HTTP binding port which uses SSL.
 *
 * @return the HTTP binding port which uses SSL.
 */
public int getHttpBindSecurePort() {
    return JiveGlobals.getIntProperty(HTTP_BIND_SECURE_PORT, HTTP_BIND_SECURE_PORT_DEFAULT);
}
 
Example 16
Source File: JMXManager.java    From Openfire with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the port number for the JMX connector. This option can 
 * be configured via the admin console or by setting the following 
 * system property:
 * <pre>
 *    xmpp.jmx.port=[port] (default: 1099)
 * </pre>
 * 
 * @return Port number for the JMX connector
 */
public static int getPort() {
    return JiveGlobals.getIntProperty(XMPP_JMX_PORT, DEFAULT_PORT);
}
 
Example 17
Source File: HttpSessionManager.java    From Openfire with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the longest time (in seconds) that Openfire is allowed to wait before responding to
 * any request during the session. This enables the client to prevent its TCP connection from
 * expiring due to inactivity, as well as to limit the delay before it discovers any network
 * failure.
 *
 * @return the longest time (in seconds) that Openfire is allowed to wait before responding to
 *         any request during the session.
 */
public int getMaxWait() {
    return JiveGlobals.getIntProperty("xmpp.httpbind.client.requests.wait",
            Integer.MAX_VALUE);
}
 
Example 18
Source File: HttpSessionManager.java    From Openfire with Apache License 2.0 2 votes vote down vote up
/**
 * Openfire MAY limit the number of simultaneous requests the client makes with the 'requests'
 * attribute. The RECOMMENDED value is "2". Servers that only support polling behavior MUST
 * prevent clients from making simultaneous requests by setting the 'requests' attribute to a
 * value of "1" (however, polling is NOT RECOMMENDED). In any case, clients MUST NOT make more
 * simultaneous requests than specified by the Openfire.
 *
 * @return the number of simultaneous requests allowable.
 */
public int getMaxRequests() {
    return JiveGlobals.getIntProperty("xmpp.httpbind.client.requests.max", 2);
}
 
Example 19
Source File: HttpBindManager.java    From Openfire with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the HTTP binding port which does not use SSL.
 *
 * @return the HTTP binding port which does not use SSL.
 */
public int getHttpBindUnsecurePort() {
    return JiveGlobals.getIntProperty(HTTP_BIND_PORT, HTTP_BIND_PORT_DEFAULT);
}
 
Example 20
Source File: HttpSessionManager.java    From Openfire with Apache License 2.0 2 votes vote down vote up
/**
 * Openfire SHOULD include two additional attributes in the session creation response element,
 * specifying the shortest allowable polling interval and the longest allowable inactivity
 * period (both in seconds). Communication of these parameters enables the client to engage in
 * appropriate behavior (e.g., not sending empty request elements more often than desired, and
 * ensuring that the periods with no requests pending are never too long).
 *
 * @return the maximum allowable period over which a client can send empty requests to the
 *         server.
 */
public int getPollingInterval() {
    return JiveGlobals.getIntProperty("xmpp.httpbind.client.requests.polling", 5);
}