Package org.jboss.resteasy.skeleton.key.idm.model.data

Examples of org.jboss.resteasy.skeleton.key.idm.model.data.Role


   }

   @Override
   public Role create(Realm realm, Resource resource, String roleName)
   {
      Role role = new Role();
      role.setName(roleName);
      role.setId(generateId());
      cache.put("/roles/"+role.getId(), role);
      Set<String> roles = (Set<String>)cache.get("/resources/" + resource.getId() + "/roles");
      if (roles == null)
      {
         roles = new HashSet<String>();
      }
      roles.add(role.getId());
      cache.put("/resources/" + resource.getId() + "/roles", roles);
      cache.put("/resources/" + resource.getId() + "/roles/" + role.getName(), role.getId());
      return role;
   }
View Full Code Here


   }

   @Override
   public Role create(Realm realm, String roleName)
   {
      Role role = new Role();
      role.setName(roleName);
      role.setId(generateId());
      cache.put("/roles/"+role.getId(), role);
      Set<String> roles = (Set<String>)cache.get(realmKey(realm) + "/roles");
      if (roles == null)
      {
         roles = new HashSet<String>();
      }
      roles.add(role.getId());
      cache.put(realmKey(realm) + "/roles", roles);
      cache.put(realmKey(realm) + "/roles/" + role.getName(), role.getId());
      return role;
   }
View Full Code Here

      realm.setAccessCodeLifespan(rep.getAccessCodeLifespan());
      realm.setSslNotRequired(rep.isSslNotRequired());
      realm = identityManager.create(realm);
      Map<String, User> userMap = new HashMap<String, User>();

      Role adminRole = identityManager.create(realm, "admin");

      for (RequiredCredentialRepresentation requiredCred : rep.getRequiredCredentials())
      {
         RequiredCredential credential = new RequiredCredential();
         credential.setType(requiredCred.getType());
         credential.setInput(requiredCred.isInput());
         credential.setSecret(requiredCred.isSecret());
         identityManager.create(realm, credential);
      }

      for (UserRepresentation userRep : rep.getUsers())
      {
         User user = new User();
         user.setUsername(userRep.getUsername());
         user.setEnabled(userRep.isEnabled());
         user = identityManager.create(realm, user);
         userMap.put(user.getUsername(), user);
         if (userRep.getCredentials() != null)
         {
            for (UserRepresentation.Credential cred : userRep.getCredentials())
            {
               UserCredential credential = new UserCredential();
               credential.setType(cred.getType());
               credential.setValue(cred.getValue());
               credential.setHashed(cred.isHashed());
               identityManager.create(user, credential);
            }
         }

         if (userRep.getAttributes() != null)
         {
            for (Map.Entry<String, String> entry : userRep.getAttributes().entrySet())
            {
               UserAttribute attribute = new UserAttribute();
               attribute.setName(entry.getKey());
               attribute.setValue(entry.getValue());
               identityManager.create(user, attribute);
            }
         }
      }

      for (RoleMappingRepresentation mapping : rep.getRoleMappings())
      {
         RoleMapping roleMapping = createRoleMapping(userMap, mapping);
         User user = userMap.get(mapping.getUsername());
         identityManager.create(realm, user, roleMapping);
      }

      for (ScopeMappingRepresentation scope : rep.getScopeMappings())
      {
         ScopeMapping scopeMapping = createScopeMapping(userMap, scope);
         User user = userMap.get(scope.getUsername());
         identityManager.create(realm, user, scopeMapping);

      }

      if (rep.getResources() != null)
      {
         for (ResourceRepresentation resourceRep : rep.getResources())
         {
            Resource resource = new Resource();
            resource.setName(resourceRep.getName());
            resource.setSurrogateAuthRequired(resourceRep.isSurrogateAuthRequired());
            resource = identityManager.create(realm, resource);
            if (resourceRep.getRoles() != null)
            {
               for (String role : resourceRep.getRoles())
               {
                  Role r = identityManager.create(realm, resource, role);
               }
            }
            if (resourceRep.getRoleMappings() != null)
            {
               for (RoleMappingRepresentation mapping : resourceRep.getRoleMappings())
View Full Code Here

TOP

Related Classes of org.jboss.resteasy.skeleton.key.idm.model.data.Role

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.