* @author Erik Brakkee
*/
public class JaasUserAccessor implements UserAccessor {
- /**
- * User administration to use.
- */
- private UserAdministration admin;
/**
* Class of the JAAS user principal.
* @param aUserClassName
* Class name of the user principal.
*/
- public JaasUserAccessor(UserAdministration aAdmin, String aUserClassName) {
- admin = aAdmin;
-
+ public JaasUserAccessor(String aUserClassName) {
try {
userPrincipalClass = Class.forName(aUserClassName);
import java.util.TreeSet;
import javax.persistence.CascadeType;
-import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import org.apache.log4j.Logger;
-import java.security.NoSuchAlgorithmException;
-
/**
* User administration initializer. It populates the user administration with a
* number of groups and users but only in case no users exist.
*
*/
public UserAdminInitializer(UserAdministration aAdmin, String[] aUsers,
- String[] aGroups, String[] aPasswords) throws UserMgtException,
- NoSuchAlgorithmException {
+ String[] aGroups, String[] aPasswords) throws UserMgtException {
if ((aUsers.length != aGroups.length) ||
(aUsers.length != aPasswords.length)) {
throw new IllegalArgumentException(
package org.wamblee.security.authentication;
import java.util.List;
-import java.util.Set;
-
-import org.wamblee.security.authentication.UserMgtException.Reason;
/**
* Interface for user administration. Manages the users and groups.
import static org.wamblee.security.authentication.UserMgtException.Reason.*;
import java.util.ArrayList;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import org.wamblee.security.authentication.UserMgtException.Reason;
import javax.persistence.TypedQuery;
import org.wamblee.cache.Cache;
-import org.wamblee.cache.ZeroCache;
import org.wamblee.persistence.JpaMergeSupport;
import org.wamblee.security.authentication.AbstractUserSet;
import org.wamblee.security.authentication.Group;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
-import javax.persistence.Transient;
import javax.persistence.Version;
-import org.wamblee.security.authentication.User;
-import org.wamblee.security.authentication.UserAdministration;
-
/**
* Represents an authorization rule to determine whether an operation is allowed
* on a resource.
import javax.persistence.Table;
import javax.persistence.Version;
-import org.wamblee.security.authentication.UserAccessor;
-
/**
* Service to determine if access to a certain resource is allowed.
*
import javax.persistence.Table;
import javax.persistence.Version;
-import org.wamblee.security.authentication.User;
-
/**
* Condition used to match a user against a specified set of users.
*
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
-import org.wamblee.security.authentication.User;
import org.wamblee.security.authentication.UserAdministration;
/**
*/
package org.wamblee.security.authorization;
-import org.wamblee.security.authentication.User;
import org.wamblee.security.authentication.UserAdministration;
/**
import javax.persistence.Entity;
import javax.persistence.Transient;
-import org.wamblee.security.authentication.User;
import org.wamblee.security.authentication.UserAdministration;
import static org.wamblee.security.authorization.AuthorizationResult.*;
-import javax.enterprise.inject.Typed;
import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.CascadeType;
import javax.persistence.Column;
-import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Transient;
import org.apache.log4j.Logger;
-import org.wamblee.security.authentication.User;
import org.wamblee.security.authentication.UserAdministration;
/**
*/
package org.wamblee.security.authorization;
-import org.wamblee.security.authentication.User;
-import org.wamblee.security.authentication.UserAdminInitializer;
import org.wamblee.security.authentication.UserAdministration;
/**
import org.wamblee.cache.ComputedValue;
import org.wamblee.cache.ComputedValue.Computation;
-import org.wamblee.persistence.JpaMergeSupport;
import org.wamblee.security.authentication.UserAccessor;
import org.wamblee.security.authentication.UserAdministration;
import org.wamblee.security.authorization.AbstractAuthorizationService;
-import org.wamblee.security.authorization.AbstractAuthorizationRule;
import org.wamblee.security.authorization.AuthorizationRule;
import org.wamblee.security.authorization.AuthorizationService;
import org.wamblee.security.authorization.DefaultAuthorizationService;
*/
package org.wamblee.security.authentication;
+import java.util.List;
+
import junit.framework.TestCase;
import org.apache.log4j.Logger;
-import org.junit.Test;
-
-import org.wamblee.security.authentication.Group;
-import org.wamblee.security.authentication.GroupSet;
-import org.wamblee.security.authentication.InMemoryGroupSet;
-import org.wamblee.security.authentication.InMemoryUserSet;
-import org.wamblee.security.authentication.RegexpNameValidator;
-import org.wamblee.security.authentication.User;
-import org.wamblee.security.authentication.UserAdministration;
-import org.wamblee.security.authentication.UserAdministrationImpl;
-import org.wamblee.security.authentication.UserMgtException;
-import org.wamblee.security.authentication.UserSet;
import org.wamblee.security.authentication.UserMgtException.Reason;
import org.wamblee.security.encryption.Md5HexMessageDigester;
-import java.util.List;
-import java.util.Set;
-
/**
* Test of user administration implementation.
*
*/
package org.wamblee.security.authorization;
+import static org.wamblee.security.authorization.AuthorizationResult.*;
import junit.framework.TestCase;
-import static org.wamblee.security.authorization.AuthorizationResult.DENIED;
-import static org.wamblee.security.authorization.AuthorizationResult.GRANTED;
-import org.junit.Ignore;
import org.wamblee.security.authentication.UserAccessor;
import org.wamblee.security.authentication.UserAdministration;
*/
package org.wamblee.security.authorization;
-import static org.wamblee.security.authorization.AuthorizationResult.DENIED;
-import static org.wamblee.security.authorization.AuthorizationResult.GRANTED;
+import static org.wamblee.security.authorization.AuthorizationResult.*;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Transient;
-import org.wamblee.security.authentication.User;
-
/**
* Test authorization rule that also counts the number of times the rule
* matches.
*/
package org.wamblee.security.authorization;
-import junit.framework.TestCase;
-
-import org.wamblee.security.authentication.Group;
import org.wamblee.security.authentication.InMemoryGroupSet;
import org.wamblee.security.authentication.InMemoryUserSet;
import org.wamblee.security.authentication.RegexpNameValidator;
-import org.wamblee.security.authentication.User;
import org.wamblee.security.authentication.UserAccessor;
import org.wamblee.security.authentication.UserAdministration;
import org.wamblee.security.authentication.UserAdministrationImpl;
-import org.wamblee.security.authentication.UserMgtException;
import org.wamblee.security.authentication.UserMgtException.Reason;
import org.wamblee.security.encryption.Md5HexMessageDigester;
*/
package org.wamblee.security.authorization;
+import static org.wamblee.security.authorization.AuthorizationResult.*;
import junit.framework.TestCase;
-import static org.wamblee.security.authorization.AuthorizationResult.GRANTED;
-import static org.wamblee.security.authorization.AuthorizationResult.UNDECIDED;
-import static org.wamblee.security.authorization.AuthorizationResult.UNSUPPORTED_RESOURCE;
-
-import org.wamblee.security.authentication.User;
/**
* Tests for the {@link org.wamblee.security.authorization.UrlAuthorizationRule}
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.junit.Ignore;
-import org.wamblee.cache.EhCache;
-import org.wamblee.io.ClassPathResource;
-import org.wamblee.security.authentication.GroupSet;
-import org.wamblee.security.authentication.NameValidator;
-import org.wamblee.security.authentication.RegexpNameValidator;
-import org.wamblee.security.authentication.User;
import org.wamblee.security.authentication.UserAdministration;
-import org.wamblee.security.authentication.UserAdministrationImpl;
import org.wamblee.security.authentication.UserAdministrationImplTest;
-import org.wamblee.security.authentication.UserSet;
-import org.wamblee.security.authentication.jpa.JpaGroupSet;
-import org.wamblee.security.authentication.jpa.JpaUserSet;
-import org.wamblee.security.encryption.Md5HexMessageDigester;
-import org.wamblee.security.encryption.MessageDigester;
-import org.wamblee.support.persistence.JpaTester;
-import org.wamblee.support.persistence.TransactionProxyFactory;
import org.wamblee.support.persistence.DatabaseUtils.JdbcUnitOfWork;
/**
*/
package org.wamblee.security.authorization.jpa;
-import static org.wamblee.security.authorization.AuthorizationResult.*;
-
-import javax.persistence.EntityManager;
-
import org.apache.log4j.Logger;
import org.wamblee.security.authentication.jpa.SecurityPersistenceUnit;
-import org.wamblee.security.authorization.AllOperation;
-import org.wamblee.security.authorization.AuthorizationRule;
import org.wamblee.security.authorization.AuthorizationService;
import org.wamblee.security.authorization.AuthorizationServiceTest;
-import org.wamblee.security.authorization.DefaultAuthorizationService;
import org.wamblee.support.persistence.JpaTester;
import org.wamblee.support.persistence.TransactionProxyFactory;
-import org.wamblee.support.persistence.JpaBuilder.JpaUnitOfWork;
/**
* Unit test for the persistent authorization service.
private JpaTester jpaTester;
- private AuthorizationService authorizationService;
-
@Override
protected void setUp() throws Exception {
jpaTester = new JpaTester(new SecurityPersistenceUnit());
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.wamblee.persistence.PersistentFactory.EntityAccessor;
import org.wamblee.reflection.ReflectionUtils;
/**
throw new IllegalArgumentException(
"Mismatch between primary key values: " + aPersistent + " " +
aMerged);
- } else {
- persistentWrapper.setPersistedVersion(mergedWrapper
- .getPersistedVersion());
- persistentWrapper.setPrimaryKey(mergedWrapper.getPrimaryKey());
}
+ persistentWrapper.setPersistedVersion(mergedWrapper
+ .getPersistedVersion());
+ persistentWrapper.setPrimaryKey(mergedWrapper.getPrimaryKey());
List<Method> methods = ReflectionUtils.getAllMethods(aPersistent
.getClass(), Object.class);
} catch (IOException e) {
throw new TransformerException(e.getMessage(), e);
}
- } else {
- throw new TransformerException("Cannot read '" + aXslt + "'");
- }
+ }
+ throw new TransformerException("Cannot read '" + aXslt + "'");
}
return resolver.resolve(aXslt, "");
LOG.info("Expected exception occured " + t.getMessage());
return; // ok
- } else {
- throw new RuntimeException(t);
- }
+ }
+ throw new RuntimeException(t);
}
}
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.wamblee.support.persistence.eclipselink;
import org.eclipse.persistence.config.SessionCustomizer;
try {
context = new InitialContext();
- if (null != context) {
- connector = (JNDIConnector) aSession.getLogin().getConnector(); // possible
- // CCE
- // Change from COMPOSITE_NAME_LOOKUP to STRING_LOOKUP
- // Note: if both jta and non-jta elements exist this will only
- // change the first one - and may still result in
- // the COMPOSITE_NAME_LOOKUP being set
- // Make sure only jta-data-source is in persistence.xml with no
- // non-jta-data-source property set
+ connector = (JNDIConnector) aSession.getLogin().getConnector(); // possible
+ // CCE
+ // Change from COMPOSITE_NAME_LOOKUP to STRING_LOOKUP
+ // Note: if both jta and non-jta elements exist this will only
+ // change the first one - and may still result in
+ // the COMPOSITE_NAME_LOOKUP being set
+ // Make sure only jta-data-source is in persistence.xml with no
+ // non-jta-data-source property set
- connector.setLookupType(JNDIConnector.STRING_LOOKUP);
+ connector.setLookupType(JNDIConnector.STRING_LOOKUP);
- // Or, if you are specifying both JTA and non-JTA in your
- // persistence.xml then set both connectors to be safe
- JNDIConnector writeConnector = (JNDIConnector) aSession
- .getLogin().getConnector();
- writeConnector.setLookupType(JNDIConnector.STRING_LOOKUP);
+ // Or, if you are specifying both JTA and non-JTA in your
+ // persistence.xml then set both connectors to be safe
+ JNDIConnector writeConnector = (JNDIConnector) aSession.getLogin()
+ .getConnector();
+ writeConnector.setLookupType(JNDIConnector.STRING_LOOKUP);
- JNDIConnector readConnector = (JNDIConnector) ((DatabaseLogin) ((ServerSession) aSession)
- .getReadConnectionPool().getLogin()).getConnector();
- readConnector.setLookupType(JNDIConnector.STRING_LOOKUP);
+ JNDIConnector readConnector = (JNDIConnector) ((DatabaseLogin) ((ServerSession) aSession)
+ .getReadConnectionPool().getLogin()).getConnector();
+ readConnector.setLookupType(JNDIConnector.STRING_LOOKUP);
- System.out.println("JndiSessionCustomizer: configured " +
- connector.getName());
- } else {
- throw new Exception("JndiSessionCustomizer: Context is null");
- }
+ System.out.println("JndiSessionCustomizer: configured " +
+ connector.getName());
} catch (Exception e) {
e.printStackTrace();
}
*/
package org.wamblee.support.persistence.eclipselink;
-import static junit.framework.Assert.assertEquals;
-
-import org.dbunit.IDatabaseTester;
-
-import org.dbunit.dataset.ITable;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import org.wamblee.support.persistence.Database;
-import org.wamblee.support.persistence.DatabaseBuilder;
-import org.wamblee.support.persistence.DatabaseUtils;
import org.wamblee.support.persistence.DatabaseUtilsTestBase;
-import org.wamblee.support.persistence.JpaBuilder;
-import org.wamblee.support.persistence.JpaBuilder.JpaUnitOfWork;
-import org.wamblee.support.persistence.PersistenceUnitDescription;
-
-import javax.persistence.EntityManager;
-
-import javax.sql.DataSource;
/**
*
*/
package org.wamblee.support.persistence.eclipselink;
-import static junit.framework.Assert.*;
-
-import org.dbunit.DataSourceDatabaseTester;
-import org.dbunit.DatabaseTestCase;
-import org.dbunit.IDatabaseTester;
-
-import org.dbunit.dataset.ITable;
-import org.dbunit.dataset.filter.ITableFilterSimple;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import org.wamblee.support.persistence.DatabaseUtils;
-import org.wamblee.support.persistence.JpaBuilder;
-import org.wamblee.support.persistence.JpaBuilder.JpaUnitOfWork;
-import org.wamblee.support.persistence.JpaTester;
import org.wamblee.support.persistence.MyEntityExampleTestBase;
-import javax.persistence.EntityManager;
-import javax.persistence.Persistence;
-
-import javax.sql.DataSource;
-
/**
* This class shows an example of how to test an entity using jpa.
*/
*/
package org.wamblee.support.persistence;
-import java.util.logging.Logger;
-
-import javax.sql.DataSource;
/**
* Database that encapsulates connection to an external database. Database
*/
public class ExternalDatabase extends AbstractDatabase {
- private static final Logger LOGGER = Logger
- .getLogger(ExternalDatabase.class.getName());
-
/**
* System property/environment variable that defines the database URL.
*/
private String itsUser;
private String itsPassword;
- private DataSource itsDataSource;
-
public ExternalDatabase() {
// Empty
}
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.wamblee.support.persistence.toplink;
import oracle.toplink.essentials.jndi.JNDIConnector;
try {
context = new InitialContext();
- if (null != context) {
- connector = (JNDIConnector) aSession.getLogin().getConnector(); // possible
- // CCE
- // Change from COMPOSITE_NAME_LOOKUP to STRING_LOOKUP
- // Note: if both jta and non-jta elements exist this will only
- // change the first one - and may still result in
- // the COMPOSITE_NAME_LOOKUP being set
- // Make sure only jta-data-source is in persistence.xml with no
- // non-jta-data-source property set
+ connector = (JNDIConnector) aSession.getLogin().getConnector(); // possible
+ // CCE
+ // Change from COMPOSITE_NAME_LOOKUP to STRING_LOOKUP
+ // Note: if both jta and non-jta elements exist this will only
+ // change the first one - and may still result in
+ // the COMPOSITE_NAME_LOOKUP being set
+ // Make sure only jta-data-source is in persistence.xml with no
+ // non-jta-data-source property set
- connector.setLookupType(JNDIConnector.STRING_LOOKUP);
+ connector.setLookupType(JNDIConnector.STRING_LOOKUP);
- // Or, if you are specifying both JTA and non-JTA in your
- // persistence.xml then set both connectors to be safe
- JNDIConnector writeConnector = (JNDIConnector) aSession
- .getLogin().getConnector();
- writeConnector.setLookupType(JNDIConnector.STRING_LOOKUP);
+ // Or, if you are specifying both JTA and non-JTA in your
+ // persistence.xml then set both connectors to be safe
+ JNDIConnector writeConnector = (JNDIConnector) aSession.getLogin()
+ .getConnector();
+ writeConnector.setLookupType(JNDIConnector.STRING_LOOKUP);
- JNDIConnector readConnector = (JNDIConnector) ((DatabaseLogin) ((ServerSession) aSession)
- .getReadConnectionPool().getLogin()).getConnector();
- readConnector.setLookupType(JNDIConnector.STRING_LOOKUP);
+ JNDIConnector readConnector = (JNDIConnector) ((DatabaseLogin) ((ServerSession) aSession)
+ .getReadConnectionPool().getLogin()).getConnector();
+ readConnector.setLookupType(JNDIConnector.STRING_LOOKUP);
- System.out.println("JndiSessionCustomizer: configured " +
- connector.getName());
- } else {
- throw new Exception("JndiSessionCustomizer: Context is null");
- }
+ System.out.println("JndiSessionCustomizer: configured " +
+ connector.getName());
} catch (Exception e) {
e.printStackTrace();
}
*/
package org.wamblee.support.persistence.toplink;
-import static junit.framework.Assert.assertEquals;
-
-import org.dbunit.IDatabaseTester;
-
-import org.dbunit.dataset.ITable;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import org.wamblee.support.persistence.Database;
-import org.wamblee.support.persistence.DatabaseBuilder;
-import org.wamblee.support.persistence.DatabaseUtils;
import org.wamblee.support.persistence.DatabaseUtilsTestBase;
-import org.wamblee.support.persistence.JpaBuilder;
-import org.wamblee.support.persistence.JpaBuilder.JpaUnitOfWork;
-import org.wamblee.support.persistence.PersistenceUnitDescription;
-
-import javax.persistence.EntityManager;
-
-import javax.sql.DataSource;
/**
*
*/
package org.wamblee.support.persistence.toplink;
-import static junit.framework.Assert.*;
-
-import org.dbunit.DataSourceDatabaseTester;
-import org.dbunit.DatabaseTestCase;
-import org.dbunit.IDatabaseTester;
-
-import org.dbunit.dataset.ITable;
-import org.dbunit.dataset.filter.ITableFilterSimple;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import org.wamblee.support.persistence.DatabaseUtils;
-import org.wamblee.support.persistence.JpaBuilder;
-import org.wamblee.support.persistence.JpaBuilder.JpaUnitOfWork;
-import org.wamblee.support.persistence.JpaTester;
import org.wamblee.support.persistence.MyEntityExampleTestBase;
-import javax.persistence.EntityManager;
-import javax.persistence.Persistence;
-
-import javax.sql.DataSource;
-
/**
* This class shows an example of how to test an entity using jpa.
*/