git://wamblee.org
/
utils
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
fa0390b
)
(no commit message)
author
Erik Brakkee
<erik@brakkee.org>
Fri, 30 Apr 2010 22:20:14 +0000
(22:20 +0000)
committer
Erik Brakkee
<erik@brakkee.org>
Fri, 30 Apr 2010 22:20:14 +0000
(22:20 +0000)
security/impl/src/main/java/org/wamblee/security/authorization/AuthorizationService.java
patch
|
blob
|
history
security/impl/src/main/java/org/wamblee/usermgt/Group.java
patch
|
blob
|
history
security/impl/src/main/java/org/wamblee/usermgt/InMemoryGroupSet.java
patch
|
blob
|
history
security/impl/src/main/java/org/wamblee/usermgt/jpa/JpaGroupSet.java
patch
|
blob
|
history
support/general/src/main/java/org/wamblee/persistence/PersistentFactory.java
patch
|
blob
|
history
test/enterprise/src/main/java/org/wamblee/support/ThreadSpecificProxyFactory.java
patch
|
blob
|
history
diff --git
a/security/impl/src/main/java/org/wamblee/security/authorization/AuthorizationService.java
b/security/impl/src/main/java/org/wamblee/security/authorization/AuthorizationService.java
index 7a0816a9713d2cbb97637bc5a3aef99a1bb79726..349ef757c0076def4f8814333b18b3d6df8f7c16 100644
(file)
--- a/
security/impl/src/main/java/org/wamblee/security/authorization/AuthorizationService.java
+++ b/
security/impl/src/main/java/org/wamblee/security/authorization/AuthorizationService.java
@@
-12,7
+12,7
@@
* 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.
* 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.security.authorization;
import org.wamblee.usermgt.UserAccessor;
package org.wamblee.security.authorization;
import org.wamblee.usermgt.UserAccessor;
@@
-37,12
+37,17
@@
public interface AuthorizationService {
boolean isAllowed(Object aResource, Operation aOperation);
/**
boolean isAllowed(Object aResource, Operation aOperation);
/**
- * Checks if the given operation is allowed on the resource.
- * @param <T> Type of resource
- * @param aResource Resource.
- * @param aOperation Operation.
+ * Checks if the given operation is allowed on the resource.
+ *
+ * @param <T>
+ * Type of resource
+ * @param aResource
+ * Resource.
+ * @param aOperation
+ * Operation.
* @return Resource passed in in case access is allowed
* @return Resource passed in in case access is allowed
- * @throws AuthorizationException In case access is denied.
+ * @throws AuthorizationException
+ * In case access is denied.
*/
<T> T check(T aResource, Operation aOperation);
*/
<T> T check(T aResource, Operation aOperation);
diff --git
a/security/impl/src/main/java/org/wamblee/usermgt/Group.java
b/security/impl/src/main/java/org/wamblee/usermgt/Group.java
index 87ab4ac7c9cd980e8b311adbcde9fe78412a471c..b203c63d20dfb74d0e89536400f3761726306622 100644
(file)
--- a/
security/impl/src/main/java/org/wamblee/usermgt/Group.java
+++ b/
security/impl/src/main/java/org/wamblee/usermgt/Group.java
@@
-145,8
+145,8
@@
public class Group implements Serializable, Comparable {
public Long getPrimaryKey() {
return primaryKey;
}
public Long getPrimaryKey() {
return primaryKey;
}
-
- public void setPrimaryKey(Long aKey) {
+
+ public void setPrimaryKey(Long aKey) {
primaryKey = aKey;
}
primaryKey = aKey;
}
diff --git
a/security/impl/src/main/java/org/wamblee/usermgt/InMemoryGroupSet.java
b/security/impl/src/main/java/org/wamblee/usermgt/InMemoryGroupSet.java
index 227e8853bca8b980e8821c571eb268da5c247dc9..ce2d7b8b1206ee2cf456e4fc62ade5c5fb42954b 100644
(file)
--- a/
security/impl/src/main/java/org/wamblee/usermgt/InMemoryGroupSet.java
+++ b/
security/impl/src/main/java/org/wamblee/usermgt/InMemoryGroupSet.java
@@
-12,7
+12,7
@@
* 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.
* 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.usermgt;
import java.util.ArrayList;
package org.wamblee.usermgt;
import java.util.ArrayList;
@@
-27,9
+27,9
@@
import java.util.concurrent.atomic.AtomicLong;
* @author Erik Brakkee
*/
public class InMemoryGroupSet implements GroupSet {
* @author Erik Brakkee
*/
public class InMemoryGroupSet implements GroupSet {
-
+
private AtomicLong pk = new AtomicLong(1l);
private AtomicLong pk = new AtomicLong(1l);
-
+
/**
* Groups.
*/
/**
* Groups.
*/
@@
-49,8
+49,8
@@
public class InMemoryGroupSet implements GroupSet {
* org.wamblee.usermgt.GroupSet#groupModified(org.wamblee.usermgt.Group)
*/
public void groupModified(Group aGroup) {
* org.wamblee.usermgt.GroupSet#groupModified(org.wamblee.usermgt.Group)
*/
public void groupModified(Group aGroup) {
- for (int i = 0; i < groups.size(); i++) {
- if (groups.get(i).getPrimaryKey().equals(aGroup.getPrimaryKey())) {
+ for (int i = 0; i < groups.size(); i++) {
+ if (groups.get(i).getPrimaryKey().equals(aGroup.getPrimaryKey())) {
groups.remove(i);
groups.add(aGroup);
return;
groups.remove(i);
groups.add(aGroup);
return;
@@
-89,8
+89,8
@@
public class InMemoryGroupSet implements GroupSet {
*/
public boolean add(Group aGroup) {
aGroup.setPrimaryKey(pk.getAndIncrement());
*/
public boolean add(Group aGroup) {
aGroup.setPrimaryKey(pk.getAndIncrement());
- if (
find(aGroup.getName()) != null ) {
- return false;
+ if (
find(aGroup.getName()) != null) {
+ return false;
}
return groups.add(aGroup);
}
}
return groups.add(aGroup);
}
diff --git
a/security/impl/src/main/java/org/wamblee/usermgt/jpa/JpaGroupSet.java
b/security/impl/src/main/java/org/wamblee/usermgt/jpa/JpaGroupSet.java
index 763fced4e464512ef6e927cecfb93be7785651ec..b9db23975f748f71e3124eb7a45b5d4c8a18bd7b 100644
(file)
--- a/
security/impl/src/main/java/org/wamblee/usermgt/jpa/JpaGroupSet.java
+++ b/
security/impl/src/main/java/org/wamblee/usermgt/jpa/JpaGroupSet.java
@@
-12,10
+12,10
@@
import org.wamblee.usermgt.Group;
import org.wamblee.usermgt.GroupSet;
public class JpaGroupSet implements GroupSet {
import org.wamblee.usermgt.GroupSet;
public class JpaGroupSet implements GroupSet {
-
- private EntityManager em;
-
- public JpaGroupSet(EntityManager aEm) {
+
+ private EntityManager em;
+
+ public JpaGroupSet(EntityManager aEm) {
em = aEm;
}
em = aEm;
}
@@
-31,12
+31,13
@@
public class JpaGroupSet implements GroupSet {
@Override
public boolean contains(Group aGroup) {
@Override
public boolean contains(Group aGroup) {
- return find(aGroup.getName()) != null;
+ return find(aGroup.getName()) != null;
}
@Override
public Group find(String aName) {
}
@Override
public Group find(String aName) {
- TypedQuery<Group> query = em.createNamedQuery(Group.QUERY_FIND_BY_NAME, Group.class);
+ TypedQuery<Group> query = em.createNamedQuery(Group.QUERY_FIND_BY_NAME,
+ Group.class);
query.setParameter(Group.NAME_PARAM, aName);
List<Group> groups = query.getResultList();
if (groups.size() > 1) {
query.setParameter(Group.NAME_PARAM, aName);
List<Group> groups = query.getResultList();
if (groups.size() > 1) {
@@
-54,25
+55,28
@@
public class JpaGroupSet implements GroupSet {
public void groupModified(Group aGroup) {
assert aGroup.getPrimaryKey() != null;
Group merged = em.merge(aGroup);
public void groupModified(Group aGroup) {
assert aGroup.getPrimaryKey() != null;
Group merged = em.merge(aGroup);
- // Need to flush so that version of the merged instance is updated so we can use
- // the updated version in the original group passed in. That allows the same
- // group object to continue to be used as a detached object.
+ // Need to flush so that version of the merged instance is updated so we
+ // can use
+ // the updated version in the original group passed in. That allows the
+ // same
+ // group object to continue to be used as a detached object.
em.flush();
JpaMergeSupport.merge(merged, aGroup);
}
@Override
public Set<Group> list() {
em.flush();
JpaMergeSupport.merge(merged, aGroup);
}
@Override
public Set<Group> list() {
- List<Group> groups = em.createNamedQuery(Group.QUERY_ALL_GROUPS, Group.class).getResultList();
+ List<Group> groups = em.createNamedQuery(Group.QUERY_ALL_GROUPS,
+ Group.class).getResultList();
Set<Group> res = new TreeSet<Group>(groups);
Set<Group> res = new TreeSet<Group>(groups);
- return res;
+ return res;
}
@Override
public boolean remove(Group aGroup) {
Group group = find(aGroup.getName());
}
@Override
public boolean remove(Group aGroup) {
Group group = find(aGroup.getName());
- if (
group == null ) {
- return false;
+ if (
group == null) {
+ return false;
}
em.remove(group);
return true;
}
em.remove(group);
return true;
@@
-80,7
+84,8
@@
public class JpaGroupSet implements GroupSet {
@Override
public int size() {
@Override
public int size() {
- Long res = (Long)em.createNamedQuery(Group.QUERY_COUNT_GROUPS).getSingleResult();
+ Long res = (Long) em.createNamedQuery(Group.QUERY_COUNT_GROUPS)
+ .getSingleResult();
return res.intValue();
}
}
return res.intValue();
}
}
diff --git
a/support/general/src/main/java/org/wamblee/persistence/PersistentFactory.java
b/support/general/src/main/java/org/wamblee/persistence/PersistentFactory.java
index fddc76b9e7844377304aa045ac0957f7316a46b5..c633f95532834319c57b0e40ba52309fd422b861 100644
(file)
--- a/
support/general/src/main/java/org/wamblee/persistence/PersistentFactory.java
+++ b/
support/general/src/main/java/org/wamblee/persistence/PersistentFactory.java
@@
-171,16
+171,16
@@
public class PersistentFactory {
@Override
public Number getPersistedVersion() {
@Override
public Number getPersistedVersion() {
- if (
accessor == null || accessor.getVersion() == null) {
- return null;
+ if (
accessor == null || accessor.getVersion() == null) {
+ return null;
}
return (Number) accessor.getVersion().get(entity);
}
@Override
public void setPersistedVersion(Number aVersion) {
}
return (Number) accessor.getVersion().get(entity);
}
@Override
public void setPersistedVersion(Number aVersion) {
- if (
accessor == null || accessor.getVersion() == null) {
- return;
+ if (
accessor == null || accessor.getVersion() == null) {
+ return;
}
accessor.getVersion().set(entity, aVersion);
}
}
accessor.getVersion().set(entity, aVersion);
}
diff --git
a/test/enterprise/src/main/java/org/wamblee/support/ThreadSpecificProxyFactory.java
b/test/enterprise/src/main/java/org/wamblee/support/ThreadSpecificProxyFactory.java
index 1e9c3468d355370d81242d8ed39d1eb2b61f3fe2..e47c037ac8f23e56086235c4758c8df7a759c2ad 100644
(file)
--- a/
test/enterprise/src/main/java/org/wamblee/support/ThreadSpecificProxyFactory.java
+++ b/
test/enterprise/src/main/java/org/wamblee/support/ThreadSpecificProxyFactory.java
@@
-49,28
+49,34
@@
public class ThreadSpecificProxyFactory<T> {
private Class clazz;
/**
private Class clazz;
/**
- * Constructs the factory.
- * @param aClass Interface class of the service to proxy.
+ * Constructs the factory.
+ *
+ * @param aClass
+ * Interface class of the service to proxy.
*/
public ThreadSpecificProxyFactory(Class<T> aClass) {
*/
public ThreadSpecificProxyFactory(Class<T> aClass) {
- if ( !aClass.isInterface() ) {
- throw new IllegalArgumentException("Class " + aClass.getName() + " is not an interface");
+ if (!aClass.isInterface()) {
+ throw new IllegalArgumentException("Class " + aClass.getName() +
+ " is not an interface");
}
clazz = aClass;
}
/**
}
clazz = aClass;
}
/**
- * Sets the thread-specific service.
- * @param aService Service, use null value to reset.
+ * Sets the thread-specific service.
+ *
+ * @param aService
+ * Service, use null value to reset.
*/
public void set(T aService) {
svc.set(aService);
}
/**
*/
public void set(T aService) {
svc.set(aService);
}
/**
- * Gets the proxy that delegates to the thread-specific instance set by
+ * Gets the proxy that delegates to the thread-specific instance set by
* {@link #set(Object)}
* {@link #set(Object)}
- * @return Proxy.
+ *
+ * @return Proxy.
*/
public T getProxy() {
InvocationHandler handler = new ThreadSpecificInvocationHandler();
*/
public T getProxy() {
InvocationHandler handler = new ThreadSpecificInvocationHandler();
@@
-82,8
+88,9
@@
public class ThreadSpecificProxyFactory<T> {
new Class[] { InvocationHandler.class }).newInstance(
new Object[] { handler });
return proxy;
new Class[] { InvocationHandler.class }).newInstance(
new Object[] { handler });
return proxy;
- } catch (Exception e) {
- throw new RuntimeException("Could not create proxy for " + clazz.getName(), e);
+ } catch (Exception e) {
+ throw new RuntimeException("Could not create proxy for " +
+ clazz.getName(), e);
}
}
}
}
}
}