Java Code Examples for org.keycloak.representations.idm.RoleRepresentation#getName()
The following examples show how to use
org.keycloak.representations.idm.RoleRepresentation#getName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RealmCompositeImport.java From keycloak-config-cli with Apache License 2.0 | 5 votes |
public void update(String realm, RoleRepresentation realmRole, Set<String> realmComposites) { String roleName = realmRole.getName(); Set<String> existingRealmCompositeNames = findRealmRoleRealmCompositeNames(realm, roleName); if (Objects.equals(realmComposites, existingRealmCompositeNames)) { logger.debug("No need to update realm-level role '{}'s composites realm-roles in realm '{}'", roleName, realm); } else { logger.debug("Update realm-level role '{}'s composites realm-roles in realm '{}'", roleName, realm); updateRealmRoleRealmComposites(realm, roleName, existingRealmCompositeNames, realmComposites); } }
Example 2
Source File: RealmCompositeImport.java From keycloak-config-cli with Apache License 2.0 | 5 votes |
public void update(String realm, String roleClientId, RoleRepresentation clientRole, Set<String> realmComposites) { String roleName = clientRole.getName(); Set<String> existingRealmCompositeNames = findClientRoleRealmCompositeNames(realm, roleClientId, roleName); if (Objects.equals(realmComposites, existingRealmCompositeNames)) { logger.debug("No need to update client-level role '{}'s composites realm-roles in realm '{}'", roleName, realm); } else { logger.debug("Update client-level role '{}'s composites realm-roles in realm '{}'", roleName, realm); updateClientRoleRealmComposites(realm, roleClientId, roleName, realmComposites, existingRealmCompositeNames); } }
Example 3
Source File: RoleImportService.java From keycloak-config-cli with Apache License 2.0 | 5 votes |
private void createOrUpdateRealmRole(String realm, RoleRepresentation role) { String roleName = role.getName(); Optional<RoleRepresentation> maybeRole = roleRepository.tryToFindRealmRole(realm, roleName); if (maybeRole.isPresent()) { updateClientIfNeeded(realm, maybeRole.get(), role); } else { logger.debug("Create realm-level role '{}' in realm '{}'", roleName, realm); roleRepository.createRealmRole(realm, role); } }
Example 4
Source File: RoleImportService.java From keycloak-config-cli with Apache License 2.0 | 5 votes |
private void createOrUpdateClientRole(String realm, String clientId, RoleRepresentation role) { String roleName = role.getName(); Optional<RoleRepresentation> maybeRole = roleRepository.tryToFindClientRole(realm, clientId, roleName); if (maybeRole.isPresent()) { updateClientRoleIfNecessary(realm, clientId, maybeRole.get(), role); } else { logger.debug("Create client-level role '{}' for client '{}' in realm '{}'", roleName, clientId, realm); roleRepository.createClientRole(realm, clientId, role); } }
Example 5
Source File: RoleImportService.java From keycloak-config-cli with Apache License 2.0 | 5 votes |
private void updateClientIfNeeded(String realm, RoleRepresentation existingRole, RoleRepresentation roleToImport) { String roleName = roleToImport.getName(); RoleRepresentation patchedRole = CloneUtil.deepPatch(existingRole, roleToImport); if (roleToImport.getAttributes() != null) { patchedRole.setAttributes(roleToImport.getAttributes()); } if (!CloneUtil.deepEquals(existingRole, patchedRole)) { logger.debug("Update realm-level role '{}' in realm '{}'", roleName, realm); roleRepository.updateRealmRole(realm, patchedRole); } else { logger.debug("No need to update realm-level '{}' in realm '{}'", roleName, realm); } }
Example 6
Source File: RoleImportService.java From keycloak-config-cli with Apache License 2.0 | 5 votes |
private void updateClientRoleIfNecessary(String realm, String clientId, RoleRepresentation existingRole, RoleRepresentation roleToImport) { RoleRepresentation patchedRole = CloneUtil.deepPatch(existingRole, roleToImport); String roleName = existingRole.getName(); if (CloneUtil.deepEquals(existingRole, patchedRole)) { logger.debug("No need to update client-level role '{}' for client '{}' in realm '{}'", roleName, clientId, realm); } else { logger.debug("Update client-level role '{}' for client '{}' in realm '{}'", roleName, clientId, realm); roleRepository.updateClientRole(realm, clientId, patchedRole); } }
Example 7
Source File: RoleContainerResource.java From keycloak with Apache License 2.0 | 5 votes |
/** * Create a new role for the realm or client * * @param rep * @return */ @POST @Consumes(MediaType.APPLICATION_JSON) public Response createRole(final RoleRepresentation rep) { auth.roles().requireManage(roleContainer); if (rep.getName() == null) { throw new BadRequestException(); } try { RoleModel role = roleContainer.addRole(rep.getName()); role.setDescription(rep.getDescription()); rep.setId(role.getId()); if (role.isClientRole()) { adminEvent.resource(ResourceType.CLIENT_ROLE); } else { adminEvent.resource(ResourceType.REALM_ROLE); } adminEvent.operation(OperationType.CREATE).resourcePath(uriInfo, role.getName()).representation(rep).success(); return Response.created(uriInfo.getAbsolutePathBuilder().path(role.getName()).build()).build(); } catch (ModelDuplicateException e) { return ErrorResponse.exists("Role with name " + rep.getName() + " already exists"); } }
Example 8
Source File: RealmRolesPartialImport.java From keycloak with Apache License 2.0 | 4 votes |
@Override public String getName(RoleRepresentation roleRep) { if (roleRep.getName() == null) throw new IllegalStateException("Realm role to import does not have a name"); return roleRep.getName(); }
Example 9
Source File: ClientRolesPartialImport.java From keycloak with Apache License 2.0 | 4 votes |
public String getName(RoleRepresentation roleRep) { if (roleRep.getName() == null) throw new IllegalStateException("Client role to import does not have a name"); return roleRep.getName(); }