Commit ca8e0205 authored by Matt Tucker's avatar Matt Tucker Committed by matt

Fixes.

git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@2654 b35dd754-fafc-0310-a699-88a17e54d16e
parent f94daab3
...@@ -23,7 +23,7 @@ import java.util.Properties; ...@@ -23,7 +23,7 @@ import java.util.Properties;
/** /**
* An AuthProvider that authenticates using a POP3 server. It will automatically create * An AuthProvider that authenticates using a POP3 server. It will automatically create
* local user accounts as needed. To enable this auth provider, edit the XML config file * local user accounts as needed. To enable this provider, edit the XML config file
* file and set: * file and set:
* *
* <pre> * <pre>
...@@ -31,6 +31,9 @@ import java.util.Properties; ...@@ -31,6 +31,9 @@ import java.util.Properties;
* &lt;auth&gt; * &lt;auth&gt;
* &lt;className&gt;org.jivesoftware.messenger.auth.POP3AuthProvider&lt;/className&gt; * &lt;className&gt;org.jivesoftware.messenger.auth.POP3AuthProvider&lt;/className&gt;
* &lt;/auth&gt; * &lt;/auth&gt;
* &lt;user&gt;
* &lt;className&gt;org.jivesoftware.messenger.user.POP3UserProvider&lt;/className&gt;
* &lt;/user&gt;
* &lt;/provider&gt; * &lt;/provider&gt;
* </pre> * </pre>
* *
...@@ -73,23 +76,22 @@ public class POP3AuthProvider implements AuthProvider { ...@@ -73,23 +76,22 @@ public class POP3AuthProvider implements AuthProvider {
* Initialiazes the POP3AuthProvider with values from the global config file. * Initialiazes the POP3AuthProvider with values from the global config file.
*/ */
public POP3AuthProvider() { public POP3AuthProvider() {
if (Boolean.valueOf(JiveGlobals.getXMLProperty("pop3.authCache.enabled")).booleanValue()) { if (Boolean.valueOf(JiveGlobals.getXMLProperty("pop3.authCache.enabled"))) {
int maxSize = JiveGlobals.getXMLProperty("pop3.authCache.size", 512*1024); int maxSize = JiveGlobals.getXMLProperty("pop3.authCache.size", 512*1024);
long maxLifetime = (long)JiveGlobals.getXMLProperty("pop3.authCache.maxLifetime", long maxLifetime = (long)JiveGlobals.getXMLProperty("pop3.authCache.maxLifetime",
(int)JiveConstants.HOUR * 1); (int)JiveConstants.HOUR);
authCache = new Cache("POP3 Auth Cache", maxSize, maxLifetime); authCache = new Cache("POP3 Auth Cache", maxSize, maxLifetime);
} }
useSSL = Boolean.valueOf(JiveGlobals.getXMLProperty("pop3.ssl")).booleanValue(); useSSL = Boolean.valueOf(JiveGlobals.getXMLProperty("pop3.ssl"));
authRequiresDomain = Boolean.valueOf(JiveGlobals.getXMLProperty("pop3.authRequiresDomain") authRequiresDomain = Boolean.valueOf(JiveGlobals.getXMLProperty("pop3.authRequiresDomain"));
).booleanValue();
host = JiveGlobals.getXMLProperty("pop3.host"); host = JiveGlobals.getXMLProperty("pop3.host");
if (host == null || host.length() < 1) { if (host == null || host.length() < 1) {
throw new IllegalArgumentException("pop3.host is null or empty"); throw new IllegalArgumentException("pop3.host is null or empty");
} }
debugEnabled = Boolean.valueOf(JiveGlobals.getXMLProperty("pop3.debug")).booleanValue(); debugEnabled = Boolean.valueOf(JiveGlobals.getXMLProperty("pop3.debug"));
domain = JiveGlobals.getXMLProperty("pop3.domain"); domain = JiveGlobals.getXMLProperty("pop3.domain");
...@@ -157,7 +159,8 @@ public class POP3AuthProvider implements AuthProvider { ...@@ -157,7 +159,8 @@ public class POP3AuthProvider implements AuthProvider {
try { try {
store.close(); store.close();
} }
catch(Exception e) { catch (Exception e) {
// Ignore.
} }
// If cache is enabled, add the item to cache. // If cache is enabled, add the item to cache.
...@@ -175,10 +178,13 @@ public class POP3AuthProvider implements AuthProvider { ...@@ -175,10 +178,13 @@ public class POP3AuthProvider implements AuthProvider {
try { try {
Log.debug("Automatically creating new user account for " + username); Log.debug("Automatically creating new user account for " + username);
// Create user; use a random password for better safety in the future. // Create user; use a random password for better safety in the future.
userManager.createUser(username, StringUtils.randomString(8), null, email); // Note that we have to go to the user provider directly -- because the
// provider is read-only, UserManager will usually deny access to createUser.
UserManager.getUserProvider().createUser(username, StringUtils.randomString(8),
null, email);
} }
catch (UserAlreadyExistsException uaee) { catch (UserAlreadyExistsException uaee) {
// Ignore.
} }
} }
} }
......
/**
* $RCSfile$
* $Revision: 1765 $
* $Date: 2005-08-10 22:37:59 -0700 (Wed, 10 Aug 2005) $
*
* Copyright (C) 2005 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.messenger.user;
/**
* A UserProvider to be used in conjunction with
* {@link org.jivesoftware.messenger.auth.POP3AuthProvider POP3AuthProvider}, which
* authenticates using a POP3 server. New user accounts will automatically be created
* as needed (upon successful initial authentication) and are subsequently treated as
* read-only. To enable this provider, edit the XML config file file and set:
*
* <pre>
* &lt;provider&gt;
* &lt;auth&gt;
* &lt;className&gt;org.jivesoftware.messenger.auth.POP3AuthProvider&lt;/className&gt;
* &lt;/auth&gt;
* &lt;user&gt;
* &lt;className&gt;org.jivesoftware.messenger.user.POP3UserProvider&lt;/className&gt;
* &lt;/user&gt;
* &lt;/provider&gt;
* </pre>
*
* @see org.jivesoftware.messenger.auth.POP3AuthProvider POP3AuthProvider
* @author Sean Meiners
*/
public class POP3UserProvider extends DefaultUserProvider {
public boolean isReadOnly() {
return true;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment