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

The following examples show how to use org.jivesoftware.util.JiveGlobals#setProperty() . 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: LdapUserProvider.java    From Openfire with Apache License 2.0 6 votes vote down vote up
public void setSearchFields(String fieldList) {
    this.searchFields = new LinkedHashMap<>();
    // If the value isn't present, default to to username, name, and email.
    if (fieldList == null) {
        searchFields.put("Username", manager.getUsernameField());
        int i = 0;
        for ( final String nameField : manager.getNameField().getFields() ) {
            searchFields.put((i == 0 ? "Name" : "Name (" + i + ")"), nameField);
            i++;
        }
        searchFields.put("Email", manager.getEmailField());
    }
    else {
        try {
            for (StringTokenizer i=new StringTokenizer(fieldList, ","); i.hasMoreTokens(); ) {
                String[] field = i.nextToken().split("/");
                searchFields.put(field[0], field[1]);
            }
        }
        catch (Exception e) {
            Log.error("Error parsing LDAP search fields: " + fieldList, e);
        }
    }
    JiveGlobals.setProperty("ldap.searchFields", fieldList);
}
 
Example 2
Source File: ExternalComponentManager.java    From Openfire with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the permission policy being used for new XMPP entities that are trying to
 * connect to the server. There are two types of policies: 1) blacklist: where any entity
 * is allowed to connect to the server except for those listed in the black list and
 * 2) whitelist: where only the entities listed in the white list are allowed to connect to
 * the server.
 *
 * @param policy the new PermissionPolicy to use.
 * @throws ModificationNotAllowedException if the operation was denied.
 */
public static void setPermissionPolicy(PermissionPolicy policy) throws ModificationNotAllowedException {
    // Alert listeners about this event
    for (ExternalComponentManagerListener listener : listeners) {
        try {
            listener.permissionPolicyChanged(policy);
        } catch (Exception e) {
            Log.warn("An exception occurred while dispatching a 'permissionPolicyChanged' event!", e);
        }
    }
    JiveGlobals.setProperty("xmpp.component.permission", policy.toString());
    // Check if connected components can remain connected to the server
    for (ComponentSession session : SessionManager.getInstance().getComponentSessions()) {
        for (String domain : session.getExternalComponent().getSubdomains()) {
            if (!canAccess(domain)) {
                Log.debug( "Closing session for external component '{}' as a changed permission policy is taken into effect. Affected session: {}", domain, session );
                session.close();
                break;
            }
        }
    }
}
 
Example 3
Source File: SystemPropertiesServlet.java    From Openfire with Apache License 2.0 6 votes vote down vote up
private void saveProperty(final HttpServletRequest request, final WebManager webManager) {
    final String key = request.getParameter("key");
    final boolean oldEncrypt = JiveGlobals.isPropertyEncrypted(key);
    final String oldValueToLog = oldEncrypt ? "***********" : JiveGlobals.getProperty(key);
    final String value = request.getParameter("value");
    final boolean encrypt = ParamUtils.getBooleanAttribute(request, "encrypt");
    final boolean alreadyExists = JiveGlobals.getProperty(key) != null;
    JiveGlobals.setProperty(key, value, encrypt);
    request.getSession().setAttribute("successMessage",
        String.format("The property %s was %s",
            StringEscapeUtils.escapeXml11(key), alreadyExists ? "updated" : "created"));
    final String newValueToLog = encrypt ? "***********" : value;
    final String details = alreadyExists
        ? String.format("Value of property changed from '%s' to '%s'", oldValueToLog, newValueToLog)
        : String.format("Property created with value '%s'", newValueToLog);
    webManager.logEvent("Updated server property " + key, details);
}
 
Example 4
Source File: JiveSharedSecretSaslServer.java    From Openfire with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the shared secret value, or {@code null} if shared secret authentication is disabled. If this is the
 * first time the shared secret value has been requested (and  shared secret auth is enabled), the key will be
 * randomly generated and stored in the property {@code xmpp.auth.sharedSecret}.
 *
 * @return the shared secret value.
 */
public static String getSharedSecret()
{
    if ( !isSharedSecretAllowed() )
    {
        return null;
    }

    String sharedSecret = JiveGlobals.getProperty( "xmpp.auth.sharedSecret" );
    if ( sharedSecret == null )
    {
        sharedSecret = StringUtils.randomString( 8 );
        JiveGlobals.setProperty( "xmpp.auth.sharedSecret", sharedSecret );
    }
    return sharedSecret;
}
 
Example 5
Source File: ConnectionListener.java    From Openfire with Apache License 2.0 6 votes vote down vote up
/**
 * Configuresif self-signed peer certificates can be used to establish an encrypted connection.
 *
 * @param accept true when self-signed certificates are accepted, otherwise false.
 */
public void setAcceptSelfSignedCertificates( boolean accept )
{
    final boolean oldValue = verifyCertificateValidity();

    // Always set the property explicitly even if it appears the equal to the old value (the old value might be a fallback value).
    JiveGlobals.setProperty( type.getPrefix() + "certificate.accept-selfsigned", Boolean.toString( accept ) );

    if ( oldValue == accept )
    {
        Log.debug( "Ignoring self-signed certificate acceptance policy change request (to '{}'): listener already in this state.", accept );
        return;
    }

    Log.debug( "Changing self-signed certificate acceptance policy from '{}' to '{}'.", oldValue, accept );
    restart();
}
 
Example 6
Source File: XMPPServer.java    From Openfire with Apache License 2.0 5 votes vote down vote up
private void finalSetupSteps() {
    for (String propName : JiveGlobals.getXMLPropertyNames()) {
        if (!XML_ONLY_PROPERTIES.contains(propName)) {
            if (JiveGlobals.getProperty(propName) == null) {
                JiveGlobals.setProperty(propName, JiveGlobals.getXMLProperty(propName));
            }
            JiveGlobals.setPropertyEncrypted(propName, JiveGlobals.isXMLPropertyEncrypted(propName));
        }
    }

    // Check if keystore (that out-of-the-box is a fallback for all keystores) already has certificates for current domain.
    CertificateStoreManager certificateStoreManager = null; // Will be a module after finishing setup.
    try {
        certificateStoreManager = new CertificateStoreManager();
        certificateStoreManager.initialize( this );
        certificateStoreManager.start();
        final IdentityStore identityStore = certificateStoreManager.getIdentityStore( ConnectionType.SOCKET_C2S );
        identityStore.ensureDomainCertificate();

    } catch (Exception e) {
        logger.error("Error generating self-signed certificates", e);
    } finally {
        if (certificateStoreManager != null)
        {
            certificateStoreManager.stop();
            certificateStoreManager.destroy();
        }
    }

    // Initialize list of admins now (before we restart Jetty)
    AdminManager.getInstance().getAdminAccounts();
}
 
Example 7
Source File: ConnectionListener.java    From Openfire with Apache License 2.0 5 votes vote down vote up
public void setClientAuth( Connection.ClientAuth clientAuth )
{
    final Connection.ClientAuth oldValue = getClientAuth();
    if ( oldValue.equals( clientAuth ) )
    {
        Log.debug( "Ignoring client auth configuration change request (to '{}'): listener already in this state.", clientAuth );
        return;
    }
    Log.debug( "Changing client auth configuration from '{}' to '{}'.", oldValue, clientAuth );
    JiveGlobals.setProperty( clientAuthPolicyPropertyName, clientAuth.toString() );
    restart();
}
 
Example 8
Source File: CrowdUserProvider.java    From Openfire with Apache License 2.0 5 votes vote down vote up
public CrowdUserProvider() {
    String propertyValue = JiveGlobals.getProperty(JIVE_CROWD_USERS_CACHE_TTL_SECS);
    int ttl = (propertyValue == null || propertyValue.trim().length() == 0) ? CACHE_TTL : Integer.parseInt(propertyValue);
    
    crowdUserSync.scheduleAtFixedRate(new UserSynch(this), 0, ttl, TimeUnit.SECONDS);
    
    JiveGlobals.setProperty(JIVE_CROWD_USERS_CACHE_TTL_SECS, String.valueOf(ttl));
    
    // workaround to load the sync of groups with crowd
    new CrowdGroupProvider();
}
 
Example 9
Source File: GroupManagerTest.java    From Openfire with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void beforeClass() throws Exception {
    Fixtures.reconfigureOpenfireHome();
    groupCache = CacheFactory.createCache("Group");
    groupMetadataCache = CacheFactory.createCache("Group Metadata Cache");
    JiveGlobals.setProperty("provider.group.className", TestGroupProvider.class.getName());
}
 
Example 10
Source File: CacheFactory.java    From Openfire with Apache License 2.0 5 votes vote down vote up
/**
 * Sets a local property which overrides the maximum cache size for the
 * supplied cache name.
 * @param cacheName the name of the cache to store a value for.
 * @param size the maximum cache size.
 */
public static void setMaxSizeProperty(String cacheName, long size) {
    cacheName = cacheName.replaceAll(" ", "");
    if ( !Long.toString(size).equals(JiveGlobals.getProperty(PROPERTY_PREFIX_CACHE + cacheName + PROPERTY_SUFFIX_SIZE)))
    {
        JiveGlobals.setProperty(PROPERTY_PREFIX_CACHE + cacheName + PROPERTY_SUFFIX_SIZE, Long.toString(size));
    }
}
 
Example 11
Source File: HttpBindManager.java    From Openfire with Apache License 2.0 4 votes vote down vote up
public void setHttpBindEnabled(boolean isEnabled) {
    JiveGlobals.setProperty(HTTP_BIND_ENABLED, String.valueOf(isEnabled));
}
 
Example 12
Source File: OFMeetConfig.java    From openfire-ofmeet-plugin with Apache License 2.0 4 votes vote down vote up
public void setVideoConstraintsMinHeight( int minHeight )
{
    JiveGlobals.setProperty( "org.jitsi.videobridge.ofmeet.constraints.video.height.min", Integer.toString( minHeight ) );
}
 
Example 13
Source File: OFMeetConfig.java    From openfire-ofmeet-plugin with Apache License 2.0 4 votes vote down vote up
public void setStartAudioMuted( Integer startAudioMuted )
{
    JiveGlobals.setProperty( "org.jitsi.videobridge.ofmeet.startaudiomuted", Integer.toString( startAudioMuted == null ? Integer.MAX_VALUE : startAudioMuted ) );
}
 
Example 14
Source File: OFMeetConfig.java    From openfire-ofmeet-plugin with Apache License 2.0 4 votes vote down vote up
public void setVideoConstraintsIdealAspectRatio( String ratio )
{
    JiveGlobals.setProperty( "org.jitsi.videobridge.ofmeet.constraints.video.aspectratio.ideal", ratio );
}
 
Example 15
Source File: OFMeetConfig.java    From openfire-ofmeet-plugin with Apache License 2.0 4 votes vote down vote up
public void setStartVideoMuted( Integer startVideoMuted )
{
    JiveGlobals.setProperty( "org.jitsi.videobridge.ofmeet.startvideomuted", Integer.toString( startVideoMuted == null ? Integer.MAX_VALUE : startVideoMuted ) );
}
 
Example 16
Source File: OFMeetConfig.java    From openfire-ofmeet-plugin with Apache License 2.0 4 votes vote down vote up
public void setPublicNATAddress( InetAddress address )
{
    JiveGlobals.setProperty( "org.ice4j.ice.harvest.NAT_HARVESTER_PUBLIC_ADDRESS", address == null ? null : address.getHostAddress() );
}
 
Example 17
Source File: OFMeetConfig.java    From openfire-ofmeet-plugin with Apache License 2.0 4 votes vote down vote up
public void setWatermarkLogoUrl( URL url )
{
    JiveGlobals.setProperty( "org.jitsi.videobridge.ofmeet.watermark.logo", url == null ? null : url.toExternalForm() );
}
 
Example 18
Source File: LdapManager.java    From Openfire with Apache License 2.0 4 votes vote down vote up
@Override
public String put(String key, String value) {
    JiveGlobals.setProperty(key, value);
    // Always return null since XMLProperties doesn't support the normal semantics.
    return null;
}
 
Example 19
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 20
Source File: DNSUtil.java    From Openfire with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the internal DNS that allows to specify target IP addresses and ports
 * to use for domains. The internal DNS will be checked up before performing an
 * actual DNS SRV lookup.
 *
 * @param dnsOverride the internal DNS that allows to specify target IP addresses and ports
 *        to use for domains.
 */
public static void setDnsOverride(Map<String, HostAddress> dnsOverride) {
    DNSUtil.dnsOverride = dnsOverride;
    JiveGlobals.setProperty("dnsutil.dnsOverride", encode(dnsOverride));
}