protected User createUser(IdentityObject identityObject) { return new SimpleUser(identityObject.getName()); }
public IdentityObjectAttribute getAttribute(IdentityStoreInvocationContext invocationContext, IdentityObject identity, String name) throws IdentityException { Map<String, IdentityObjectAttribute> results = cacheSupport.getAttributesFromCache(identity.getName(), identity.getIdentityType()); if (results != null && results.containsKey(name)) { return results.get(name); } else { return attributeStore.getAttribute(invocationContext, identity, name); //TODO: add this attribute to the node map } }
protected boolean hasIdentityObject(IdentityStoreInvocationContext ctx, IdentityStore is, IdentityObject io) throws IdentityException { try { if (is.findIdentityObject(ctx, io.getName(), io.getIdentityType()) != null) { return true; } } catch (IdentityException e) { //store may throw exception if there is no identity so do nothing //TODO: should have isIdentityPresent method } return false; }
public Map<String, IdentityObjectAttribute> getAttributes(IdentityStoreInvocationContext invocationContext, IdentityObject identity) throws IdentityException { Map<String, IdentityObjectAttribute> results = cacheSupport.getAttributesFromCache(identity.getName(), identity.getIdentityType()); if (results == null) { results = attributeStore.getAttributes(invocationContext, identity); if (results != null && results.size() > 0) { //TODO:FIXME // cacheSupport.putIntoCache(identity, results); } } return results; }
private HibernateIdentityObject getHibernateIdentityObject(IdentityStoreInvocationContext ctx, IdentityObject io) throws IdentityException { HibernateIdentityObject hibernateObject = null; Session hibernateSession = getHibernateSession(ctx); try { hibernateObject = (HibernateIdentityObject)hibernateSession.createQuery(HibernateIdentityObject.findIdentityObjectByNameAndType) .setParameter("name", io.getName()) .setParameter("typeName", io.getIdentityType().getName()) .setParameter("realm", getRealm(hibernateSession, ctx)) .uniqueResult(); } catch (Exception e) { throw new IdentityException("IdentityObject[ " + io.getName() + " | " + io.getIdentityType().getName() + "] not present in the store.", e); } return hibernateObject; }
protected Group createGroup(IdentityObject identityObject) { String groupType = getSessionContext().getIdentityObjectTypeMapper().getGroupType(identityObject.getIdentityType()); return new SimpleGroup(identityObject.getName(), groupType); }
public void removeRelationships(IdentityStoreInvocationContext invocationCtx, IdentityObject identity1, IdentityObject identity2, boolean named) throws IdentityException { IdentityStore fromStore = resolveIdentityStore(identity1); IdentityStore toStore = resolveIdentityStore(identity2); IdentityStoreInvocationContext toTargetCtx = resolveInvocationContext(toStore, invocationCtx); IdentityStoreInvocationContext defaultTargetCtx = resolveInvocationContext(defaultIdentityStore, invocationCtx); if (fromStore == toStore) { fromStore.removeRelationships(toTargetCtx, identity1, identity2, named); return; } if (!hasIdentityObject(defaultTargetCtx, defaultIdentityStore, identity1)) { defaultIdentityStore.createIdentityObject(defaultTargetCtx, identity1.getName(), identity1.getIdentityType()); } if (!hasIdentityObject(defaultTargetCtx, defaultIdentityStore, identity2)) { defaultIdentityStore.createIdentityObject(defaultTargetCtx, identity2.getName(), identity2.getIdentityType()); } defaultIdentityStore.removeRelationships(defaultTargetCtx, identity1, identity2, named); }
public Set<IdentityObjectRelationship> resolveRelationships(IdentityStoreInvocationContext invocationCxt, IdentityObject fromIdentity, IdentityObject toIdentity, IdentityObjectRelationshipType relationshipType) throws IdentityException { IdentityStore fromStore = resolveIdentityStore(fromIdentity); IdentityStore toStore = resolveIdentityStore(toIdentity); IdentityStoreInvocationContext toTargetCtx = resolveInvocationContext(toStore, invocationCxt); IdentityStoreInvocationContext defaultTargetCtx = resolveInvocationContext(defaultIdentityStore, invocationCxt); if (fromStore == toStore && (!RoleManagerImpl.ROLE.getName().equals(relationshipType.getName()) || fromStore.getSupportedFeatures().isNamedRelationshipsSupported())) { return fromStore.resolveRelationships(toTargetCtx, fromIdentity, toIdentity, relationshipType); } if (!hasIdentityObject(defaultTargetCtx, defaultIdentityStore, fromIdentity)) { defaultIdentityStore.createIdentityObject(defaultTargetCtx, fromIdentity.getName(), fromIdentity.getIdentityType()); } if (!hasIdentityObject(defaultTargetCtx, defaultIdentityStore, toIdentity)) { defaultIdentityStore.createIdentityObject(defaultTargetCtx, toIdentity.getName(), toIdentity.getIdentityType()); } return defaultIdentityStore.resolveRelationships(defaultTargetCtx, fromIdentity, toIdentity, relationshipType); }
public void removeRelationship(IdentityStoreInvocationContext invocationCxt, IdentityObject fromIdentity, IdentityObject toIdentity, IdentityObjectRelationshipType relationshipType, String relationshipName) throws IdentityException { IdentityStore fromStore = resolveIdentityStore(fromIdentity); IdentityStore toStore = resolveIdentityStore(toIdentity); IdentityStoreInvocationContext toTargetCtx = resolveInvocationContext(toStore, invocationCxt); IdentityStoreInvocationContext defaultTargetCtx = resolveInvocationContext(defaultIdentityStore, invocationCxt); if (fromStore == toStore) { if (relationshipName == null || (relationshipName != null && fromStore.getSupportedFeatures().isNamedRelationshipsSupported())) { fromStore.removeRelationship(toTargetCtx, fromIdentity, toIdentity, relationshipType, relationshipName); return; } } if (!hasIdentityObject(defaultTargetCtx, defaultIdentityStore, fromIdentity)) { defaultIdentityStore.createIdentityObject(defaultTargetCtx, fromIdentity.getName(), fromIdentity.getIdentityType()); } if (!hasIdentityObject(defaultTargetCtx, defaultIdentityStore, toIdentity)) { defaultIdentityStore.createIdentityObject(defaultTargetCtx, toIdentity.getName(), toIdentity.getIdentityType()); } defaultIdentityStore.removeRelationship(defaultTargetCtx, fromIdentity, toIdentity, relationshipType, relationshipName); }
public IdentityObjectRelationship createRelationship(IdentityStoreInvocationContext invocationCxt, IdentityObject fromIdentity, IdentityObject toIdentity, IdentityObjectRelationshipType relationshipType, String relationshipName, boolean createNames) throws IdentityException { IdentityStore fromStore = resolveIdentityStore(fromIdentity); IdentityStore toStore = resolveIdentityStore(toIdentity); IdentityStoreInvocationContext toTargetCtx = resolveInvocationContext(toStore, invocationCxt); IdentityStoreInvocationContext defaultTargetCtx = resolveInvocationContext(defaultIdentityStore, invocationCxt); if (fromStore == toStore) { // If relationship is named and target store doesn't support named relationships it need to be put in default store anyway if (relationshipName == null || (relationshipName != null && fromStore.getSupportedFeatures().isNamedRelationshipsSupported())) { return fromStore.createRelationship(toTargetCtx, fromIdentity, toIdentity, relationshipType, relationshipName, createNames); } } if (!hasIdentityObject(defaultTargetCtx, defaultIdentityStore, fromIdentity)) { defaultIdentityStore.createIdentityObject(defaultTargetCtx, fromIdentity.getName(), fromIdentity.getIdentityType()); } if (!hasIdentityObject(defaultTargetCtx, defaultIdentityStore, toIdentity)) { defaultIdentityStore.createIdentityObject(defaultTargetCtx, toIdentity.getName(), toIdentity.getIdentityType()); } return defaultIdentityStore.createRelationship(defaultTargetCtx, fromIdentity, toIdentity, relationshipType, relationshipName, createNames); }
defaultStoreIdentityObject = defaultIdentityStore.findIdentityObject(defaultCtx, identity.getName(), identity.getIdentityType());