@Override public List<Application> getApplicationsForUser(PerunSession sess) { try { PerunPrincipal pp = sess.getPerunPrincipal(); if (pp.getUser() != null) { return jdbc.query(APP_SELECT + " where user_id=? or (a.created_by=? and extsourcename=?) order by a.id desc", APP_MAPPER, pp.getUserId(), pp.getActor(), pp.getExtSourceName()); } else { // sort by ID which respect latest applications return jdbc.query(APP_SELECT + " where a.created_by=? and extsourcename=? order by a.id desc", APP_MAPPER, pp.getActor(), pp.getExtSourceName()); } } catch (EmptyResultDataAccessException ex) { return new ArrayList<Application>(); } }
@Override public String getConsolidatorToken(PerunSession sess) throws PerunException { Map<String, Object> value = new HashMap<String, Object>(); String actor = sess.getPerunPrincipal().getActor(); String extSourceName = sess.getPerunPrincipal().getExtSourceName(); String extSourceType = sess.getPerunPrincipal().getExtSourceType(); Integer extSourceLoa = sess.getPerunPrincipal().getExtSourceLoa(); User user = sess.getPerunPrincipal().getUser(); value.put("actor", actor); value.put("extSourceName", extSourceName); value.put("extSourceType", extSourceType); value.put("extSourceLoa", extSourceLoa); value.put("user", user); value.put("additionalInformation", sess.getPerunPrincipal().getAdditionalInformations()); // create token from actual properties String token = registrarManager.getMailManager().getMessageAuthenticationCode(System.currentTimeMillis() + actor + extSourceName + extSourceType + extSourceLoa); requestCache.putIfAbsent(token, value); return token; }
List<Identity> similarUsers = getConsolidatorManager().checkForSimilarUsers(sess); if (similarUsers != null && !similarUsers.isEmpty()) { log.debug("Similar users found for {} / {}: {}", sess.getPerunPrincipal().getActor(), sess.getPerunPrincipal().getExtSourceName(), similarUsers);
perun.getUsersManager().getUserByExtSourceNameAndExtLogin(registrarSession, sess.getPerunPrincipal().getExtSourceName(), sess.getPerunPrincipal().getActor()); return new ArrayList<Identity>(); } catch (Exception ex) {
params.put("delegatedExtSourceName", perunPrincipal.getExtSourceName()); params.put("delegatedExtSourceType", perunPrincipal.getExtSourceType());
String extSourceName = sess.getPerunPrincipal().getExtSourceName(); String extSourceType = sess.getPerunPrincipal().getExtSourceType(); int extSourceLoa = sess.getPerunPrincipal().getExtSourceLoa();
/** * Retrieves whole application object from DB * (authz in parent methods) * * @param sess PerunSession for Authz and to resolve User * @param vo VO to get application for * @param group Group * * @return application object / null if not exists */ private Application getLatestApplication(PerunSession sess, Vo vo, Group group, Application.AppType type) { try { if (sess.getPerunPrincipal().getUser() != null) { if (group != null) { return jdbc.queryForObject(RegistrarManagerImpl.APP_SELECT + " where a.id=(select max(id) from application where vo_id=? and group_id=? and apptype=? and user_id=? )", RegistrarManagerImpl.APP_MAPPER, vo.getId(), group.getId(), String.valueOf(type), sess.getPerunPrincipal().getUserId()); } else { return jdbc.queryForObject(RegistrarManagerImpl.APP_SELECT + " where a.id=(select max(id) from application where vo_id=? and apptype=? and user_id=? )", RegistrarManagerImpl.APP_MAPPER, vo.getId(), String.valueOf(type), sess.getPerunPrincipal().getUserId()); } } else { if (group != null) { return jdbc.queryForObject(RegistrarManagerImpl.APP_SELECT + " where a.id=(select max(id) from application where vo_id=? and group_id=? and apptype=? and created_by=? and extsourcename=? )", RegistrarManagerImpl.APP_MAPPER, vo.getId(), group.getId(), String.valueOf(type), sess.getPerunPrincipal().getActor(), sess.getPerunPrincipal().getExtSourceName()); } else { return jdbc.queryForObject(RegistrarManagerImpl.APP_SELECT + " where a.id=(select max(id) from application where vo_id=? and apptype=? and created_by=? and extsourcename=? )", RegistrarManagerImpl.APP_MAPPER, vo.getId(), String.valueOf(type), sess.getPerunPrincipal().getActor(), sess.getPerunPrincipal().getExtSourceName()); } } } catch (EmptyResultDataAccessException ex) { return null; } }
ex.setSourceType2((String) originalIdentity.get("extSourceType")); ex.setLogin2(sess.getPerunPrincipal().getActor()); ex.setSource2(sess.getPerunPrincipal().getExtSourceName()); ex.setSourceType2(sess.getPerunPrincipal().getExtSourceType()); throw ex; if (originalIdentity.get("extSourceName").equals(sess.getPerunPrincipal().getExtSourceName()) && originalIdentity.get("actor").equals(sess.getPerunPrincipal().getActor()) && originalIdentity.get("extSourceType").equals(sess.getPerunPrincipal().getExtSourceType())) { IdentityIsSameException ex = new IdentityIsSameException("You tried to join same identity with itself. Please try again but select different identity."); ex.setLogin(sess.getPerunPrincipal().getActor()); ex.setSource(sess.getPerunPrincipal().getExtSourceName()); ex.setSourceType(sess.getPerunPrincipal().getExtSourceType()); throw ex; sess.getPerunPrincipal().getExtSourceName(), sess.getPerunPrincipal().getExtSourceType(), sess.getPerunPrincipal().getExtSourceLoa()); ((PerunBlImpl)perun).setUserExtSourceAttributes(sess, ues, sess.getPerunPrincipal().getAdditionalInformations());
if (!sess.getPerunPrincipal().getExtSourceName().equals(app.getExtSourceName()) && !sess.getPerunPrincipal().getActor().equals(app.getCreatedBy())) throw new PrivilegeException("checkForSimilarUsers"); if (!sess.getPerunPrincipal().getExtSourceName().equals(app.getExtSourceName()) && !sess.getPerunPrincipal().getActor().equals(app.getCreatedBy())) throw new PrivilegeException("checkForSimilarUsers");
String extSourceName = sess.getPerunPrincipal().getExtSourceName(); int extSourceLoa = sess.getPerunPrincipal().getExtSourceLoa();
&& !AuthzResolver.hasRole(sess.getPerunPrincipal(), Role.RPC) && !(app.getCreatedBy().equals(sess.getPerunPrincipal().getActor()) && app.getExtSourceName().equals(sess.getPerunPrincipal().getExtSourceName()))) { throw new PrivilegeException(sess, "getApplicationById"); && !AuthzResolver.hasRole(sess.getPerunPrincipal(), Role.RPC) && !(app.getCreatedBy().equals(sess.getPerunPrincipal().getActor()) && app.getExtSourceName().equals(sess.getPerunPrincipal().getExtSourceName()))) { throw new PrivilegeException(sess, "getApplicationById");
} else { if (Objects.equals(app.getCreatedBy(), sess.getPerunPrincipal().getActor()) && Objects.equals(app.getExtSourceName(), sess.getPerunPrincipal().getExtSourceName()) && Objects.equals(app.getExtSourceType(), sess.getPerunPrincipal().getExtSourceType()) ) {