* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/**
* Class to hold info from the User Perspective.
- *
+ *
* @author Jonathan
*
*/
long permExpires;
private final long interval;
int count;
-
+
// Note: This should only be used for Local RBAC (in memory)
public User(Principal principal) {
this.principal = principal;
count = 0;
renewPerm();
}
-
+
public void renewPerm() {
permExpires = System.currentTimeMillis()+interval;
}
-
+
public long permExpires() {
return permExpires;
}
-
+
public boolean permExpired() {
return System.currentTimeMillis() > permExpires;
}
public boolean noPerms() {
- return perms==null || perms==NULL_MAP || perms.values().size()==0;
+ return perms==null || perms==NULL_MAP || perms.values().size()==0;
}
-
+
public synchronized void setNoPerms() {
perms=NULL_MAP;
renewPerm();
public synchronized void incCount() {
++count;
}
-
+
public synchronized void resetCount() {
count=0;
}
-
+
public Map<String,Permission> newMap() {
return new ConcurrentHashMap<>();
}
}
return false;
}
-
+
public void copyPermsTo(List<Permission> sink) {
sink.addAll(perms.values());
}
-
+
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(principal.getName());