public String toString() { final StringBuffer sb = new StringBuffer(); sb.append("org.n52.security.decision.Target"); sb.append("{subject=").append(getSubject()); sb.append(", resourceAttributes=").append(getResourceAttributes()); sb.append(", actionAttributes=").append(getActionAttributes()); sb.append('}'); return sb.toString(); } }
public List getPermissions(Target pTarget) throws DecisionProcessingException { Iterator principalIterator = pTarget.getSubject().getPrincipals( UsernameIDPrincipal.class).iterator(); UsernameIDPrincipal userNameIDprincipal = (UsernameIDPrincipal) principalIterator.next(); if (userNameIDprincipal == null) { throw new DecisionProcessingException( "Subject for PDP request contains no username or id"); } String lSubject = userNameIDprincipal.getName(); return getPermissions(lSubject, pTarget.getAction(), pTarget.getResource()); }
/** * Creates a unique key from the request object. * */ private String getCacheKey(final PDPRequest req) { // here we try to generate a hopefull unique "cachekey" // using the id of the user // the environment attributes, // and the the resource and action id String resource = req.getTarget().getResourceId(); String action = req.getTarget().getActionId(); String env = String.valueOf(req.getEnvironment().hashCode()); SubjectPrincipalAnalyzer principalAnalyzer = new SubjectPrincipalAnalyzer(req.getTarget().getSubject()); String userid = principalAnalyzer.getUsername(); LicenseReference licref = LicensingUtils.getLicenseReference(req.getTarget().getSubject()); String licId = licref != null ? licref.getLicenseId() : ""; if (userid == null) { userid = "#anonymous#"; } String key = new StringBuffer() .append("U:").append(userid) .append(";R:").append(resource) .append(";A:").append(action) .append(";L:").append(licId) .append(";E:").append(env).toString(); if (LOG.isTraceEnabled()) { LOG.trace("generate hash-key <" + key + "> for request <" + req + ">"); } return key; }
Set tPrincipals = target.getSubject().getPrincipals();
private RequestDocument convert52nRequestToXACMLRequest(final PDPRequest pRequest) throws XmlException { RequestDocument lDoc = RequestDocument.Factory.newInstance(); RequestType lRequest = lDoc.addNewRequest(); Target target = pRequest.getTarget(); convertEnvironmentToXACMLEnvironment(pRequest.getEnvironment(), lRequest); convertSubjectToXACMLSubject(target.getSubject(), lRequest); convertLicensePrincipalOfSubjectToXACMLEnvironment(target.getSubject(), lRequest); // todo: support complex resource and action attributes and not only id's convertResourceToXACMLResource(target.getResourceId(), lRequest); convertActionToXACMLAction(target.getActionId(), lRequest); // type is ignored ! return lDoc; }