7575import com .stormpath .sdk .saml .SamlPolicy ;
7676import com .stormpath .sdk .tenant .Tenant ;
7777
78+ import java .util .Collection ;
79+ import java .util .Collections ;
7880import java .util .Date ;
81+ import java .util .Iterator ;
7982import java .util .LinkedHashMap ;
8083import java .util .List ;
8184import java .util .Map ;
@@ -84,7 +87,7 @@ public class OktaApplication extends AbstractResource implements Application, OA
8487
8588 private final Directory OKTA_TENANT_DIR ;
8689
87- private final ApplicationAccountStoreMappingList applicationAccountStoreMappingList ;
90+ private final ApplicationAccountStoreMappingCollectionBackedList applicationAccountStoreMappingList ;
8891
8992 private String name ;
9093
@@ -101,9 +104,14 @@ public OktaApplication(InternalDataStore dataStore, Map<String, Object> properti
101104 mappingProperties .put ("application" , this );
102105 mappingProperties .put ("accountStore" , OKTA_TENANT_DIR );
103106
104- ApplicationAccountStoreMapping mapping = new DefaultApplicationAccountStoreMapping (dataStore , mappingProperties );
105-
106- applicationAccountStoreMappingList = AbstractCollectionResource .singletonCollectionResource (dataStore , DefaultApplicationAccountStoreMappingList .class , mapping );
107+ ApplicationAccountStoreMapping mapping = new DefaultApplicationAccountStoreMapping (dataStore , mappingProperties ) {
108+ @ Override
109+ public AccountStore getAccountStore () {
110+ return OKTA_TENANT_DIR ;
111+ }
112+ };
113+ mapping .setAccountStore (OKTA_TENANT_DIR );
114+ applicationAccountStoreMappingList = new ApplicationAccountStoreMappingCollectionBackedList (Collections .singletonList (mapping ));
107115 }
108116
109117 @ Override
@@ -577,4 +585,52 @@ public IdSiteAuthenticator createIdSiteAuthenticator() {
577585 public OAuthTokenRevocator createOAuhtTokenRevocator () {
578586 return new DefaultOAuthTokenRevocator (this , getDataStore (), "/oauth2/v1/token" );
579587 }
588+
589+
590+ public static class ApplicationAccountStoreMappingCollectionBackedList implements ApplicationAccountStoreMappingList {
591+
592+ final private Collection <ApplicationAccountStoreMapping > accountStoreMappings ;
593+
594+ public ApplicationAccountStoreMappingCollectionBackedList (Collection <ApplicationAccountStoreMapping > accountStoreMappings ) {
595+ this .accountStoreMappings = accountStoreMappings ;
596+ }
597+
598+ @ Override
599+ public String getHref () {
600+ return null ;
601+ }
602+
603+ @ Override
604+ public int getOffset () {
605+ return 0 ;
606+ }
607+
608+ @ Override
609+ public int getLimit () {
610+ return getSize ();
611+ }
612+
613+ @ Override
614+ public int getSize () {
615+ return accountStoreMappings .size ();
616+ }
617+
618+ @ Override
619+ public ApplicationAccountStoreMapping single () {
620+ Iterator <ApplicationAccountStoreMapping > iterator = iterator ();
621+ if (!iterator .hasNext ()) {
622+ throw new IllegalStateException ("This list is empty while it was expected to contain one (and only one) element." );
623+ }
624+ ApplicationAccountStoreMapping itemToReturn = iterator .next ();
625+ if (iterator .hasNext ()) {
626+ throw new IllegalStateException ("Only a single resource was expected, but this list contains more than one item." );
627+ }
628+ return itemToReturn ;
629+ }
630+
631+ @ Override
632+ public Iterator <ApplicationAccountStoreMapping > iterator () {
633+ return accountStoreMappings .iterator ();
634+ }
635+ }
580636}
0 commit comments