X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cadi%2Fcore%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2FUser.java;h=978375551412377524c7ee4609e42b34053f0752;hb=6dd9704640eb8cc8d6b4ccd266e40a3f6f589e75;hp=512f2e6ac9ead17a4ff81a26ed0487d734b4681d;hpb=4b5a7d721d994a49057e9bfb403c7bff1b376660;p=aaf%2Fauthz.git diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/User.java b/cadi/core/src/main/java/org/onap/aaf/cadi/User.java index 512f2e6a..97837555 100644 --- a/cadi/core/src/main/java/org/onap/aaf/cadi/User.java +++ b/cadi/core/src/main/java/org/onap/aaf/cadi/User.java @@ -7,9 +7,9 @@ * 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. @@ -31,7 +31,7 @@ import org.onap.aaf.cadi.lur.LocalPermission; /** * Class to hold info from the User Perspective. - * + * * @author Jonathan * */ @@ -40,11 +40,11 @@ public final class User { public String name; private byte[] cred; public Principal principal; - Map perms ; + Map perms; 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; @@ -86,23 +86,23 @@ public final class User { 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(); @@ -115,17 +115,17 @@ public final class User { public synchronized void incCount() { ++count; } - + public synchronized void resetCount() { count=0; } - + public Map newMap() { return new ConcurrentHashMap<>(); } public void add(LocalPermission permission) { - if(perms==NULL_MAP) { + if (perms==NULL_MAP) { perms=newMap(); } perms.put(permission.getKey(),permission); @@ -146,19 +146,19 @@ public final class User { } return false; } - + public void copyPermsTo(List sink) { sink.addAll(perms.values()); } - + public String toString() { StringBuilder sb = new StringBuilder(); sb.append(principal.getName()); sb.append('|'); boolean first = true; synchronized(perms) { - for(Permission gp : perms.values()) { - if(first) { + for (Permission gp : perms.values()) { + if (first) { first = false; sb.append(':'); } else {