Esempio n. 1
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;
 }
Esempio n. 2
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();
 }