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

The following examples show how to use org.jivesoftware.util.JiveGlobals#migrateProperty() . 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: MappedUserProvider.java    From Openfire with Apache License 2.0 6 votes vote down vote up
public MappedUserProvider()
{

    // Migrate properties.
    JiveGlobals.migrateProperty( PROPERTY_MAPPER_CLASSNAME );

    // Instantiate mapper.
    final String mapperClass = JiveGlobals.getProperty( PROPERTY_MAPPER_CLASSNAME );
    if ( mapperClass == null )
    {
        throw new IllegalStateException( "A mapper must be specified via openfire.xml or the system properties." );
    }

    try
    {
        final Class c = ClassUtils.forName( mapperClass );
        mapper = (UserProviderMapper) c.newInstance();
    }
    catch ( Exception e )
    {
        throw new IllegalStateException( "Unable to create new instance of UserProviderMapper class: " + mapperClass, e );
    }
}
 
Example 2
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 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: MappedAuthProvider.java    From Openfire with Apache License 2.0 6 votes vote down vote up
public MappedAuthProvider()
{
    // Migrate properties.
    JiveGlobals.migrateProperty( PROPERTY_MAPPER_CLASSNAME );

    // Instantiate mapper.
    final String mapperClass = JiveGlobals.getProperty( PROPERTY_MAPPER_CLASSNAME );
    if ( mapperClass == null )
    {
        throw new IllegalStateException( "A mapper must be specified via openfire.xml or the system properties." );
    }

    try
    {
        final Class c = ClassUtils.forName( mapperClass );
        mapper = (AuthProviderMapper) c.newInstance();
    }
    catch ( Exception e )
    {
        throw new IllegalStateException( "Unable to create new instance of AuthProviderMapper class: " + mapperClass, e );
    }
}
 
Example 5
Source File: RosterManager.java    From Openfire with Apache License 2.0 6 votes vote down vote up
private void initProvider() {
    JiveGlobals.migrateProperty("provider.roster.className");
    String className = JiveGlobals.getProperty("provider.roster.className",
            "org.jivesoftware.openfire.roster.DefaultRosterItemProvider");

    if (provider == null || !className.equals(provider.getClass().getName())) {
        try {
            Class c = ClassUtils.forName(className);
            provider = (RosterItemProvider) c.newInstance();
        }
        catch (Exception e) {
            Log.error("Error loading roster provider: " + className, e);
            provider = new DefaultRosterItemProvider();
        }
    }

}
 
Example 6
Source File: HybridUserPropertyProvider.java    From Openfire with Apache License 2.0 5 votes vote down vote up
public HybridUserPropertyProvider()
{
    // Migrate user provider properties
    JiveGlobals.migrateProperty( "hybridUserPropertyProvider.primaryProvider.className" );
    JiveGlobals.migrateProperty( "hybridUserPropertyProvider.secondaryProvider.className" );
    JiveGlobals.migrateProperty( "hybridUserPropertyProvider.tertiaryProvider.className" );

    // Load primary, secondary, and tertiary user providers.
    final UserPropertyProvider primary = MappedUserPropertyProvider.instantiate( "hybridUserPropertyProvider.primaryProvider.className" );
    if ( primary != null )
    {
        providers.add( primary );
    }
    final UserPropertyProvider secondary = MappedUserPropertyProvider.instantiate( "hybridUserPropertyProvider.secondaryProvider.className" );
    if ( secondary != null )
    {
        providers.add( secondary );
    }
    final UserPropertyProvider tertiary = MappedUserPropertyProvider.instantiate( "hybridUserPropertyProvider.tertiaryProvider.className" );
    if ( tertiary != null )
    {
        providers.add( tertiary );
    }

    // Verify that there's at least one provider available.
    if ( providers.isEmpty() )
    {
        Log.error( "At least one UserPropertyProvider must be specified via openfire.xml or the system properties!" );
    }
}
 
Example 7
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 8
Source File: LdapAuthProvider.java    From Openfire with Apache License 2.0 5 votes vote down vote up
public LdapAuthProvider() {
    // Convert XML based provider setup to Database based
    JiveGlobals.migrateProperty("ldap.authCache.enabled");

    manager = LdapManager.getInstance();
    if (JiveGlobals.getBooleanProperty("ldap.authCache.enabled", false)) {
        String cacheName = "LDAP Authentication";
        authCache = CacheFactory.createCache(cacheName);
    }
}
 
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: HybridUserProvider.java    From Openfire with Apache License 2.0 5 votes vote down vote up
public HybridUserProvider()
{
    // Migrate user provider properties
    JiveGlobals.migrateProperty( "hybridUserProvider.primaryProvider.className" );
    JiveGlobals.migrateProperty( "hybridUserProvider.secondaryProvider.className" );
    JiveGlobals.migrateProperty( "hybridUserProvider.tertiaryProvider.className" );

    // Load primary, secondary, and tertiary user providers.
    final UserProvider primary = instantiate( "hybridUserProvider.primaryProvider.className" );
    if ( primary != null )
    {
        userProviders.add( primary );
    }
    final UserProvider secondary = instantiate( "hybridUserProvider.secondaryProvider.className" );
    if ( secondary != null )
    {
        userProviders.add( secondary );
    }
    final UserProvider tertiary = instantiate( "hybridUserProvider.tertiaryProvider.className" );
    if ( tertiary != null )
    {
        userProviders.add( tertiary );
    }

    // Verify that there's at least one provider available.
    if ( userProviders.isEmpty() )
    {
        Log.error( "At least one UserProvider must be specified via openfire.xml or the system properties!" );
    }
}
 
Example 11
Source File: JDBCUserProvider.java    From Openfire with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a new JDBC user provider.
 */
public JDBCUserProvider() {
    // Convert XML based provider setup to Database based
    JiveGlobals.migrateProperty("jdbcProvider.driver");
    JiveGlobals.migrateProperty("jdbcProvider.connectionString");
    JiveGlobals.migrateProperty("jdbcUserProvider.loadUserSQL");
    JiveGlobals.migrateProperty("jdbcUserProvider.userCountSQL");
    JiveGlobals.migrateProperty("jdbcUserProvider.allUsersSQL");
    JiveGlobals.migrateProperty("jdbcUserProvider.searchSQL");
    JiveGlobals.migrateProperty("jdbcUserProvider.usernameField");
    JiveGlobals.migrateProperty("jdbcUserProvider.nameField");
    JiveGlobals.migrateProperty("jdbcUserProvider.emailField");

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

        // 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");
    }

    // Load database statements for user data.
    loadUserSQL = JiveGlobals.getProperty("jdbcUserProvider.loadUserSQL");
    userCountSQL = JiveGlobals.getProperty("jdbcUserProvider.userCountSQL");
    allUsersSQL = JiveGlobals.getProperty("jdbcUserProvider.allUsersSQL");
    searchSQL = JiveGlobals.getProperty("jdbcUserProvider.searchSQL");
    usernameField = JiveGlobals.getProperty("jdbcUserProvider.usernameField");
    nameField = JiveGlobals.getProperty("jdbcUserProvider.nameField");
    emailField = JiveGlobals.getProperty("jdbcUserProvider.emailField");
}
 
Example 12
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 13
Source File: LdapUserProvider.java    From Openfire with Apache License 2.0 5 votes vote down vote up
public LdapUserProvider() {
    // Convert XML based provider setup to Database based
    JiveGlobals.migrateProperty("ldap.searchFields");

    manager = LdapManager.getInstance();
    searchFields = new LinkedHashMap<>();
    String fieldList = JiveGlobals.getProperty("ldap.searchFields");
    // 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);
        }
    }
}
 
Example 14
Source File: HttpBindManager.java    From Openfire with Apache License 2.0 5 votes vote down vote up
private HttpBindManager() {
    JiveGlobals.migrateProperty(HTTP_BIND_ENABLED);
    JiveGlobals.migrateProperty(HTTP_BIND_PORT);
    JiveGlobals.migrateProperty(HTTP_BIND_SECURE_PORT);
    JiveGlobals.migrateProperty(HTTP_BIND_THREADS);
    JiveGlobals.migrateProperty(HTTP_BIND_FORWARDED);
    JiveGlobals.migrateProperty(HTTP_BIND_FORWARDED_FOR);
    JiveGlobals.migrateProperty(HTTP_BIND_FORWARDED_SERVER);
    JiveGlobals.migrateProperty(HTTP_BIND_FORWARDED_HOST);
    JiveGlobals.migrateProperty(HTTP_BIND_FORWARDED_HOST_NAME);
    JiveGlobals.migrateProperty(HTTP_BIND_CORS_ENABLED);
    JiveGlobals.migrateProperty(HTTP_BIND_CORS_ALLOW_ORIGIN);
    JiveGlobals.migrateProperty(HTTP_BIND_REQUEST_HEADER_SIZE);

    PropertyEventDispatcher.addListener( this );
    this.httpSessionManager = new HttpSessionManager();

    // setup the cache for the allowed origins
    this.setupAllowedOriginsMap();

    // Setup the default handlers. Order is important here. First, evaluate if the 'standard' handlers can be used to fulfill requests.
    this.handlerList.addHandler( createBoshHandler() );
    this.handlerList.addHandler( createWebsocketHandler() );
    this.handlerList.addHandler( createCrossDomainHandler() );

    // When standard handling does not apply, see if any of the handlers in the extension pool of handlers applies to the request.
    this.handlerList.addHandler( this.extensionHandlers );

    // When everything else fails, use the static content handler. This one should be last, as it is mapping to the root context.
    // This means that it will catch everything and prevent the invocation of later handlers.
    final Handler staticContentHandler = createStaticContentHandler();
    if ( staticContentHandler != null )
    {
        this.handlerList.addHandler( staticContentHandler );
    }
}
 
Example 15
Source File: AuthorizationBasedAuthProviderMapper.java    From Openfire with Apache License 2.0 5 votes vote down vote up
public AuthorizationBasedAuthProviderMapper()
{
    // Migrate properties.
    JiveGlobals.migrateProperty( PROPERTY_ADMINPROVIDER_CLASSNAME );
    JiveGlobals.migrateProperty( PROPERTY_USERPROVIDER_CLASSNAME );

    // Instantiate providers.
    adminProvider = instantiateProvider( PROPERTY_ADMINPROVIDER_CLASSNAME );
    userProvider = instantiateProvider( PROPERTY_USERPROVIDER_CLASSNAME );
}
 
Example 16
Source File: UpdateManager.java    From Openfire with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(XMPPServer server) {
    super.initialize(server);

    JiveGlobals.migrateProperty(ENABLED.getKey());
    JiveGlobals.migrateProperty(NOTIFY_ADMINS.getKey());
}
 
Example 17
Source File: JDBCGroupProvider.java    From Openfire with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor of the JDBCGroupProvider class.
 */
public JDBCGroupProvider() {
    // Convert XML based provider setup to Database based
    JiveGlobals.migrateProperty("jdbcProvider.driver");
    JiveGlobals.migrateProperty("jdbcProvider.connectionString");
    JiveGlobals.migrateProperty("jdbcGroupProvider.groupCountSQL");
    JiveGlobals.migrateProperty("jdbcGroupProvider.allGroupsSQL");
    JiveGlobals.migrateProperty("jdbcGroupProvider.userGroupsSQL");
    JiveGlobals.migrateProperty("jdbcGroupProvider.descriptionSQL");
    JiveGlobals.migrateProperty("jdbcGroupProvider.loadMembersSQL");
    JiveGlobals.migrateProperty("jdbcGroupProvider.loadAdminsSQL");

    useConnectionProvider = JiveGlobals.getBooleanProperty("jdbcGroupProvider.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
    groupCountSQL = JiveGlobals.getProperty("jdbcGroupProvider.groupCountSQL");
    allGroupsSQL = JiveGlobals.getProperty("jdbcGroupProvider.allGroupsSQL");
    userGroupsSQL = JiveGlobals.getProperty("jdbcGroupProvider.userGroupsSQL");
    descriptionSQL = JiveGlobals.getProperty("jdbcGroupProvider.descriptionSQL");
    loadMembersSQL = JiveGlobals.getProperty("jdbcGroupProvider.loadMembersSQL");
    loadAdminsSQL = JiveGlobals.getProperty("jdbcGroupProvider.loadAdminsSQL");
}
 
Example 18
Source File: HttpSessionManager.java    From Openfire with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new HttpSessionManager instance.
 */
public HttpSessionManager() {
    
    JiveGlobals.migrateProperty("xmpp.httpbind.worker.threads");
    JiveGlobals.migrateProperty("xmpp.httpbind.worker.timeout");
}
 
Example 19
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 20
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());
    }
}