X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-deforg%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Forg%2FDefaultOrg.java;h=50b65ffe4f638b8b04af134aedd851e6d00388bf;hb=08755cae37030d74d8fcadf38f9919c9d9fd21c0;hp=107141bc9cd3ce8f584b0ccd05109179ed54df8d;hpb=2b5103e038a7727734097a671d331db9aaab77ba;p=aaf%2Fauthz.git diff --git a/auth/auth-deforg/src/main/java/org/onap/aaf/org/DefaultOrg.java b/auth/auth-deforg/src/main/java/org/onap/aaf/org/DefaultOrg.java index 107141bc..50b65ffe 100644 --- a/auth/auth-deforg/src/main/java/org/onap/aaf/org/DefaultOrg.java +++ b/auth/auth-deforg/src/main/java/org/onap/aaf/org/DefaultOrg.java @@ -32,6 +32,7 @@ import java.util.Set; import java.util.regex.Pattern; import org.onap.aaf.auth.env.AuthzTrans; +import org.onap.aaf.auth.local.AbsData.Reuse; import org.onap.aaf.auth.org.EmailWarnings; import org.onap.aaf.auth.org.Executor; import org.onap.aaf.auth.org.Mailer; @@ -83,6 +84,7 @@ public class DefaultOrg implements Organization { } fIdentities.createNewFile(); } + } } else { fIdentities = new File(temp); @@ -103,6 +105,24 @@ public class DefaultOrg implements Organization { throw new OrganizationException(fIdentities.getCanonicalPath() + " does not exist."); } } + + File fRevoked=null; + temp=env.getProperty(getClass().getName()+".file.revoked"); + if(temp==null) { + temp = env.getProperty(AAF_DATA_DIR); + if (temp!=null) { + File dir = new File(temp); + fRevoked=new File(dir,"revoked.dat"); + } + } else { + fRevoked = new File(temp); + } + if (fRevoked!=null && fRevoked.exists()) { + revoked = new Identities(fRevoked); + } else { + revoked = null; + } + } catch (IOException e) { throw new OrganizationException(e); } @@ -112,6 +132,7 @@ public class DefaultOrg implements Organization { static final List NULL_DELEGATES = new ArrayList<>(); public Identities identities; + public Identities revoked; private boolean dryRun; private Mailer mailer; public enum Types {Employee, Contractor, Application, NotActive}; @@ -147,7 +168,58 @@ public class DefaultOrg implements Organization { return new DefaultOrgIdentity(trans,at<0?id:id.substring(0, at),this); } - // Note: Return a null if found; return a String Message explaining why not found. + /** + * If the ID isn't in the revoked file, if it exists, it is revoked. + */ + @Override + public boolean isRevoked(AuthzTrans trans, String key) { + if(revoked!=null) { + try { + revoked.open(trans, DefaultOrgIdentity.TIMEOUT); + try { + Reuse r = revoked.reuse(); + int at = key.indexOf(domain); + String search; + if (at>=0) { + search = key.substring(0,at); + } else { + search = key; + } + return revoked.find(search, r)!=null; + } finally { + revoked.close(trans); + } + } catch (IOException e) { + trans.error().log(e); + } + } + return false; + } + + /* (non-Javadoc) + * @see org.onap.aaf.auth.org.Organization#getEsclaations(org.onap.aaf.auth.env.AuthzTrans, java.lang.String, int) + */ + @Override + public List getIDs(AuthzTrans trans, String user, int escalate) throws OrganizationException { + List rv = new ArrayList<>(); + int end = Math.min(3,Math.abs(escalate)); + Identity id = null; + for(int i=0;i