public Object getObject(String name) throws IdentityException { Object o = registry.getRegistration(name); if (o == null) { throw new IdentityException("No such mapping in IdentityContext: " + name); } return o; }
public IdentityStoreSession createIdentityStoreSession() throws IdentityException { try { return new HibernateIdentityStoreSessionImpl(sessionFactory); } catch (Exception e) { throw new IdentityException("Failed to obtain Hibernate SessionFactory",e); } }
public void register(Object object, String name) throws IdentityException { if (!registry.register(name, object)) { throw new IdentityException("Cannot register object in IdentityContext with name: " + name); } if (log.isLoggable(Level.FINER)) log.finer("registering object: " + name + " ; " + object.getClass()); }
public IdentityObject findIdentityObject(IdentityStoreInvocationContext ctx, String id) throws IdentityException { if (id == null) { throw new IllegalArgumentException("id is null"); } HibernateIdentityObject hibernateObject; try { hibernateObject = (HibernateIdentityObject)getHibernateSession(ctx).get(HibernateIdentityObject.class, new Long(id)); } catch(Exception e) { throw new IdentityException("Cannot find IdentityObject with id: " + id, e); } return hibernateObject; }
protected Session getHibernateSession(IdentityStoreInvocationContext ctx) throws IdentityException { try { return ((Session)ctx.getIdentityStoreSession().getSessionContext()); } catch (Exception e) { throw new IdentityException("Cannot obtain Hibernate Session", e); } }
public void addRealm(Session hibernateSession, String realmName) throws IdentityException { try { HibernateRealm realm = new HibernateRealm(realmName); hibernateSession.persist(realm); } catch (Exception e) { throw new IdentityException("Failed to create store realm", e); } }
public IdentitySession createIdentitySession(String realmName) throws IdentityException { if (!sessionContextMap.containsKey(realmName)) { throw new IdentityException("Cannot find configured realm with a given name: " + realmName); } //IdentitySession session = new IdentitySessionImpl(realmName, repo, mapper); IdentitySessionConfigurationContext sessionConfigCtx = sessionContextMap.get(realmName); IdentitySession newSession = new IdentitySessionImpl(sessionConfigCtx.getRealmName(), sessionConfigCtx.getRepository(), sessionConfigCtx.getTypeMapper()); realmMap.put(realmName, newSession); return newSession; }
public IdentityStore getIdentityStore(IdentityObjectType identityObjectType) throws IdentityException { IdentityStore store = identityStoreMappings.get(identityObjectType.getName()); if (store == null) { String option = configurationContext.getRepositoryConfigurationMetaData().getOptionSingleValue(ALLOW_NOT_DEFINED_IDENTITY_OBJECT_TYPES_OPTION); if (option != null && option.equalsIgnoreCase("true")) { return defaultIdentityStore; } else { throw new IdentityException("IdentityObjectType not mapped in the configuration: " + identityObjectType); } } return store; }
private void checkIOType(IdentityObjectType iot) throws IdentityException { if (iot == null) { throw new IllegalArgumentException("IdentityObjectType is null"); } if (!getSupportedFeatures().isIdentityObjectTypeSupported(iot)) { if (!isAllowNotDefinedIdentityObjectTypes()) { throw new IdentityException("IdentityType not supported by this IdentityStore implementation: " + iot); } } }
public AttributeStore getAttributeStore(IdentityObjectType identityObjectType) throws IdentityException { AttributeStore store = attributeStoreMappings.get(identityObjectType.getName()); if (store == null) { String option = configurationContext.getRepositoryConfigurationMetaData().getOptionSingleValue(ALLOW_NOT_DEFINED_IDENTITY_OBJECT_TYPES_OPTION); if (option != null && option.equalsIgnoreCase("true")) { return defaultIdentityStore; } else { throw new IdentityException("IdentityObjectType not mapped in the configuration: " + identityObjectType); } } return store; }
private HibernateIdentityObjectCredentialType getHibernateIdentityObjectCredentialType(IdentityStoreInvocationContext ctx, IdentityObjectCredentialType credentialType) throws IdentityException { Session session = getHibernateSession(ctx); HibernateIdentityObjectCredentialType hibernateType = null; try { hibernateType = (HibernateIdentityObjectCredentialType)session. createCriteria(HibernateIdentityObjectCredentialType.class).add(Restrictions.eq("name", credentialType.getName())).uniqueResult(); } catch (HibernateException e) { throw new IdentityException("IdentityObjectCredentialType[ " + credentialType.getName() + "] not present in the store."); } return hibernateType; }
private HibernateIdentityObjectRelationshipType getHibernateIdentityObjectRelationshipType(IdentityStoreInvocationContext ctx, IdentityObjectRelationshipType iot) throws IdentityException { HibernateIdentityObjectRelationshipType relationshipType = null; Session hibernateSession = getHibernateSession(ctx); try { relationshipType = (HibernateIdentityObjectRelationshipType)hibernateSession. createQuery(HibernateIdentityObjectRelationshipType.findIdentityObjectRelationshipTypeByName) .setParameter("name", iot.getName()) .uniqueResult(); } catch (Exception e) { throw new IdentityException("IdentityObjectRelationshipType[ " + iot.getName() + "] not present in the store."); } return relationshipType; }
public Collection<RoleType> findRoleTypes(IdentitySearchCriteria criteria) throws IdentityException { try { Set<String> names = getRepository().getRelationshipNames(getInvocationContext(), convertSearchControls(criteria)); Set<RoleType> types = new HashSet<RoleType>(); for (String name : names) { types.add(new SimpleRoleType(name)); } return types; } catch (OperationNotSupportedException e) { throw new IdentityException("Role management not supported"); } }
public void removeRoleType(String name) throws IdentityException { checkNotNullArgument(name, "RoleType name"); try { getRepository().removeRelationshipName(getInvocationContext(), name); } catch (OperationNotSupportedException e) { throw new IdentityException("Role management not supported"); } }
public RoleType getRoleType(String name) throws IdentityException { checkNotNullArgument(name, "RoleType name"); try { Set<String> names = getRepository().getRelationshipNames(getInvocationContext(), null); if (names.contains(name)) { return new SimpleRoleType(name); } } catch (OperationNotSupportedException e) { throw new IdentityException("Role management not supported"); } return null; }
public void updateCredential(User user, Credential credential) throws IdentityException { checkNotNullArgument(user, "User"); checkNotNullArgument(credential, "Credential"); if (credential instanceof IdentityObjectCredential) { getRepository().updateCredential(getInvocationContext(), createIdentityObject(user), (IdentityObjectCredential)credential); } else { throw new IdentityException("Unsupported Credential implementation: " + credential.getClass()); } }
public Collection<RoleType> findGroupRoleTypes(Group group, IdentitySearchCriteria criteria) throws IdentityException { checkNotNullArgument(group, "Group"); Set<RoleType> types = new HashSet<RoleType>(); try { Collection<String> names = getRepository().getRelationshipNames(getInvocationContext(), createIdentityObject(group), convertSearchControls(criteria)); for (String name : names) { types.add(new SimpleRoleType(name)); } return types; } catch (OperationNotSupportedException e) { throw new IdentityException("Role management not supported"); } }
public Collection<RoleType> findUserRoleTypes(User user, IdentitySearchCriteria criteria) throws IdentityException { checkNotNullArgument(user, "User"); Set<RoleType> types = new HashSet<RoleType>(); try { Collection<String> names = getRepository().getRelationshipNames(getInvocationContext(), createIdentityObject(user), convertSearchControls(criteria)); for (String name : names) { types.add(new SimpleRoleType(name)); } return types; } catch (OperationNotSupportedException e) { throw new IdentityException("Role management not supported", e); } }
public Group findGroupById(String id) throws IdentityException { checkNotNullArgument(id, "Group id"); if (!GroupId.validateId(id)) { throw new IdentityException("Provided group id is not valid: " + id + "; " + "Please use PersistenceManager.createGroupId() to obtain valid group id"); } GroupId groupId = new GroupId(id); return findGroup(groupId.getName(), groupId.getType()); }
public RoleType createRoleType(String name) throws IdentityException { checkNotNullArgument(name, "RoleType name"); checkObjectName(name); String roleType = null; try { roleType = getRepository().createRelationshipName(getInvocationContext(), name); } catch (OperationNotSupportedException e) { throw new IdentityException("Role management not supported"); } return new SimpleRoleType(roleType); }