public void assignService(String serviceName,Map attributes) throws IdRepoException, SSOException {
  IdServices idServices=IdServicesFactory.getDataStoreServices();
  Set OCs=getServiceOCs(token,serviceName);
  SchemaType stype;
  Map tMap=new HashMap();
  tMap.put(serviceName,OCs);
  Set assignedServices=idServices.getAssignedServices(token,type,name,tMap,orgName,univDN);
  if (assignedServices.contains(serviceName)) {
    Object args[]={serviceName,type.getName()};
    throw new IdRepoException(IdRepoBundle.BUNDLE_NAME,IdRepoErrorCode.SERVICE_ALREADY_ASSIGNED,args);
  }
  try {
    ServiceSchemaManager ssm=new ServiceSchemaManager(serviceName,token);
    ServiceSchema ss=ssm.getSchema(type.getName());
    if (ss != null) {
      Set cosPriority=(attributes != null) ? (Set)attributes.remove(COS_PRIORITY) : null;
      attributes=ss.validateAndInheritDefaults(attributes,orgName,true);
      if (cosPriority != null) {
        attributes.put(COS_PRIORITY,cosPriority);
      }
      attributes=AMCommonUtils.removeEmptyValues(attributes);
      stype=ss.getServiceType();
    }
 else {
      ss=ssm.getSchema(SchemaType.DYNAMIC);
      if (ss == null) {
        Object args[]={serviceName};
        throw new IdRepoException(IdRepoBundle.BUNDLE_NAME,IdRepoErrorCode.UNABLE_GET_SERVICE_SCHEMA,args);
      }
      if (attributes == null) {
        try {
          attributes=getServiceConfig(token,serviceName,SchemaType.DYNAMIC);
        }
 catch (        SMSException smsex) {
          Object args[]={serviceName,type.getName()};
          throw new IdRepoException(IdRepoBundle.BUNDLE_NAME,"451",args);
        }
      }
 else {
        attributes=ss.validateAndInheritDefaults(attributes,orgName,true);
      }
      attributes=AMCommonUtils.removeEmptyValues(attributes);
      stype=SchemaType.DYNAMIC;
    }
    attributes=AMCrypt.encryptPasswords(attributes,ss);
  }
 catch (  SMSException smse) {
    Object[] args={serviceName};
    throw new IdRepoException(IdRepoBundle.BUNDLE_NAME,IdRepoErrorCode.SERVICE_NOT_ASSIGNED,args);
  }
  attributes.put("objectclass",OCs);
  idServices.assignService(token,type,name,serviceName,stype,attributes,orgName,univDN);
}

public void assignService ( String serviceName , Map attributes ) throws IdRepoException , SSOException { IdServices idServices = IdServicesFactory . getDataStoreServices ( ) ; Set OCs = getServiceOCs ( token , serviceName ) ; SchemaType stype ; Map tMap = new HashMap ( ) ; tMap . put ( serviceName , OCs ) ; Set assignedServices = idServices . getAssignedServices ( token , type , name , tMap , orgName , univDN ) ; if ( assignedServices . contains ( serviceName ) ) { Object args [ ] = { serviceName , type . getName ( ) } ; throw new IdRepoException ( IdRepoBundle . BUNDLE_NAME , IdRepoErrorCode . SERVICE_ALREADY_ASSIGNED , args ) ; } try { ServiceSchemaManager ssm = new ServiceSchemaManager ( serviceName , token ) ; ServiceSchema ss = ssm . getSchema ( type . getName ( ) ) ; if ( ss != null ) { Set cosPriority = ( attributes != null ) ? ( Set ) attributes . remove ( COS_PRIORITY ) : null ; attributes = ss . validateAndInheritDefaults ( attributes , orgName , true ) ; if ( cosPriority != null ) { attributes . put ( COS_PRIORITY , cosPriority ) ; } attributes = AMCommonUtils . removeEmptyValues ( attributes ) ; stype = ss . getServiceType ( ) ; } else { ss = ssm . getSchema ( SchemaType . DYNAMIC ) ; if ( ss == null ) { Object args [ ] = { serviceName } ; throw new IdRepoException ( IdRepoBundle . BUNDLE_NAME , IdRepoErrorCode . UNABLE_GET_SERVICE_SCHEMA , args ) ; } if ( attributes == null ) { try { attributes = getServiceConfig ( token , serviceName , SchemaType . DYNAMIC ) ; } catch ( SMSException smsex ) { Object args [ ] = { serviceName , type . getName ( ) } ; throw new IdRepoException ( IdRepoBundle . BUNDLE_NAME , "451" , args ) ; } } else { attributes = ss . validateAndInheritDefaults ( attributes , orgName , true ) ; } attributes = AMCommonUtils . removeEmptyValues ( attributes ) ; stype = SchemaType . DYNAMIC ; } attributes = AMCrypt . encryptPasswords ( attributes , ss ) ; } catch ( SMSException smse ) { Object [ ] args = { serviceName } ; throw new IdRepoException ( IdRepoBundle . BUNDLE_NAME , IdRepoErrorCode . SERVICE_NOT_ASSIGNED , args ) ; } attributes . put ( "objectclass" , OCs ) ; idServices . assignService ( token , type , name , serviceName , stype , attributes , orgName , univDN ) ; }
assigns the service and service related attributes to the identity . this method is only valid for amidentity object of type user .
