try {
hostname = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
- e.printStackTrace();
- env.warn().log("Unable to get hostname");
+ env.warn().log("Unable to get hostname : "+e.getMessage());
return (0);
}
if(cluster!=null && !cluster.isClosed()) {
cluster.close();
}
- e.printStackTrace(System.err);
+ env.warn().log(System.err);
}
}
}
public static void batchDelete(StringBuilder sb, List<String> row) {
- Long l = Long.parseLong(row.get(5));
+ long l = Long.parseLong(row.get(5));
String date = Chrono.batchFmt.format(new Date(l));
sb.append("DELETE from authz.cred WHERE id='");
sb.append(row.get(1));
sb.append(" AND expires='");
sb.append(date);
sb.append("';\n");
-// sb.append(" AND expires=dateof(maxtimeuuid(");
-// sb.append(row.get(5));
-// sb.append("));\n");
}
if(row.size()>3) {
escalation = Integer.parseInt(row.get(3));
}
- return;
} else if(type.equals(row.get(0))) {
String user = user(row);
if(user!=null) {
String path = pkg.getName().replace('.', '/');
URL url = cl.getResource(path);
List<String> classNames = new ArrayList<>();
- String urlString = url.toString();
- if(urlString.startsWith("jar:file:")) {
- int exclam = urlString.lastIndexOf('!');
- JarFile jf = new JarFile(urlString.substring(9,exclam));
- try {
- Enumeration<JarEntry> jfe = jf.entries();
- while(jfe.hasMoreElements()) {
- String name = jfe.nextElement().getName();
- if(name.startsWith(path) && name.endsWith(".class")) {
- classNames.add(name.substring(0,name.length()-6).replace('/', '.'));
+ String urlString;
+ if (url != null) {
+ urlString = url.toString();
+ if (urlString.startsWith("jar:file:")) {
+ int exclam = urlString.lastIndexOf('!');
+ JarFile jf = new JarFile(urlString.substring(9, exclam));
+ try {
+ Enumeration<JarEntry> jfe = jf.entries();
+ while (jfe.hasMoreElements()) {
+ String name = jfe.nextElement().getName();
+ if (name.startsWith(path) && name.endsWith(".class")) {
+ classNames.add(name.substring(0, name.length() - 6).replace('/', '.'));
+ }
}
+ } finally {
+ jf.close();
}
- } finally {
- jf.close();
- }
- } else {
- File dir = new File(url.getFile());
- for( String f : dir.list()) {
- if(f.endsWith(".class")) {
- classNames.add(pkg.getName() + '.' + f.substring(0,f.length() - 6));
+ } else {
+ File dir = new File(url.getFile());
+ String[] dirs = dir.list();
+ if (dirs != null) {
+ for (String f : dirs) {
+ if (f.endsWith(".class")) {
+ classNames.add(pkg.getName() + '.' + f.substring(0, f.length() - 6));
+ }
+ }
}
}
- }
- for(String cls : classNames) {
- try {
- Class<?> c = cl.loadClass(cls);
- if((c!=null)&&(!Modifier.isAbstract(c.getModifiers()))) {
- Constructor<?> cst = c.getConstructor(Access.class);
- NotifyBody nb = (NotifyBody)cst.newInstance(access);
- if(nb!=null) {
- bodyMap.put("info|" + nb.name, nb);
- bodyMap.put(nb.type+'|' + nb.name, nb);
- }
+ for (String cls : classNames) {
+ try {
+ Class<?> c = cl.loadClass(cls);
+ if ((c != null) && (!Modifier.isAbstract(c.getModifiers()))) {
+ Constructor<?> cst = c.getConstructor(Access.class);
+ NotifyBody nb = (NotifyBody) cst.newInstance(access);
+ bodyMap.put("info|" + nb.name, nb);
+ bodyMap.put(nb.type + '|' + nb.name, nb);
+ }
+ } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ e.printStackTrace();
}
- } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- e.printStackTrace();
}
}
}
remove.add(new File(logDir, args()[i]));
}
} else {
- remove.add(new File(logDir,"Delete"+Chrono.dateOnlyStamp()+".csv"));
+ final String ending = Chrono.dateOnlyStamp()+".csv";
+ for (File file : logDir.listFiles(f -> {
+ String name = f.getName();
+ return name.endsWith(ending) && (
+ name.startsWith("Delete") || name.startsWith("Clean."));
+ })) {
+ remove.add(file);
+ };
}
for(File f : remove) {
public Result<List<Data>> readNS(AuthzTrans trans, final String ns) {
DAOGetter getter = new DAOGetter(trans,dao()) {
+ @Override
public Result<List<Data>> call() {
return dao.readNS(trans, ns);
}
} else {
}
-// if (getter.result==null) {
-// if (lurd==null) {
- return Result.err(Status.ERR_PermissionNotFound,"No Permission found - " + lurd.details);
-// } else {
-// return Result.ok(lurd);
-// }
-// }
-// return getter.result;
+ return Result.err(Status.ERR_PermissionNotFound,"No Permission found - " + lurd.details);
}
public Result<List<Data>> readChildren(AuthzTrans trans, final String ns, final String type) {
*/
public Result<List<Data>> readByType(AuthzTrans trans, final String ns, final String type) {
DAOGetter getter = new DAOGetter(trans,dao()) {
+ @Override
public Result<List<Data>> call() {
return dao.readByType(trans, ns, type);
}
public Result<List<Data>> readNS(AuthzTrans trans, final String ns) {
DAOGetter getter = new DAOGetter(trans,dao()) {
+ @Override
public Result<List<Data>> call() {
return dao.readNS(trans, ns);
}
public Result<List<Data>> readName(AuthzTrans trans, final String name) {
DAOGetter getter = new DAOGetter(trans,dao()) {
+ @Override
public Result<List<Data>> call() {
return dao().readName(trans, name);
}
obj[++idx]=data.target;
obj[++idx]=data.subject;
obj[++idx]=data.memo;
-// obj[++idx]=data.detail;
obj[++idx]=data.reconstruct;
}
};
}
},writeConsistency)
);
-// disable(CRUD.Create);
- replace(CRUD.read, new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] +
+ replace(CRUD.read, new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] +
" FROM history WHERE id = ?", defLoader,readConsistency)
// new HistLoader(2) {
// @Override
private class YYYYMM implements Accept<Data> {
private int[] yyyymm;
- public YYYYMM(int yyyymm[]) {
+ public YYYYMM(int[] yyyymm) {
this.yyyymm = yyyymm;
}
@Override
public class X509ChainWithIssuer extends X509andChain {
private String issuerDN;
- public X509Certificate caX509;
public X509ChainWithIssuer(X509ChainWithIssuer orig, X509Certificate x509) {
super(x509,orig.trustChain);
} else if ("set".equalsIgnoreCase(largs[idx])) {
while (largs.length > ++idx) {
int equals = largs[idx].indexOf('=');
- String tag, value;
+ String tag;
+ String value;
if (equals < 0) {
tag = largs[idx];
value = access.getProperty(Config.AAF_APPPASS,null);
long lhash;
int curr;
while ((max-min)>100) {
- ttok.pos((curr=(min+(max-min)/2))*REC_SIZE);
+ curr=(min+(max-min)/2);
+ ttok.pos(curr*REC_SIZE);
tib.rewind();
lhash = hashToLong(tib.get());
if (lhash<hash) {
private final String[] columns;
private final Rows rows;
private Code<HTMLGen> other;
-// private DynamicCode<HTMLGen, AuthGUI, AuthzTrans> prefix,postfix;
+
public Table(String title, TRANS trans, Data<S,TRANS> data, Code<HTMLGen> other, String name, String ... attrs) {
this(title,trans,data,name, attrs);
public Table(String title, TRANS trans, Data<S,TRANS> data, String name, String ... attrs) {
super(true,name);
-// prefix=postfix=null;
for (String a : attrs) {
addAttr(false, a);
}
}
lmu = users.get(u.getId());
if (lmu==null) {
- users.put(u.getId(),lmu=new ArrayList<>());
+ lmu=new ArrayList<>();
+ users.put(u.getId(),lmu);
}
mu=null;
for (Map<Integer,List<User>> xmu : lmu) {
}
if (mu==null) {
- lmu.add(mu=new HashMap<>());
+ mu=new HashMap<>();
+ lmu.add(mu);
}
lu = mu.get(u.getType());
if (lu==null) {
- mu.put(u.getType(),lu = new ArrayList<>());
+ lu = new ArrayList<>();
+ mu.put(u.getType(),lu);
}
lu.add(u);
}
hgen.js(copyRoleJS);
hgen.text("function copyRole(role) {");
hgen.text("var txtRole = document.querySelector(\"#role\");");
-// hgen.text("if (role==;");
hgen.text("txtRole.value=role;");
hgen.text("}");
hgen.end(copyRoleJS);
import javax.servlet.Filter;
-import org.onap.aaf.auth.cache.Cache.Dated;
import org.onap.aaf.auth.env.AuthzEnv;
import org.onap.aaf.auth.env.AuthzTrans;
import org.onap.aaf.auth.env.AuthzTransFilter;
public class AAF_Hello extends AbsService<AuthzEnv,AuthzTrans> {
public enum API{TOKEN_REQ, TOKEN,INTROSPECT, ERROR,VOID};
- public Map<String, Dated> cacheUser;
public AAFAuthn<?> aafAuthn;
public AAFLurPerm aafLurPerm;
* Construct AuthzAPI with all the Context Supporting Routes that Authz needs
*
* @param env
- * @param si
- * @param dm
- * @param decryptor
* @throws APIException
*/
public AAF_Hello(final AuthzEnv env) throws Exception {
* Construct AuthzAPI with all the Context Supporting Routes that Authz needs
*
* @param env
- * @param si
- * @param dm
- * @param decryptor
* @throws APIException
*/
public AAF_OAuth(final AuthzEnv env) throws Exception {
import org.onap.aaf.auth.env.AuthzTrans;
import org.onap.aaf.auth.layer.Result;
+@FunctionalInterface
public interface DirectIntrospect<INTROSPECT> {
Result<INTROSPECT> mappedIntrospect(AuthzTrans trans, String token);
}
public static final char ALT_START_INST_KEY_CHAR='/';
public static final char LIST_SEP = ',';
- public static final String INST_KEY_REGEX = new StringBuilder().append(START_INST_KEY_CHAR).toString();
public static final String ASTERIX = "*";
/**
if (sInst == null || pInst == null) {
return false;
}
- if (sInst == "" || pInst == "") {
+ if (sInst.equals("") || pInst.equals("")) {
return false;
}
if (ASTERIX.equals(sInst)) {
* Action is not quite as complex. But we write it in this function so it can be consistent
*/
public static boolean evalAction(String sAction,String pAction) {
- if (ASTERIX.equals(sAction))return true; // If Server's String is "*", then it accepts every Action
- if (pAction == "") return false;
+ if (ASTERIX.equals(sAction)) return true; // If Server's String is "*", then it accepts every Action
+ if (pAction.equals("")) return false;
for (String sItem : Split.split(LIST_SEP,sAction)) { // allow for "," definition in Action
if (pAction.charAt(0)==START_REGEX_CHAR? // First char
sItem.matches(pAction.substring(1)): // Evaluate as Regular Expression
niceUTCDateFmt.setTimeZone(TimeZone.getTimeZone("UTC"));\r
iso8601Fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX");\r
batchFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss+SSSS");\r
+ // Note: DB and thus Batch conversions should always be in UTC Time\r
+ batchFmt.setTimeZone(TimeZone.getTimeZone("UTC"));\r
}\r
\r
\r