Commit 307b06e0 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Modified user creation, update or deletion to check if the provider is read-only.

git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@2789 b35dd754-fafc-0310-a699-88a17e54d16e
parent f531e993
...@@ -89,6 +89,10 @@ public class DefaultUserProvider implements UserProvider { ...@@ -89,6 +89,10 @@ public class DefaultUserProvider implements UserProvider {
public User createUser(String username, String password, String name, String email) public User createUser(String username, String password, String name, String email)
throws UserAlreadyExistsException throws UserAlreadyExistsException
{ {
if (isReadOnly()) {
// Reject the operation since the provider is read-only
throw new UnsupportedOperationException();
}
try { try {
loadUser(username); loadUser(username);
// The user already exists since no exception, so: // The user already exists since no exception, so:
...@@ -134,6 +138,10 @@ public class DefaultUserProvider implements UserProvider { ...@@ -134,6 +138,10 @@ public class DefaultUserProvider implements UserProvider {
} }
public void deleteUser(String username) { public void deleteUser(String username) {
if (isReadOnly()) {
// Reject the operation since the provider is read-only
throw new UnsupportedOperationException();
}
Connection con = null; Connection con = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
boolean abortTransaction = false; boolean abortTransaction = false;
...@@ -248,6 +256,10 @@ public class DefaultUserProvider implements UserProvider { ...@@ -248,6 +256,10 @@ public class DefaultUserProvider implements UserProvider {
} }
public void setName(String username, String name) throws UserNotFoundException { public void setName(String username, String name) throws UserNotFoundException {
if (isReadOnly()) {
// Reject the operation since the provider is read-only
throw new UnsupportedOperationException();
}
Connection con = null; Connection con = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
try { try {
...@@ -269,6 +281,10 @@ public class DefaultUserProvider implements UserProvider { ...@@ -269,6 +281,10 @@ public class DefaultUserProvider implements UserProvider {
} }
public void setEmail(String username, String email) throws UserNotFoundException { public void setEmail(String username, String email) throws UserNotFoundException {
if (isReadOnly()) {
// Reject the operation since the provider is read-only
throw new UnsupportedOperationException();
}
Connection con = null; Connection con = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
try { try {
...@@ -290,6 +306,10 @@ public class DefaultUserProvider implements UserProvider { ...@@ -290,6 +306,10 @@ public class DefaultUserProvider implements UserProvider {
} }
public void setCreationDate(String username, Date creationDate) throws UserNotFoundException { public void setCreationDate(String username, Date creationDate) throws UserNotFoundException {
if (isReadOnly()) {
// Reject the operation since the provider is read-only
throw new UnsupportedOperationException();
}
Connection con = null; Connection con = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
try { try {
...@@ -311,6 +331,10 @@ public class DefaultUserProvider implements UserProvider { ...@@ -311,6 +331,10 @@ public class DefaultUserProvider implements UserProvider {
} }
public void setModificationDate(String username, Date modificationDate) throws UserNotFoundException { public void setModificationDate(String username, Date modificationDate) throws UserNotFoundException {
if (isReadOnly()) {
// Reject the operation since the provider is read-only
throw new UnsupportedOperationException();
}
Connection con = null; Connection con = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
try { try {
...@@ -332,6 +356,10 @@ public class DefaultUserProvider implements UserProvider { ...@@ -332,6 +356,10 @@ public class DefaultUserProvider implements UserProvider {
} }
public String getPassword(String username) throws UserNotFoundException { public String getPassword(String username) throws UserNotFoundException {
if (!supportsPasswordRetrieval()) {
// Reject the operation since the provider is read-only
throw new UnsupportedOperationException();
}
Connection con = null; Connection con = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
try { try {
...@@ -355,8 +383,11 @@ public class DefaultUserProvider implements UserProvider { ...@@ -355,8 +383,11 @@ public class DefaultUserProvider implements UserProvider {
} }
} }
public void setPassword(String username, String password) throws UserNotFoundException public void setPassword(String username, String password) throws UserNotFoundException {
{ if (isReadOnly()) {
// Reject the operation since the provider is read-only
throw new UnsupportedOperationException();
}
Connection con = null; Connection con = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
try { try {
......
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