예제 #1
0
 protected static String generateKey(PIPRequest pipRequest) {
   StringBuilder stringBuilder = new StringBuilder(pipRequest.getCategory().toString());
   stringBuilder.append('+');
   stringBuilder.append(pipRequest.getAttributeId());
   stringBuilder.append('+');
   stringBuilder.append(pipRequest.getDataTypeId());
   String issuer = pipRequest.getIssuer();
   if (issuer != null) {
     stringBuilder.append('+');
     stringBuilder.append(issuer);
   }
   return stringBuilder.toString();
 }
예제 #2
0
 protected Attribute findAttribute(PIPRequest pipRequest) {
   Attribute attributeResult = null;
   Iterator<Attribute> iterAttributes = this.listAttributes.iterator();
   while (attributeResult == null && iterAttributes.hasNext()) {
     Attribute attributeTest = iterAttributes.next();
     if (pipRequest.getCategory().equals(attributeTest.getCategory())
         && pipRequest.getAttributeId().equals(attributeTest.getAttributeId())
         && (pipRequest.getIssuer() == null
             || pipRequest.getIssuer().equals(attributeTest.getIssuer()))) {
       attributeResult = attributeTest;
     }
   }
   return attributeResult;
 }
예제 #3
0
 @Override
 public PIPResponse getAttributes(PIPRequest pipRequest, PIPFinder pipFinder) throws PIPException {
   String pipRequestKey = generateKey(pipRequest);
   PIPResponse pipResponse = this.cache.get(pipRequestKey);
   if (pipResponse != null) {
     return pipResponse;
   }
   Attribute attributeMatch = this.findAttribute(pipRequest);
   if (attributeMatch == null) {
     return StdPIPResponse.PIP_RESPONSE_EMPTY;
   }
   /*
    * Iterate through the values and only return the ones that match the requested data type
    */
   List<AttributeValue<?>> matchingValues =
       attributeMatch
           .getValues()
           .stream()
           .filter(
               attributeValue -> pipRequest.getDataTypeId().equals(attributeValue.getDataTypeId()))
           .collect(Collectors.toList());
   if (matchingValues.size() > 0) {
     Attribute attributeResponse =
         new StdMutableAttribute(
             attributeMatch.getCategory(),
             attributeMatch.getAttributeId(),
             matchingValues,
             attributeMatch.getIssuer(),
             false);
     pipResponse = new StdPIPResponse(attributeResponse);
     this.cache.put(pipRequestKey, pipResponse);
   }
   return pipResponse;
 }