aboutsummaryrefslogtreecommitdiff
path: root/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/Linker.java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/Linker.java')
-rw-r--r--id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/Linker.java107
1 files changed, 52 insertions, 55 deletions
diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/Linker.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/Linker.java
index 94882de77..f82f6fbcc 100644
--- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/Linker.java
+++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/Linker.java
@@ -9,11 +9,9 @@ import java.util.List;
import org.apache.log4j.Logger;
/**
- * This class is a bean used to store the information of Attribute Providers, the Attribute
- * List to be requested, the Assertions returned by the Attribute Providers and the values
- * that each Attribute has. This information along with the current status of the Linker (the
- * attribute providers that were queried and the remaining providers) is used by the PEPS
- * actions in order to complete the Attribute gathering.
+ * This class is a bean used to store the information of Attribute Providers, the Attribute List to be requested, the Assertions returned by the Attribute Providers and the values that each Attribute
+ * has. This information along with the current status of the Linker (the attribute providers that were queried and the remaining providers) is used by the PEPS actions in order to complete the
+ * Attribute gathering.
*
* @author Stelios Lelis (stelios.lelis@aegean.gr), Elias Pastos (ilias@aegean.gr)
*
@@ -56,7 +54,7 @@ public final class Linker implements Serializable {
public Linker() {
localIndex = 0;
remoteIndex = 0;
-
+
assertions = new LinkedHashMap<AttributeSource, STORKAttrQueryResponse>();
}
@@ -74,13 +72,13 @@ public final class Linker implements Serializable {
found = null;
- if ( attributeProvidersMap!=null && !attributeProvidersMap.isEmpty() ) {
+ if (attributeProvidersMap != null && !attributeProvidersMap.isEmpty()) {
iterator = attributeProvidersMap.keyIterator();
while (iterator.hasNext()) {
source = iterator.next();
- if ( source.getSourceType()==AttributeSource.SOURCE_LOCAL_APROVIDER ) {
- if ( curIndex>=localIndex ) {
+ if (source.getSourceType() == AttributeSource.SOURCE_LOCAL_APROVIDER) {
+ if (curIndex >= localIndex) {
found = source;
break;
@@ -108,13 +106,13 @@ public final class Linker implements Serializable {
found = null;
- if ( attributeProvidersMap !=null && !attributeProvidersMap.isEmpty() ) {
+ if (attributeProvidersMap != null && !attributeProvidersMap.isEmpty()) {
iterator = attributeProvidersMap.keyIterator();
while (iterator.hasNext()) {
source = iterator.next();
- if ( source.getSourceType()==AttributeSource.SOURCE_REMOTE_COUNTRY ) {
- if ( curIndex>=remoteIndex ) {
+ if (source.getSourceType() == AttributeSource.SOURCE_REMOTE_COUNTRY) {
+ if (curIndex >= remoteIndex) {
found = source;
break;
@@ -129,28 +127,29 @@ public final class Linker implements Serializable {
}
/**
- * It updates the Linker with the values returned by the Attribute Source. It also advances
- * to the next index in order to mark this attribute source as completed.
+ * It updates the Linker with the values returned by the Attribute Source. It also advances to the next index in order to mark this attribute source as completed.
*
- * @param source The Attribute Source that was queried for attribute values.
- * @param attrResponse The attrResponse returned by the Attribute Source that contains the attribute values.
+ * @param source
+ * The Attribute Source that was queried for attribute values.
+ * @param attrResponse
+ * The attrResponse returned by the Attribute Source that contains the attribute values.
*
* @see AttributeSource, STORKAttrQueryResponse
*/
public void setProviderReponse(AttributeSource source, STORKAttrQueryResponse attrResponse) {
- if ( source.getSourceType()==AttributeSource.SOURCE_REMOTE_COUNTRY )
+ if (source.getSourceType() == AttributeSource.SOURCE_REMOTE_COUNTRY)
remoteIndex++;
else
localIndex++;
- //Assertion storage
+ // Assertion storage
this.assertions.put(source, attrResponse);
- // previously: getTotalPersonalAttributeList() in both cases
- if ( source.getSourceType()==AttributeSource.SOURCE_REMOTE_COUNTRY )
+ // previously: getTotalPersonalAttributeList() in both cases
+ if (source.getSourceType() == AttributeSource.SOURCE_REMOTE_COUNTRY)
this.attributeProvidersMap.put(source, attrResponse.getTotalPersonalAttributeList());
else
- this.attributeProvidersMap.put(source, attrResponse.getPersonalAttributeList());
- //this.attributeProvidersMap.put(source, attrResponse.getTotalPersonalAttributeList());
+ this.attributeProvidersMap.put(source, attrResponse.getPersonalAttributeList());
+ // this.attributeProvidersMap.put(source, attrResponse.getTotalPersonalAttributeList());
}
/**
@@ -170,7 +169,8 @@ public final class Linker implements Serializable {
/**
* Setter for attributeProvidersMap.
*
- * @param attributeProvidersMap The attributeProvidersMap to set.
+ * @param attributeProvidersMap
+ * The attributeProvidersMap to set.
*/
public void setAttributeProvidersMap(IAttributeProvidersMap attributeProvidersMap) {
this.attributeProvidersMap = attributeProvidersMap;
@@ -188,14 +188,15 @@ public final class Linker implements Serializable {
/**
* Returns the Personal Attribute list of the provided Attribute Source.
*
- * @param source The attributeSource in reference
+ * @param source
+ * The attributeSource in reference
*
* @return The IPersonalAttributeList assosiated with this source or null if empty
*
* @see IPersonalAttributeList
*/
public IPersonalAttributeList getProviderAttributes(AttributeSource source) {
- if ( attributeProvidersMap.containsKey(source) )
+ if (attributeProvidersMap.containsKey(source))
return attributeProvidersMap.get(source);
else
return null;
@@ -215,7 +216,7 @@ public final class Linker implements Serializable {
merged = null;
- if ( attributeProvidersMap !=null && !attributeProvidersMap.isEmpty() ) {
+ if (attributeProvidersMap != null && !attributeProvidersMap.isEmpty()) {
iterator = attributeProvidersMap.keyIterator();
merged = new PersonalAttributeList();
@@ -233,29 +234,26 @@ public final class Linker implements Serializable {
}
/**
- * Returns a List with all the assertions gathered by the AAS-PEPS module
- * returned both by local APs or remote A-PEPS.
+ * Returns a List with all the assertions gathered by the AAS-PEPS module returned both by local APs or remote A-PEPS.
*
* @return The assertions returned from the APs and A-PEPS
*/
public List<STORKAttrQueryResponse> getAttrQueryResponseList() {
List<STORKAttrQueryResponse> originalAssertions;
-
+
originalAssertions = new ArrayList<STORKAttrQueryResponse>();
- //Gather all assertions
- for (STORKAttrQueryResponse element : this.assertions.values()) {
+ // Gather all assertions
+ for (STORKAttrQueryResponse element : this.assertions.values()) {
originalAssertions.add(element);
- }
+ }
return originalAssertions;
}
/**
- * Checks the internal state of the Linker and if all Attribute Sources where visited
- * returns true, otherwise it returns false. So if you go directly from AtPLinkerAction
- * to MoreAttributesAction the call will have, since the method setProviderReponse
- * was not executed from every Attribute Source.
+ * Checks the internal state of the Linker and if all Attribute Sources where visited returns true, otherwise it returns false. So if you go directly from AtPLinkerAction to MoreAttributesAction
+ * the call will have, since the method setProviderReponse was not executed from every Attribute Source.
*
* @return true if everything is OK, false otherwise
*/
@@ -263,11 +261,10 @@ public final class Linker implements Serializable {
boolean outcome = false;
LOG.debug("Check if linkder is complete: R[" + remoteIndex + "], L[" + localIndex + "], S[" + attributeProvidersMap.size() + "]");
- if ( attributeProvidersMap !=null && !attributeProvidersMap.isEmpty() ) {
- if ( (remoteIndex + localIndex)==attributeProvidersMap.size() )
+ if (attributeProvidersMap != null && !attributeProvidersMap.isEmpty()) {
+ if ((remoteIndex + localIndex) == attributeProvidersMap.size())
outcome = true;
- }
- else {
+ } else {
outcome = true;
}
@@ -275,33 +272,33 @@ public final class Linker implements Serializable {
}
/**
- * Merge the two Linker objects.
+ * Merge the two Linker objects.
*
- * @param previous The other Linker object to merge with this one.
+ * @param previous
+ * The other Linker object to merge with this one.
*/
public void mergeWith(Linker previous) {
- //BEFORE
- if ( LOG.isDebugEnabled() ) {
+ // BEFORE
+ if (LOG.isDebugEnabled()) {
LOG.debug("The attributeProvidersMap from the current object.");
- ((AttributeProvidersMap)this.attributeProvidersMap).trace();
+ ((AttributeProvidersMap) this.attributeProvidersMap).trace();
LOG.debug("The attributeProvidersMap from the provided object.");
- ((AttributeProvidersMap)previous.getAttributeProvidersMap()).trace();
+ ((AttributeProvidersMap) previous.getAttributeProvidersMap()).trace();
}
IAttributeProvidersMap map = previous.getAttributeProvidersMap();
Iterator<AttributeSource> items = map.keyIterator();
- while( items.hasNext() ) {
+ while (items.hasNext()) {
AttributeSource item = items.next();
IPersonalAttributeList pal = map.get(item);
- if ( this.attributeProvidersMap.containsKey(item) ) {
+ if (this.attributeProvidersMap.containsKey(item)) {
IPersonalAttributeList new_pal = this.attributeProvidersMap.get(item);
- for(PersonalAttribute pa : pal)
+ for (PersonalAttribute pa : pal)
new_pal.add(pa);
- }
- else {
- if ( item.getSourceType()==AttributeSource.SOURCE_REMOTE_COUNTRY )
+ } else {
+ if (item.getSourceType() == AttributeSource.SOURCE_REMOTE_COUNTRY)
remoteIndex++;
else
localIndex++;
@@ -310,10 +307,10 @@ public final class Linker implements Serializable {
}
}
- //AFTER
- if ( LOG.isDebugEnabled() ) {
+ // AFTER
+ if (LOG.isDebugEnabled()) {
LOG.debug("The attributeProvidersMap after the merge.");
- ((AttributeProvidersMap)this.attributeProvidersMap).trace();
+ ((AttributeProvidersMap) this.attributeProvidersMap).trace();
}
}
} \ No newline at end of file