/**
  * Read the header from the file and determine the attributes for the account object this resource
  * supports.
  */
 public Schema schema() {
   // read the header to construct an ConnectionObjectInfo..
   final SchemaBuilder bld = new SchemaBuilder(getClass());
   BufferedReader rdr = null;
   try {
     // open the file for reading..
     rdr = this.cfg.newFileReader();
     // build the connector info object..
     // read the header..
     Set<AttributeInfo> attrInfos = new HashSet<AttributeInfo>();
     List<String> fieldNames =
         readHeader(
             rdr,
             this.cfg.getFieldDelimiter(),
             this.cfg.getTextQualifier(),
             this.cfg.getUniqueAttributeName());
     for (String fieldName : fieldNames) {
       AttributeInfoBuilder abld = new AttributeInfoBuilder();
       abld.setName(fieldName);
       abld.setCreateable(false);
       abld.setUpdateable(false);
       attrInfos.add(abld.build());
     }
     // set it to object class account..
     bld.defineObjectClass(ObjectClass.ACCOUNT_NAME, attrInfos);
   } catch (IOException e) {
     throw new IllegalStateException(e);
   } finally {
     IOUtil.quietClose(rdr);
   }
   // return the new schema object..
   return bld.build();
 }
Esempio n. 2
0
  public Schema schema() {

    SchemaBuilder schemaBuilder = new SchemaBuilder(SASConnector.class);
    ObjectClassInfo accountObjectClassInfo =
        createObjectClassInfo(ObjectClass.ACCOUNT_NAME, MetadataObjects.PERSON);
    ObjectClassInfo groupObjectClassInfo =
        createObjectClassInfo(ObjectClass.GROUP_NAME, MetadataObjects.GROUP);
    schemaBuilder.defineObjectClass(accountObjectClassInfo);
    schemaBuilder.defineObjectClass(groupObjectClassInfo);

    //		List<String> metadataObjects = new ArrayList<String>();
    //		try {
    //			connection.getFactory().getOMIUtil().getTypes(metadataObjects, new ArrayList<String>());
    //
    //			for (String metadataObject : metadataObjects){
    //				LOG.ok("Gnerating object class for metadata object {0}" , metadataObject);
    //				if (MetadataObjects.PERSON.equals(metadataObject)){
    //					continue;
    //				}
    //				if (MetadataObjects.GROUP.equals(metadataObject)){
    //					continue;
    //				}
    //				//let the icf object class the same as metadata object specified..it will generate prefix
    // complex and sufix obejctclass
    //				ObjectClassInfo objClassInfo = createObjectClassInfo(metadataObject, metadataObject);
    //				schemaBuilder.defineObjectClass(objClassInfo);
    //			}
    //
    //		} catch (RemoteException e) {
    //			throw new ConnectorException(e);
    //		} catch (MdException e) {
    //			throw new ConnectorException(e);
    //		}

    return schemaBuilder.build();
  }
Esempio n. 3
0
  @Override
  public Schema buildSchema() {
    final SchemaBuilder schemaBuilder = new SchemaBuilder(SolarisConnector.class);

    /*
     * GROUP
     */
    Set<AttributeInfo> attributes = new HashSet<AttributeInfo>();
    // attributes.add(Name.INFO);
    for (GroupAttribute attr : GroupAttribute.values()) {
      switch (attr) {
        case USERS:
          attributes.add(
              AttributeInfoBuilder.build(
                  attr.getName(), String.class, EnumSet.of(Flags.MULTIVALUED)));
          break;
        case GROUPNAME:
          attributes.add(
              AttributeInfoBuilder.build(attr.getName(), String.class, EnumSet.of(Flags.REQUIRED)));
          break;
        case GID:
          attributes.add(
              AttributeInfoBuilder.build(
                  attr.getName(), int.class, EnumSet.of(Flags.NOT_RETURNED_BY_DEFAULT)));
          break;

        default:
          attributes.add(AttributeInfoBuilder.build(attr.getName()));
          break;
      }
    }

    // GROUP supports no authentication:
    final ObjectClassInfo ociInfoGroup =
        new ObjectClassInfoBuilder()
            .setType(ObjectClass.GROUP_NAME)
            .addAllAttributeInfo(attributes)
            .build();
    schemaBuilder.defineObjectClass(ociInfoGroup);
    schemaBuilder.removeSupportedObjectClass(AuthenticateOp.class, ociInfoGroup);
    schemaBuilder.removeSupportedObjectClass(ResolveUsernameOp.class, ociInfoGroup);

    /*
     * ACCOUNT
     */
    attributes = new HashSet<AttributeInfo>();
    attributes.add(OperationalAttributeInfos.PASSWORD);
    for (AccountAttribute attr : AccountAttribute.values()) {
      String attrName = attr.getName();
      AttributeInfo newAttr = null;
      switch (attr) {
        case NAME:
          newAttr = AttributeInfoBuilder.build(attrName, String.class, EnumSet.of(Flags.REQUIRED));
          break;
        case MIN:
        case MAX:
        case WARN:
        case INACTIVE:
        case UID:
          newAttr =
              AttributeInfoBuilder.build(
                  attrName, int.class, EnumSet.of(Flags.NOT_RETURNED_BY_DEFAULT));
          break;
        case PASSWD_FORCE_CHANGE:
        case LOCK:
          newAttr =
              AttributeInfoBuilder.build(
                  attrName, boolean.class, EnumSet.of(Flags.NOT_RETURNED_BY_DEFAULT));
          break;
        case SECONDARY_GROUP:
        case ROLES:
        case AUTHORIZATION:
        case PROFILE:
          newAttr =
              AttributeInfoBuilder.build(
                  attrName,
                  String.class,
                  EnumSet.of(Flags.MULTIVALUED, Flags.NOT_RETURNED_BY_DEFAULT));
          break;
        case REGISTRY:
        case TIME_LAST_LOGIN:
          newAttr =
              AttributeInfoBuilder.build(
                  attrName,
                  String.class,
                  EnumSet.of(
                      Flags.NOT_UPDATEABLE, Flags.NOT_CREATABLE, Flags.NOT_RETURNED_BY_DEFAULT));
          break;
        default:
          newAttr = AttributeInfoBuilder.build(attrName);
          break;
      }

      if (newAttr != null) {
        attributes.add(newAttr);
      }
    }

    tweakAccountActivationSchema(attributes);

    final ObjectClassInfo ociInfoAccount =
        new ObjectClassInfoBuilder()
            .setType(ObjectClass.ACCOUNT_NAME)
            .addAllAttributeInfo(attributes)
            .build();
    schemaBuilder.defineObjectClass(ociInfoAccount);

    /*
     * SHELL
     */
    attributes = new HashSet<AttributeInfo>();
    attributes.add(
        AttributeInfoBuilder.build(
            SolarisSearch.SHELL.getObjectClassValue(),
            String.class,
            EnumSet.of(Flags.MULTIVALUED, Flags.NOT_RETURNED_BY_DEFAULT, Flags.NOT_UPDATEABLE)));
    final ObjectClassInfo ociInfoShell =
        new ObjectClassInfoBuilder()
            .addAllAttributeInfo(attributes)
            .setType(SolarisSearch.SHELL.getObjectClassValue())
            .build();
    schemaBuilder.defineObjectClass(ociInfoShell);
    schemaBuilder.removeSupportedObjectClass(AuthenticateOp.class, ociInfoShell);
    schemaBuilder.removeSupportedObjectClass(CreateOp.class, ociInfoShell);
    schemaBuilder.removeSupportedObjectClass(UpdateOp.class, ociInfoShell);
    schemaBuilder.removeSupportedObjectClass(DeleteOp.class, ociInfoShell);
    schemaBuilder.removeSupportedObjectClass(SchemaOp.class, ociInfoShell);
    schemaBuilder.removeSupportedObjectClass(ResolveUsernameOp.class, ociInfoShell);

    return schemaBuilder.build();
  }