Skip to content

Commit

Permalink
#219, #216 (more VO renaming of internal variables to vi)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjg-123 committed Nov 19, 2024
1 parent 8768a52 commit 94e1c4e
Showing 11 changed files with 74 additions and 232 deletions.
194 changes: 18 additions & 176 deletions .idea/workspace.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -70,15 +70,15 @@ public void extraUpdates(Identifiable identifiable, int magicNumber) throws IOEx
if (!isEmpty(issuer)) {
client.setIssuer(issuer);
}
String voURI;
String viURI;
if (client.getVirtualIssuer() == null) {
voURI = getPropertyHelp(keys.voURI(), "Give the VO URI", null);
viURI = getPropertyHelp(keys.voURI(), "Give the VI URI", null);
} else {
voURI = getPropertyHelp(keys.voURI(), "Give the VO URI", client.getVirtualIssuer().toString());
viURI = getPropertyHelp(keys.voURI(), "Give the VI URI", client.getVirtualIssuer().toString());
}
if (!isEmpty(voURI)) {
if (!isEmpty(viURI)) {
try {
URI z = URI.create(voURI);
URI z = URI.create(viURI);
client.setVirtualIssuer(BasicIdentifier.newID(z));
} catch (Throwable t) {
if (DebugUtil.isEnabled()) {
Original file line number Diff line number Diff line change
@@ -189,7 +189,7 @@ public String toString() {
"admin_id=" + getIdentifier() +
", virtualIssuer=" + virtualIssuer +
", issuer='" + issuer + '\'' +
", externalVOName='" + externalVIName + '\'' +
", externalVIName='" + externalVIName + '\'' +
", maxClients=" + maxClients +
", config=" + config +
", allowQDL=" + allowQDL +
Original file line number Diff line number Diff line change
@@ -602,9 +602,9 @@ public void setAuthorizationGrantLifetime(long authorizationGrantLifetime) {
long authorizationGrantLifetime = AUTHORIZATION_GRANT_LIFETIME_DEFAULT;

/**
* Given the client id, look up the admin and determine what (if any) the VO is.
* The returned value may be null,, meaning there is no VO.
* If the VO is disabled, it will not be returned either.<br/><br/>
* Given the client id, look up the admin and determine what (if any) the VI is.
* The returned value may be null,, meaning there is no VI.
* If the VI is disabled, it will not be returned either.<br/><br/>
* This has its own call here because it involves multiple store lookups. It cannot
* be done as a join in SQL or some such because there are no guarantees the stores
* are all SQL -- some may be file stores or even in another unrelated database.
Original file line number Diff line number Diff line change
@@ -489,20 +489,20 @@ public void setAccountingInformation() {
// hierarchy.
// 1. If they passed it in explicitly, use that
// 2. If it is set in the configuration, use that
// 3. If there is a VO, use that
// 3. If there is a VI, use that
// 4. If all else fails, use the standard issuer
if (transaction.hasAudience()) {
atData.put(AUDIENCE, transaction.getAudience());
} else {
if (getATConfig().getAudience() != null && !getATConfig().getAudience().isEmpty()) {
atData.put(AUDIENCE, getATConfig().getAudience());
} else{
VirtualIssuer vo = oa2se.getVI(client.getIdentifier());
if (vo == null) {
// fail safe. No VO, no configuration, return this service as issuer.
VirtualIssuer vi = oa2se.getVI(client.getIdentifier());
if (vi == null) {
// fail safe. No VI, no configuration, return this service as issuer.
atData.put(AUDIENCE, transaction.getClient().getIdentifierString());
} else {
atData.put(AUDIENCE, vo.getAtIssuer());
atData.put(AUDIENCE, vi.getAtIssuer());
}
// Note that at this point a default audience could be set, but different
// protocols have very different ideas. These are set in the individual handlers.
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ public class OA2RegistrationServlet extends AbstractRegistrationServlet {
public static final String CALLBACK_URI = "callbackURI";
public static final String REFRESH_TOKEN_LIFETIME = "rtLifetime";
public static final String REFRESH_TOKEN_FIELD_VISIBLE = "rtFieldVisible";
public static final String VO_NAME = "voName";
public static final String VI_NAME = "viName";
public static final String LDAP_NAME = "ldap";
public static final String ISSUER_NAME = "issuer";
public static final String SCOPES_NAME = "scopes";
@@ -77,7 +77,7 @@ public void prepare(PresentableState state) throws Throwable {
String[] scopes = new String[displayScopes.size()];
displayScopes.toArray(scopes);
request.setAttribute(SCOPES_NAME, scopes);
request.setAttribute(VO_NAME, VO_NAME);
request.setAttribute(VI_NAME, VI_NAME);
request.setAttribute(LDAP_NAME, LDAP_NAME);
request.setAttribute(ISSUER_NAME, ISSUER_NAME);
request.setAttribute(CALLBACK_URI, CALLBACK_URI);
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ public static JSONWebKeys getKeys(OA2SE oa2se, OA2Client client) {

if (vo != null) {
keys = vo.getJsonWebKeys();
ServletDebugUtil.trace(OA2TokenUtils.class, "Got VO for client " + client.getIdentifierString());
ServletDebugUtil.trace(OA2TokenUtils.class, "Got VI for client " + client.getIdentifierString());
}
return keys;
}
Original file line number Diff line number Diff line change
@@ -532,7 +532,7 @@ public Identifier getProvisioningAdminID() {
/**
* Sets the provisioning admin partly so we don't have to look it up again and partly so
* that for very, very long lived transactions, there is absolutely no possibility
* that the VO can change.
* that the VI can change.
*
* @param provisioningAdminID
*/
Original file line number Diff line number Diff line change
@@ -27,41 +27,41 @@ protected VISerializationKeys vok() {

@Override
public V fromMap(ConversionMap<String, Object> map, V v) {
V vo = super.fromMap(map, v);
V vi = super.fromMap(map, v);

vo.setCreationTS(new Date(map.getLong(vok().creationTS())));
vo.setLastModifiedTS(new Date(map.getLong(vok().lastModifiedTS())));
vi.setCreationTS(new Date(map.getLong(vok().creationTS())));
vi.setLastModifiedTS(new Date(map.getLong(vok().lastModifiedTS())));

// Fixes https://github.com/ncsa/oa4mp/issues/149
vo.setLastAccessed(new Date(map.getLong(vok().lastAccessed())));
vo.setValid(map.getBoolean(vok().valid()));
vi.setLastAccessed(new Date(map.getLong(vok().lastAccessed())));
vi.setValid(map.getBoolean(vok().valid()));

if (map.containsKey(vok().issuer()) && !isTrivial(map.getString(vok().issuer()))) {
vo.setIssuer(map.getString(vok().issuer()));
vi.setIssuer(map.getString(vok().issuer()));
}
if (map.containsKey(vok().atIssuer()) && !isTrivial(map.getString(vok().atIssuer()))) {
vo.setAtIssuer(map.getString(vok().atIssuer()));
vi.setAtIssuer(map.getString(vok().atIssuer()));
}
if (map.containsKey(vok().defaultKeyID()) && !isTrivial(map.getString(vok().defaultKeyID()))) {
vo.setDefaultKeyID(map.getString(vok().defaultKeyID()));
vi.setDefaultKeyID(map.getString(vok().defaultKeyID()));
}
if (map.containsKey(vok().jsonWebKeys()) && !isTrivial(map.getString(vok().jsonWebKeys()))) {
try {
JSONWebKeys keys = JSONWebKeyUtil.fromJSON(map.getString(vok().jsonWebKeys()));
vo.setJsonWebKeys(keys);
vi.setJsonWebKeys(keys);

} catch (Throwable e) {
DebugUtil.error(this, "Could not deserialize the JSON web keys for this VO.\"" + vo.getIdentifierString() + "\".", e);
DebugUtil.error(this, "Could not deserialize the JSON web keys for this VI.\"" + vi.getIdentifierString() + "\".", e);
}
}
if (map.containsKey(vok().discoveryPath()) && !isTrivial(map.getString(vok().discoveryPath()))) {
vo.setDiscoveryPath(map.getString(vok().discoveryPath()));
vi.setDiscoveryPath(map.getString(vok().discoveryPath()));
}

if (map.containsKey(vok().title()) && !isTrivial(map.getString(vok().title()))) {
vo.setTitle(map.getString(vok().title()));
vi.setTitle(map.getString(vok().title()));
}
return vo;
return vi;
}

@Override
Original file line number Diff line number Diff line change
@@ -105,27 +105,27 @@ public void setTitle(String title) {
}

public void toXML(XMLStreamWriter xsw) throws XMLStreamException {
xsw.writeStartElement(VO_ENTRY);
xsw.writeStartElement(VI_ENTRY);
xsw.writeAttribute(ID_ATTR, getIdentifierString());
xsw.writeAttribute(VO_CREATED, Long.toString(getCreationTS().getTime()));
xsw.writeAttribute(VO_LAST_MODIFIED, Long.toString(getLastModifiedTS().getTime()));
xsw.writeAttribute(VO_LAST_ACCESSED, Long.toString(getLastAccessed().getTime()));
xsw.writeAttribute(VI_CREATED, Long.toString(getCreationTS().getTime()));
xsw.writeAttribute(VI_LAST_MODIFIED, Long.toString(getLastModifiedTS().getTime()));
xsw.writeAttribute(VI_LAST_ACCESSED, Long.toString(getLastAccessed().getTime()));
xsw.writeAttribute(IS_VALID_ATTR, Boolean.toString(valid));
if (!isTrivial(issuer)) {
xsw.writeAttribute(ISSUER, issuer);
}
if (!isTrivial(discoveryPath)) {
xsw.writeAttribute(VO_DISCOVERY_PATH, discoveryPath);
xsw.writeAttribute(VI_DISCOVERY_PATH, discoveryPath);
}
if (!isTrivial(title)) {
xsw.writeAttribute(VO_TITLE, title);
xsw.writeAttribute(VI_TITLE, title);
}
if (!isTrivial(defaultKeyID)) {
xsw.writeAttribute(VO_DEFAULT_KEY, defaultKeyID);
xsw.writeAttribute(VI_DEFAULT_KEY, defaultKeyID);
}
if (jsonWebKeys != null) {
JSONObject json = JSONWebKeyUtil.toJSON(jsonWebKeys);
xsw.writeStartElement(VO_JSON_WEB_KEYS);
xsw.writeStartElement(VI_JSON_WEB_KEYS);
// It is base 64 encoded so we don't have to grapple with escaping and such. All we need
// is that it is faithfully stashed someplace.
XMLUtils.write(xsw, Base64.encodeBase64String(json.toString().getBytes(StandardCharsets.UTF_8)));
@@ -143,14 +143,14 @@ public void fromXML(XMLEventReader xer) throws XMLStreamException {
switch (xe.getEventType()) {
case XMLEvent.START_ELEMENT:
switch (xe.asStartElement().getName().getLocalPart()) {
case VO_JSON_WEB_KEYS:
case VI_JSON_WEB_KEYS:
String raw = xe.asCharacters().getData();
jsonWebKeys = JSONWebKeyUtil.fromJSON(new String(Base64.decodeBase64(raw)));
break;
} //end inner switch
break;
case XMLEvent.END_ELEMENT:
if (xe.asEndElement().getName().getLocalPart().equals(VO_ENTRY)) {
if (xe.asEndElement().getName().getLocalPart().equals(VI_ENTRY)) {
return;
}
break;
@@ -159,7 +159,7 @@ public void fromXML(XMLEventReader xer) throws XMLStreamException {
xer.next();

}
throw new IllegalStateException("Error: XML file corrupt. No end tag for " + VO_ENTRY);
throw new IllegalStateException("Error: XML file corrupt. No end tag for " + VI_ENTRY);

}

@@ -173,26 +173,26 @@ private void doXMLAttributes(XMLEvent xe) {
case ID_ATTR:
setIdentifier(BasicIdentifier.newID(v));
break;
case VO_CREATED:
case VI_CREATED:
setCreationTS(new Date(Long.parseLong(v)));
break;
case VO_LAST_MODIFIED:
case VI_LAST_MODIFIED:
setLastModifiedTS(new Date(Long.parseLong(v)));
break;
case VO_LAST_ACCESSED:
case VI_LAST_ACCESSED:
setLastAccessed(new Date(Long.parseLong(v)));
case IS_VALID_ATTR:
break;
case ISSUER:
issuer = v;
break;
case VO_DEFAULT_KEY:
case VI_DEFAULT_KEY:
defaultKeyID = v;
break;
case VO_DISCOVERY_PATH:
case VI_DISCOVERY_PATH:
discoveryPath = v;
break;
case VO_TITLE:
case VI_TITLE:
title = v;
}
}
Original file line number Diff line number Diff line change
@@ -22,14 +22,14 @@ public interface QDLXMLConstants extends SerializationConstants {
String STATE = "state";
String ID_ATTR = "id";

String VO_ENTRY = "virtual_issuer";
String VO_JSON_WEB_KEYS = "json_web_keys";
String VO_DEFAULT_KEY = "default_key";
String VO_TITLE = "title";
String VO_LAST_MODIFIED = "last_modified_at";
String VO_LAST_ACCESSED = "last_accessed_at";
String VO_CREATED = "created_at";
String VO_DISCOVERY_PATH = "discovery_path";
String VI_ENTRY = "virtual_issuer";
String VI_JSON_WEB_KEYS = "json_web_keys";
String VI_DEFAULT_KEY = "default_key";
String VI_TITLE = "title";
String VI_LAST_MODIFIED = "last_modified_at";
String VI_LAST_ACCESSED = "last_accessed_at";
String VI_CREATED = "created_at";
String VI_DISCOVERY_PATH = "discovery_path";
// use issuer and id_attr from above

}

0 comments on commit 94e1c4e

Please sign in to comment.