Esempio n. 1
0
 public String getExceptionWorkgroupName() {
   Group exceptionGroup = getExceptionWorkgroup();
   if (exceptionWorkgroupName == null || exceptionWorkgroupName.equals("")) {
     if (exceptionGroup != null) {
       return exceptionGroup.getName();
     }
   }
   return exceptionWorkgroupName;
 }
 protected boolean checkDelegationMember(RoleDocumentDelegationMember newMember) {
   if (StringUtils.isBlank(newMember.getMemberTypeCode())
       || StringUtils.isBlank(newMember.getMemberId())) {
     GlobalVariables.getMessageMap()
         .putError(
             "document.delegationMember.memberId",
             RiceKeyConstants.ERROR_EMPTY_ENTRY,
             new String[] {"Member Type Code and Member ID"});
     return false;
   }
   if (MemberType.PRINCIPAL.getCode().equals(newMember.getMemberTypeCode())) {
     Principal principalInfo = getIdentityService().getPrincipal(newMember.getMemberId());
     if (principalInfo == null) {
       GlobalVariables.getMessageMap()
           .putError(
               "document.delegationMember.memberId",
               RiceKeyConstants.ERROR_MEMBERID_MEMBERTYPE_MISMATCH,
               new String[] {newMember.getMemberId()});
       return false;
     } else {
       newMember.setMemberName(principalInfo.getPrincipalName());
     }
   } else if (MemberType.GROUP.getCode().equals(newMember.getMemberTypeCode())) {
     Group groupInfo = null;
     groupInfo = getGroupService().getGroup(newMember.getMemberId());
     if (groupInfo == null) {
       GlobalVariables.getMessageMap()
           .putError(
               "document.delegationMember.memberId",
               RiceKeyConstants.ERROR_MEMBERID_MEMBERTYPE_MISMATCH,
               new String[] {newMember.getMemberId()});
       return false;
     } else {
       newMember.setMemberName(groupInfo.getName());
       newMember.setMemberNamespaceCode(groupInfo.getNamespaceCode());
     }
   } else if (MemberType.ROLE.getCode().equals(newMember.getMemberTypeCode())) {
     Role roleInfo = KimApiServiceLocator.getRoleService().getRole(newMember.getMemberId());
     if (roleInfo == null) {
       GlobalVariables.getMessageMap()
           .putError(
               "document.delegationMember.memberId",
               RiceKeyConstants.ERROR_MEMBERID_MEMBERTYPE_MISMATCH,
               new String[] {newMember.getMemberId()});
       return false;
     } else {
       newMember.setMemberName(roleInfo.getName());
       newMember.setMemberNamespaceCode(roleInfo.getNamespaceCode());
     }
   }
   return true;
 }
  protected boolean checkKimDocumentRoleMember(KimDocumentRoleMember newMember) {
    boolean memberExists = false;
    String memberName = null;
    String memberNamespace = null;

    if (StringUtils.isBlank(newMember.getMemberId())) {
      GlobalVariables.getMessageMap()
          .putError(
              "document.member.memberId",
              RiceKeyConstants.ERROR_EMPTY_ENTRY,
              new String[] {"Member ID"});
      return false;
    }

    if (MemberType.PRINCIPAL.getCode().equals(newMember.getMemberTypeCode())) {
      Principal pi = this.getIdentityService().getPrincipal(newMember.getMemberId());
      if (pi != null) {
        memberExists = true;
        memberName = pi.getPrincipalName();
        memberNamespace = "";
      }
    } else if (MemberType.GROUP.getCode().equals(newMember.getMemberTypeCode())) {
      Group gi = KimApiServiceLocator.getGroupService().getGroup(newMember.getMemberId());
      if (gi != null) {
        memberExists = true;
        memberName = gi.getName();
        memberNamespace = gi.getNamespaceCode();
      }
    } else if (MemberType.ROLE.getCode().equals(newMember.getMemberTypeCode())) {
      Role ri = KimApiServiceLocator.getRoleService().getRole(newMember.getMemberId());
      if (!validateRole(newMember.getMemberId(), ri, "document.member.memberId", "Role")) {
        return false;
      } else {
        memberExists = true;
        memberName = ri.getName();
        memberNamespace = ri.getNamespaceCode();
      }
    }

    if (!memberExists) {
      GlobalVariables.getMessageMap()
          .putError(
              "document.member.memberId",
              RiceKeyConstants.ERROR_MEMBERID_MEMBERTYPE_MISMATCH,
              new String[] {newMember.getMemberId()});
      return false;
    }
    newMember.setMemberName(memberName);
    newMember.setMemberNamespaceCode(memberNamespace);
    return true;
  }
Esempio n. 4
0
 public String getDisplayName() {
   if (isUserRequest()) {
     Person person = getPerson();
     if (person != null) {
       return person.getName();
     }
   } else if (isGroupRequest()) {
     Group group = getGroup();
     if (group != null) {
       return group.getName();
     } else {
       return getGroupId();
     }
   } else if (isRoleRequest()) {
     return getRoleName();
   }
   return "";
 }
  @Test
  public void testCreateGroupWithCustomKimTypeAttributes() {
    // This test needs to be run in separate test class
    // with @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.NONE)
    KimAttribute.Builder kimAttribute =
        KimAttribute.Builder.create(KIM_ATTRIBUTE_COMPONENT_NAME, KIM_ATTRIBUTE_NAME, NAMESPACE);
    kimAttribute.setAttributeLabel(KIM_ATTRIBUTE_LABEL);
    kimAttribute.setId(KIM_ATTRIBUTE_ID);
    kimAttribute.setActive(true);
    KimAttributeBo kimAddrBo =
        KRADServiceLocator.getDataObjectService().save(KimAttributeBo.from(kimAttribute.build()));

    KimType.Builder kimTypeBuilder = KimType.Builder.create();
    kimTypeBuilder.setId(KIM_TYPE_ID);
    kimTypeBuilder.setName(KIM_TYPE_NAME);
    kimTypeBuilder.setNamespaceCode(NAMESPACE);
    kimTypeBuilder.setServiceName(KIM_TYPE_SERVICE_NAME);
    kimTypeBuilder.setActive(true);
    KimTypeBo kimTypeBo =
        KRADServiceLocator.getDataObjectService().save(KimTypeBo.from(kimTypeBuilder.build()));

    KimTypeAttribute.Builder kimTypeAttributeBuilder = KimTypeAttribute.Builder.create();
    kimTypeAttributeBuilder.setId(KIM_TYPE_ATTRIBUTE_ID);
    kimTypeAttributeBuilder.setActive(true);
    kimTypeAttributeBuilder.setSortCode("a");
    kimTypeAttributeBuilder.setKimTypeId(KIM_TYPE_ID);
    kimTypeAttributeBuilder.setKimAttribute(kimAttribute);
    KimTypeAttributeBo kimTypeAttrBo =
        KRADServiceLocator.getDataObjectService()
            .save(KimTypeAttributeBo.from(kimTypeAttributeBuilder.build()));

    kimTypeBuilder =
        KimType.Builder.create(
            KimApiServiceLocator.getKimTypeInfoService().getKimType(KIM_TYPE_ID));
    kimTypeAttributeBuilder = KimTypeAttribute.Builder.create(kimTypeAttrBo);
    List<KimTypeAttribute.Builder> attrList = Collections.singletonList(kimTypeAttributeBuilder);
    kimTypeBuilder.setAttributeDefinitions(attrList);

    kimTypeBo =
        KRADServiceLocator.getDataObjectService().save(KimTypeBo.from(kimTypeBuilder.build()));
    KRADServiceLocator.getDataObjectService().flush(KimTypeBo.class);

    Map<String, String> attributes = new HashMap<String, String>();
    attributes.put(KIM_ATTRIBUTE_NAME, KIM_ATTRIBUTE_VALUE);

    Group.Builder groupInfo = Group.Builder.create(NAMESPACE, GROUP_NAME, KIM_TYPE_ID);
    groupInfo.setAttributes(attributes);
    groupInfo.setActive(true);
    groupInfo.setDescription(KIM_ATTRIBUTE_LABEL + " " + KIM_ATTRIBUTE_VALUE);
    Group group = KimApiServiceLocator.getGroupService().createGroup(groupInfo.build());

    Group result =
        KimApiServiceLocator.getGroupService()
            .getGroupByNamespaceCodeAndName(NAMESPACE, GROUP_NAME);
    assertEquals(groupInfo.isActive(), result.isActive());
    assertTrue(groupInfo.getNamespaceCode().equals(result.getNamespaceCode()));
    assertTrue(groupInfo.getName().equals(result.getName()));
    assertTrue(groupInfo.getKimTypeId().equals(result.getKimTypeId()));
    assertEquals(1, result.getAttributes().size());
    assertTrue(result.getAttributes().get(KIM_ATTRIBUTE_NAME).contains(KIM_ATTRIBUTE_VALUE));
  }