/** * @see org.n52.security.decision.DecisionService#request(PDPRequestCollection) */ public PDPResponseCollection request(final PDPRequestCollection reqCol) throws DecisionProcessingException { PDPResponseCollection respCol = new PDPResponseCollection(); Iterator itreq = reqCol.iterator(); while (itreq.hasNext()) { PDPRequest pdpRequest = (PDPRequest) itreq.next(); if (LOG.isDebugEnabled()) { LOG.debug("pdp request <" + pdpRequest + "> is permitted"); } respCol.add(new PDPResponse(PDPResponse.DECISION_PERMIT, pdpRequest)); } return respCol; } }
public PDPResponseCollection request(PDPRequestCollection pdpReqCol) throws DecisionProcessingException { PDPResponseCollection resColl = new PDPResponseCollection(); LOG.info("PDP performs request"); Iterator it = pdpReqCol.iterator(); // iterate through request collection while (it.hasNext()) { PDPRequest request = (PDPRequest) it.next(); // only one target imaginable Target target = request.getTarget(); if (LOG.isDebugEnabled()) { LOG.debug(request); } int lPermission = permissionExists(target) ? PDPResponse.DECISION_PERMIT : PDPResponse.DECISION_DENY; PDPResponse response = new PDPResponse(lPermission, request); if (LOG.isDebugEnabled()) { LOG.debug(response); } resColl.add(response); } return resColl; }
private PDPResponse lookUp(final PDPRequest req) { if (m_stopped || m_maxCacheTime < 0) { // cache disabled return null; } String key = getCacheKey(req); CacheEntry cacheEntry = null; synchronized (m_lock) { cacheEntry = m_decisionCache.get(key); } long now = System.currentTimeMillis(); PDPResponse resp = null; if (cacheEntry != null && cacheEntry.getInserted() > (now - m_maxCacheTime) && (resp = cacheEntry.getResponse()) != null) { if (LOG.isTraceEnabled()) { LOG.trace("cache hit for <" + req + "> --return--> <" + resp + ">"); } m_hitCount.incrementAndGet(); // return copy to ensure that the request object is the input param! return new PDPResponse(resp.getDecision(), req, resp.getObligations()); } m_missCount.incrementAndGet(); return null; }
if (lPermColl == null) { LOG.debug("No PermissionCollection available for type " + lPermCollType); response = new PDPResponse(PDPResponse.DECISION_DENY, request); } else { lPermColl.getPermission(tPrincipals, target.getResource(), target.getAction()); if (tPermission == null) { response = new PDPResponse(PDPResponse.DECISION_DENY, request); } else { response = new PDPResponse(PDPResponse.DECISION_PERMIT, request, tPermission.getObligations());
return new PDPResponse(lDecision, pRequest, lOblig);
private void store(final PDPRequest request, final PDPResponse resp) { if (m_stopped || m_maxCacheTime < 0) { return; } // store copy to ensure no memory leeks because of pdp responses/requests! CacheEntry entry = new CacheEntry(new PDPResponse(resp.getDecision(), new PDPRequest(new Target()), resp.getObligations())); String key = getCacheKey(request); synchronized (m_lock) { int size = m_decisionCache.size(); if (size > m_maxEntries) { // don't insert if limit is exceeded! return; } m_decisionCache.put(key, entry); } }