+ public static class Singleton {
+ public AAFCon<?> acon;
+ public AAFAuthn<?> authn;
+ public AAFLurPerm authz;
+// private Set<Class<? extends AuthenticationToken>> supports;
+
+ private MapBathConverter mbc;
+ private Map<String,String> idMap;
+ private Singleton() {
+ logger.info("Creating AAFRealm.Singleton");
+ mbc = null;
+ idMap = null;
+ String cadi_prop_files = access.getProperty(Config.CADI_PROP_FILES);
+ if(cadi_prop_files==null) {
+ String msg = Config.CADI_PROP_FILES + " in VM Args is required to initialize AAFRealm.";
+ access.log(Level.INFO,msg);
+ throw new RuntimeException(msg);
+ } else {
+ try {
+ acon = AAFCon.newInstance(access);
+ authn = acon.newAuthn();
+ authz = acon.newLur(authn);
+
+ final String csv = access.getProperty(Config.CADI_BATH_CONVERT);
+ if(csv!=null) {
+ try {
+ mbc = new MapBathConverter(access, new CSV(access,csv));
+ access.log(Level.INFO, "MapBathConversion enabled with file ",csv);
+ idMap = Collections.synchronizedMap(new TreeMap<String,String>());
+ // Load
+ for(Entry<String, String> es : mbc.map().entrySet()) {
+ String oldID = es.getKey();
+ if(oldID.startsWith("Basic ")) {
+ oldID = Symm.base64noSplit.decode(oldID.substring(6));
+ int idx = oldID.indexOf(':');
+ if(idx>=0) {
+ oldID = oldID.substring(0, idx);
+ }
+ }
+ String newID = es.getValue();
+ if(newID.startsWith("Basic ")) {
+ newID = Symm.base64noSplit.decode(newID.substring(6));
+ int idx = newID.indexOf(':');
+ if(idx>=0) {
+ newID = newID.substring(0, idx);
+ }
+ }
+ idMap.put(oldID,newID);
+ }
+ } catch (IOException e) {
+ access.log(e);
+ }
+ }
+ } catch (APIException | CadiException | LocatorException e) {
+ String msg = "Cannot initiate AAFRealm";
+ access.log(Level.ERROR,e,msg);
+ throw new RuntimeException(msg,e);
+ }
+ }
+
+ // There is only one of these. If there are more, put back
+// supports = Collections.synchronizedSet(new HashSet<>());
+// supports.add(UsernamePasswordToken.class);
+ }
+
+ public static synchronized Singleton singleton() {
+ if(singleton==null) {
+ singleton = new Singleton();
+ }
+ return singleton;
+ }