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

The following examples show how to use org.jivesoftware.util.JiveGlobals#getProperty() . 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: MediaProxyService.java    From Openfire with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(XMPPServer server) {
    super.initialize(server);

    sessionManager = server.getSessionManager();
    // In some cases, the domain name of the server may not be the actual address of the machine
    // (ie, when using DNS SRV records). In that case, the "mediaproxy.externalip" property should be
    // set to the IP address of the actual server where the media proxy is listening.
    String ipAddress = JiveGlobals.getProperty("mediaproxy.externalip", server.getServerInfo().getXMPPDomain());
    mediaProxy = new MediaProxy(ipAddress);

    String defaultName = "rtpbridge";
    serviceName = JiveGlobals.getProperty("mediaproxy.serviceName", defaultName);
    serviceName = serviceName.equals("") ? defaultName : serviceName;

    echoPort = JiveGlobals.getIntProperty("mediaproxy.echoPort", echoPort);

    routingTable = server.getRoutingTable();
    router = server.getPacketRouter();

    initMediaProxy();
}
 
Example 2
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 3
Source File: OfflineMessageStrategy.java    From Openfire with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(XMPPServer server) {
    super.initialize(server);
    messageStore = server.getOfflineMessageStore();
    router = server.getPacketRouter();
    serverAddress = new JID(server.getServerInfo().getXMPPDomain());

    JiveGlobals.migrateProperty("xmpp.offline.quota");
    JiveGlobals.migrateProperty("xmpp.offline.type");

    String quota = JiveGlobals.getProperty("xmpp.offline.quota");
    if (quota != null && quota.length() > 0) {
        OfflineMessageStrategy.quota = Integer.parseInt(quota);
    }
    String type = JiveGlobals.getProperty("xmpp.offline.type");
    if (type != null && type.length() > 0) {
        OfflineMessageStrategy.type = Type.valueOf(type);
    }
}
 
Example 4
Source File: CacheFactory.java    From Openfire with Apache License 2.0 6 votes vote down vote up
private static long getCacheProperty(String cacheName, String suffix, long defaultValue) {
    // First check if user is overwriting default value using a system property for the cache name
    String propName = PROPERTY_PREFIX_CACHE + cacheName.replaceAll(" ", "") + suffix;
    String sizeProp = JiveGlobals.getProperty(propName);
    if (sizeProp == null && cacheNames.containsKey(cacheName)) {
        // No system property was found for the cache name so try now with short name
        propName = PROPERTY_PREFIX_CACHE + cacheNames.get(cacheName) + suffix;
        sizeProp = JiveGlobals.getProperty(propName);
    }
    if (sizeProp != null) {
        try {
            return Long.parseLong(sizeProp);
        }
        catch (NumberFormatException nfe) {
            log.warn("Unable to parse " + propName + " using default value.");
        }
    }
    // Check if there is a default size value for this cache
    Long defaultSize = cacheProps.get(propName);
    return defaultSize == null ? defaultValue : defaultSize;
}
 
Example 5
Source File: LdapAuthorizationMapping.java    From Openfire with Apache License 2.0 6 votes vote down vote up
public LdapAuthorizationMapping() {
    // Convert XML based provider setup to Database based
    JiveGlobals.migrateProperty("ldap.princField");
    JiveGlobals.migrateProperty("ldap.princSearchFilter");

    manager = LdapManager.getInstance();
    usernameField = manager.getUsernameField();
    princField = JiveGlobals.getProperty("ldap.princField", "k5login");
    princSearchFilter = JiveGlobals.getProperty("ldap.princSearchFilter");
    StringBuilder filter = new StringBuilder();
    if(princSearchFilter == null) {
        filter.append('(').append(princField).append("={0})");
    } else {
        filter.append("(&(").append(princField).append("={0})(");
        filter.append(princSearchFilter).append("))");
    }
    princSearchFilter = filter.toString();
}
 
Example 6
Source File: PropertyBasedAuthProviderMapper.java    From Openfire with Apache License 2.0 6 votes vote down vote up
protected static AuthProvider instantiateProvider( String propertyName )
{
    final String className = JiveGlobals.getProperty( propertyName );
    if ( className == null )
    {
        throw new IllegalStateException( "A class name must be specified via openfire.xml or the system properties." );
    }

    try
    {
        final Class c = ClassUtils.forName( className );
        return (AuthProvider) c.newInstance();
    }
    catch ( Exception e )
    {
        throw new IllegalStateException( "Unable to create new instance of AuthProvider: " + className, e );
    }
}
 
Example 7
Source File: PropertyBasedAuthProviderMapper.java    From Openfire with Apache License 2.0 6 votes vote down vote up
@Override
public AuthProvider getAuthProvider( String username )
{
    for ( final Map.Entry<String, AuthProvider> entry : providersByPrefix.entrySet() )
    {
        final String usersProperty = JiveGlobals.getProperty( entry.getKey() + ".members.propertyName" );
        if ( usersProperty != null )
        {
            final List<String> usersInSet = JiveGlobals.getListProperty( usersProperty, Collections.<String>emptyList() );
            if ( usersInSet.contains( username ) )
            {
                return entry.getValue();
            }
        }
    }

    return fallbackProvider;
}
 
Example 8
Source File: JDBCAdminProvider.java    From Openfire with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a new JDBC admin provider.
 */
public JDBCAdminProvider() {
    // Convert XML based provider setup to Database based
    JiveGlobals.migrateProperty("jdbcProvider.driver");
    JiveGlobals.migrateProperty("jdbcProvider.connectionString");
    JiveGlobals.migrateProperty("jdbcAdminProvider.getAdminsSQL");

    xmppDomain = XMPPServerInfo.XMPP_DOMAIN.getValue();
    useConnectionProvider = JiveGlobals.getBooleanProperty("jdbcAdminProvider.useConnectionProvider");

    // Load database statement for reading admin list
    getAdminsSQL = JiveGlobals.getProperty("jdbcAdminProvider.getAdminsSQL");
    insertAdminsSQL = JiveGlobals.getProperty("jdbcAdminProvider.insertAdminsSQL", "");
    deleteAdminsSQL = JiveGlobals.getProperty("jdbcAdminProvider.deleteAdminsSQL", "");

    // Load the JDBC driver and connection string
    if (!useConnectionProvider) {
        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");
    }
}
 
Example 9
Source File: LdapAuthorizationPolicy.java    From Openfire with Apache License 2.0 5 votes vote down vote up
public LdapAuthorizationPolicy() {
    // Convert XML based provider setup to Database based
    JiveGlobals.migrateProperty("ldap.authorizeField");

    manager = LdapManager.getInstance();
    usernameField = manager.getUsernameField();
    authorizeField = JiveGlobals.getProperty("ldap.authorizeField", "k5login");
}
 
Example 10
Source File: JDBCUserPropertyProvider.java    From Openfire with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a new JDBC user property provider.
 */
public JDBCUserPropertyProvider()
{
    // Convert XML based provider setup to Database based
    JiveGlobals.migrateProperty( "jdbcUserPropertyProvider.driver" );
    JiveGlobals.migrateProperty( "jdbcUserPropertyProvider.connectionString" );
    JiveGlobals.migrateProperty( "jdbcUserPropertyProvider.loadPropertySQL" );
    JiveGlobals.migrateProperty( "jdbcUserPropertyProvider.loadPropertiesSQL" );

    useConnectionProvider = JiveGlobals.getBooleanProperty( "jdbcUserProvider.useConnectionProvider" );

    // Load the JDBC driver and connection string.
    if ( !useConnectionProvider )
    {
        String jdbcDriver = JiveGlobals.getProperty( "jdbcUserPropertyProvider.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 database statements for user data.
    loadPropertySQL = JiveGlobals.getProperty( "jdbcUserPropertyProvider.loadPropertySQL" );
    loadPropertiesSQL = JiveGlobals.getProperty( "jdbcUserPropertyProvider.loadPropertiesSQL" );
}
 
Example 11
Source File: SystemPropertiesServlet.java    From Openfire with Apache License 2.0 5 votes vote down vote up
private CompoundProperty(final String key) {
    this.systemProperty = false;
    this.key = key;
    this.value = JiveGlobals.getProperty(key);
    this.valueAsSaved = (String) value;
    this.displayValue = valueAsSaved;
    this.defaultDisplayValue = null;
    this.valueChanged = false;
    this.description = "";
    this.plugin = "";
    this.dynamic = false;
    this.restartRequired = false;
    this.encrypted = JiveGlobals.isPropertyEncrypted(key);
    this.hidden = encrypted || JiveGlobals.isPropertySensitive(key);
}
 
Example 12
Source File: OFMeetConfig.java    From openfire-ofmeet-plugin with Apache License 2.0 4 votes vote down vote up
public String getFocusPassword()
{
    return JiveGlobals.getProperty( "org.jitsi.videobridge.ofmeet.focus.user.password" );
}
 
Example 13
Source File: POP3AuthProvider.java    From Openfire with Apache License 2.0 4 votes vote down vote up
/**
 * Initialiazes the POP3AuthProvider with values from the global config file.
 */
public POP3AuthProvider() {
    // Convert XML based provider setup to Database based
    JiveGlobals.migrateProperty("pop3.authCache.enabled");
    JiveGlobals.migrateProperty("pop3.ssl");
    JiveGlobals.migrateProperty("pop3.authRequiresDomain");
    JiveGlobals.migrateProperty("pop3.host");
    JiveGlobals.migrateProperty("pop3.debug");
    JiveGlobals.migrateProperty("pop3.domain");
    JiveGlobals.migrateProperty("pop3.port");

    if (Boolean.valueOf(JiveGlobals.getProperty("pop3.authCache.enabled"))) {
        String cacheName = "POP3 Authentication";
        authCache = CacheFactory.createCache(cacheName);
    }

    useSSL = Boolean.valueOf(JiveGlobals.getProperty("pop3.ssl"));
    authRequiresDomain = Boolean.valueOf(JiveGlobals.getProperty("pop3.authRequiresDomain"));

    host = JiveGlobals.getProperty("pop3.host");
    if (host == null || host.length() < 1) {
        throw new IllegalArgumentException("pop3.host is null or empty");
    }

    debugEnabled = Boolean.valueOf(JiveGlobals.getProperty("pop3.debug"));

    domain = JiveGlobals.getProperty("pop3.domain");

    port = JiveGlobals.getIntProperty("pop3.port", useSSL ? 995 : 110);

    if (Log.isDebugEnabled()) {
        Log.debug("POP3AuthProvider: Created new POP3AuthProvider instance, fields:");
        Log.debug("\t host: " + host);
        Log.debug("\t port: " + port);
        Log.debug("\t domain: " + domain);
        Log.debug("\t useSSL: " + useSSL);
        Log.debug("\t authRequiresDomain: " + authRequiresDomain);
        Log.debug("\t authCacheEnabled: " + (authCache != null));
        if (authCache != null) {
            Log.debug("\t authCacheSize: " + authCache.getLongCacheSize());
            Log.debug("\t authCacheMaxLifetime: " + authCache.getMaxLifetime());
        }
    }
}
 
Example 14
Source File: LdapManager.java    From Openfire with Apache License 2.0 4 votes vote down vote up
@Override
public String get(Object key) {
    return JiveGlobals.getProperty((String)key);
}
 
Example 15
Source File: SipAccount.java    From openfire-ofmeet-plugin with Apache License 2.0 4 votes vote down vote up
public String getStunServer() {
    return stunServer == null ? JiveGlobals.getProperty("phone.stunServer", "") : stunServer;
}
 
Example 16
Source File: IdentityStore.java    From Openfire with Apache License 2.0 4 votes vote down vote up
/**
 * Populates the key store with a self-signed certificate for the domain of this XMPP service.
 *
 * If the 'algorithm' parameter is used, then this method will evaluate only certificates that match that
 * certificate.
 *
 * @param algorithm An optional algorithm constraint (eg: "RSA"). Can be null, cannot be empty.
 * @deprecated Unused as of Openfire 4.3.0. Use 'addSelfSignedDomainCertificate' instead. See OF-1599.
 * @throws CertificateStoreConfigException if a self-signed certificate could not be created
 */
@Deprecated
public synchronized void addSelfSignedDomainCertificate( String algorithm ) throws CertificateStoreConfigException
{
    if ( algorithm != null && algorithm.isEmpty() )
    {
        throw new IllegalArgumentException( "Argument 'algorithm' cannot be empty (but is allowed to be null)." );
    }

    final int keySize;
    final String signAlgorithm;

    if ( algorithm == null ) {
        algorithm = JiveGlobals.getProperty( "cert.algorithm", "RSA" );
    }
    switch ( algorithm.toUpperCase() )
    {
        case "RSA":
            keySize = JiveGlobals.getIntProperty( "cert.rsa.keysize", 2048 );
            signAlgorithm = JiveGlobals.getProperty( "cert.rsa.algorithm", "SHA256WITHRSAENCRYPTION" );
            break;

        case "DSA":
            keySize = JiveGlobals.getIntProperty( "cert.dsa.keysize", 1024 );
            signAlgorithm = JiveGlobals.getProperty( "cert.dsa.algorithm", "SHA256withDSA" );
            break;

        default:
            throw new IllegalArgumentException( "Unsupported algorithm '" + algorithm + "'. Use 'RSA' or 'DSA'." );
    }

    final String name = XMPPServerInfo.XMPP_DOMAIN.getValue().toLowerCase();
    final String alias = name + "_" + algorithm.toLowerCase();
    final int validityInDays = JiveGlobals.getIntProperty( "cert.validity-days", 5*365 );
    Set<String> sanDnsNames = CertificateManager.determineSubjectAlternateNameDnsNameValues();

    // OF-1605: Check if a wildcard entry is to be used to represent/replace any subdomains of the XMPP domain name.
    final boolean useWildcard = JiveGlobals.getBooleanProperty( "cert.wildcard", true );
    if ( useWildcard )
    {
        final String wildcard = "*." + XMPPServer.getInstance().getServerInfo().getXMPPDomain();

        // Remove any names that match the wildcard.
        sanDnsNames = sanDnsNames.stream()
            .filter( sanDnsName -> !DNSUtil.isNameCoveredByPattern( sanDnsName, wildcard )  )
            .collect( Collectors.toSet() );

        // Add the domain and wildcard entries.
        sanDnsNames.add( XMPPServer.getInstance().getServerInfo().getXMPPDomain() );
        sanDnsNames.add( wildcard );
    }

    Log.info( "Generating a new private key and corresponding self-signed certificate for domain name '{}', using the {} algorithm (sign-algorithm: {} with a key size of {} bits). Certificate will be valid for {} days.", name, algorithm, signAlgorithm, keySize, validityInDays );
    // Generate public and private keys
    try
    {
        final KeyPair keyPair = generateKeyPair( algorithm.toUpperCase(), keySize );

        // Create X509 certificate with keys and specified domain
        final X509Certificate cert = CertificateManager.createX509V3Certificate( keyPair, validityInDays, name, name, name, signAlgorithm, sanDnsNames );

        // Store new certificate and private key in the key store
        store.setKeyEntry( alias, keyPair.getPrivate(), configuration.getPassword(), new X509Certificate[]{cert} );

        // Persist the changes in the store to disk.
        persist();
    }
    catch ( CertificateStoreConfigException | IOException | GeneralSecurityException ex )
    {
        reload(); // reset state of the store.
        throw new CertificateStoreConfigException( "Unable to generate new self-signed " + algorithm + " certificate.", ex );
    }

    // TODO Notify listeners that a new certificate has been created
}
 
Example 17
Source File: GcmPlugin.java    From Openfire-GCM with Apache License 2.0 4 votes vote down vote up
public String getURL() {
	return JiveGlobals.getProperty(URL, null);
}
 
Example 18
Source File: HttpBindManager.java    From Openfire with Apache License 2.0 4 votes vote down vote up
public String getXFFHostHeader() {
    return JiveGlobals.getProperty(HTTP_BIND_FORWARDED_HOST);
}
 
Example 19
Source File: HttpBindManager.java    From Openfire with Apache License 2.0 4 votes vote down vote up
public String getXFFServerHeader() {
    return JiveGlobals.getProperty(HTTP_BIND_FORWARDED_SERVER);
}
 
Example 20
Source File: HttpBindManager.java    From Openfire with Apache License 2.0 4 votes vote down vote up
public String getXFFHeader() {
    return JiveGlobals.getProperty(HTTP_BIND_FORWARDED_FOR);
}