当前位置: 首页>>代码示例>>Java>>正文


Java Group类代码示例

本文整理汇总了Java中com.stormpath.sdk.group.Group的典型用法代码示例。如果您正苦于以下问题:Java Group类的具体用法?Java Group怎么用?Java Group使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Group类属于com.stormpath.sdk.group包,在下文中一共展示了Group类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getClients

import com.stormpath.sdk.group.Group; //导入依赖的package包/类
/**
 * Obtiene la lista de los registros de Client
 *
 * @return Colección de objetos de ClientDetailDTO
 * @generated
 */
@GET
public List<ClientDetailDTO> getClients() {
    String accountHref = req.getRemoteUser();
    if (accountHref != null) {
        Account account = Utils.getClient().getResource(accountHref, Account.class);
        for (Group gr : account.getGroups()) {
            switch (gr.getHref()) {
                case ADMIN_HREF:
                    if (page != null && maxRecords != null) {
                        this.response.setIntHeader("X-Total-Count", clientLogic.countClients());
                        return listEntity2DTO(clientLogic.getClients(page, maxRecords));
                    }
                    return listEntity2DTO(clientLogic.getClients());
                case CLIENT_HREF:
                    Integer id = (int) account.getCustomData().get("client_id");
                    List<ClientDetailDTO> list = new ArrayList();
                    list.add(new ClientDetailDTO(clientLogic.getClient(id.longValue())));
                    return list;
            }
        }
    } 
    return null;
}
 
开发者ID:Uniandes-MISO4203-backup,项目名称:turism-201620-2,代码行数:30,代码来源:ClientResource.java

示例2: getAgencys

import com.stormpath.sdk.group.Group; //导入依赖的package包/类
/**
 * Obtiene la lista de los registros de Agency
 *
 * @return Colección de objetos de AgencyDetailDTO
 * @generated
 */
@GET
public List<AgencyDetailDTO> getAgencys() {
    String accountHref = req.getRemoteUser();
    if (accountHref != null) {
        Account account = Utils.getClient().getResource(accountHref, Account.class);
        for (Group gr : account.getGroups()) {
            switch (gr.getHref()) {
                case ADMIN_HREF:
                    if (page != null && maxRecords != null) {
                    this.response.setIntHeader("X-Total-Count", agencyLogic.countAgencys());
                    return listEntity2DTO(agencyLogic.getAgencys(page, maxRecords));
                }
                return listEntity2DTO(agencyLogic.getAgencys());
                case AGENCY_HREF:
                    Integer id = (int) account.getCustomData().get("agency_id");
                    List<AgencyDetailDTO> list = new ArrayList();
                    list.add(new AgencyDetailDTO(agencyLogic.getAgency(id.longValue())));
                    return list;
            }
        }
    } 
    return null;
}
 
开发者ID:Uniandes-MISO4203-backup,项目名称:turism-201620-2,代码行数:30,代码来源:AgencyResource.java

示例3: Can_convert_groups_to_granted_authorities

import com.stormpath.sdk.group.Group; //导入依赖的package包/类
@Test
public void Can_convert_groups_to_granted_authorities() {

    final GroupList groups = mock(GroupList.class);

    final Group group1 = mock(Group.class);
    final Group group2 = mock(Group.class);
    final Group group3 = mock(Group.class);
    final String groupName1 = someString();
    final String groupName3 = someString();

    // Given
    given(groups.iterator()).willReturn(asList(group1, group2, group3).iterator());
    given(group1.getStatus()).willReturn(ENABLED);
    given(group1.getName()).willReturn(groupName1);
    given(group2.getStatus()).willReturn(DISABLED);
    given(group2.getName()).willReturn(someString());
    given(group3.getStatus()).willReturn(ENABLED);
    given(group3.getName()).willReturn(groupName3);

    // When
    final Collection<? extends GrantedAuthority> actual = new StormpathGroupGrantedAuthorityConverter().convert(groups);

    // Then
    assertThat(actual, contains(hasField("role", groupName1), hasField("role", groupName3)));
}
 
开发者ID:shiver-me-timbers,项目名称:smt-spring-security-parent,代码行数:27,代码来源:StormpathGroupGrantedAuthorityConverterTest.java

示例4: buildGroups

import com.stormpath.sdk.group.Group; //导入依赖的package包/类
private void buildGroups(final OtfDirectory oDir, final Directory dir) {

		GroupList grps = dir.getGroups();
		for (OtfGroup ogrp : oDir.getGroups().getGroups().values()) {
			boolean found = false;
			for (Group grp : grps) {
				if (grp.getName().equals(ogrp.getName())) {
					buildGroup(ogrp, grp, dir);
					found = true;
				}
			}
			if (!found) {
				buildGroup(ogrp, null, dir);
			}
		}

	}
 
开发者ID:IHTSDO,项目名称:OTF-User-Module,代码行数:18,代码来源:Model2Storm.java

示例5: buildGroup

import com.stormpath.sdk.group.Group; //导入依赖的package包/类
public final OtfGroup buildGroup(final String href) {
	final Group grp = spbd.getResourceByHrefGroup(href);
	OtfGroup ogrp = new OtfGroup();
	ogrp.setIdref(grp.getHref());
	ogrp.setName(grp.getName());
	ogrp.setDescription(grp.getDescription());
	ogrp.setStatus(grp.getStatus().toString());

	for (Account acc : grp.getAccounts()) {
		OtfAccount oacc = buildAccount(acc);
		ogrp.getAccounts().getAccounts().put(oacc.getName(), oacc);
	}

	Map<String, Object> cd = spbd.getResourceByHrefCustomData(grp
			.getCustomData().getHref());
	for (String key : cd.keySet()) {
		if (!OtfCustomData.getReservedWords().contains(key)) {
			String val = cd.get(key).toString();
			OtfCustomField cf = new OtfCustomField(key, val);
			ogrp.getCustData().getCustFields().put(key, cf);
		}
	}
	return ogrp;
}
 
开发者ID:IHTSDO,项目名称:OTF-User-Module,代码行数:25,代码来源:Storm2Model.java

示例6: test_topic_permissions

import com.stormpath.sdk.group.Group; //导入依赖的package包/类
@Test
public void test_topic_permissions() throws Exception {
    List<Group> groups = new LinkedList<Group>();
    List<String> topics = Arrays.asList("testtopicA", "testtopicB", "testtopicC");

    addMockGroupToList(groups, topics.get(0));
    addMockGroupToList(groups, topics.get(1));
    addMockGroupToList(groups, topics.get(2));

    MockIterator mockIterator = new MockIterator(groups);
    when(groupList.iterator()).thenReturn(mockIterator);

    when(account.getGroups()).thenReturn(groupList);
    TestAuthorization testAuthorization = new TestAuthorization(app, account);
    List<MqttTopicPermission> permissions = testAuthorization.getPermissionsForClient(clientData);

    assertEquals(3, permissions.size());

    for (MqttTopicPermission permission : permissions) {
        assertTrue(topics.contains(permission.getTopic()));
    }

}
 
开发者ID:hivemq,项目名称:hivemq-stormpath-plugin,代码行数:24,代码来源:AuthorizationTest.java

示例7: register

import com.stormpath.sdk.group.Group; //导入依赖的package包/类
@Override
public void register(UserDTO user) {
    try {
       Account acct = createUser(user);
    for (Group gr : acct.getGroups()) {
        switch(gr.getHref()){
            case CLIENT_HREF:
            ClientEntity client = new ClientEntity();
            client.setName(user.getUserName());
            client = clientLogic.createClient(client);
            acct.getCustomData().put(CLIENT_CD, client.getId());
            break;
            case AGENCY_HREF:
            AgencyEntity provider = new AgencyEntity();
            provider.setName(user.getUserName());                
            provider = agencyLogic.createAgency(provider);
            acct.getCustomData().put(AGENCY_CD, provider.getId());  
            break;
            default:
             throw new WebApplicationException("Group link doen's match ");
        }
            
        }
    acct.getCustomData().save();
    } catch (ResourceException e) {
        throw new WebApplicationException(e, e.getStatus());
    }
}
 
开发者ID:Uniandes-MISO4203-backup,项目名称:turism-201620-2,代码行数:29,代码来源:UseResource.java

示例8: convert

import com.stormpath.sdk.group.Group; //导入依赖的package包/类
@Override
public Collection<? extends GrantedAuthority> convert(GroupList groups) {
    final Collection<GrantedAuthority> authorities = new ArrayList<>(groups.getSize());
    for (Group group : groups) {
        if (ENABLED.equals(group.getStatus())) {
            authorities.add(new SimpleGrantedAuthority(group.getName()));
        }
    }
    return authorities;
}
 
开发者ID:shiver-me-timbers,项目名称:smt-spring-security-parent,代码行数:11,代码来源:StormpathGroupGrantedAuthorityConverter.java

示例9: getGroups

import com.stormpath.sdk.group.Group; //导入依赖的package包/类
public final List<String> getGroups(final Directory directory) {
	ArrayList<String> groupsList = new ArrayList<String>();
	GroupList groups = directory.getGroups();
	for (Group group : groups) {
		groupsList.add(group.getName());
		LOG.info("group " + group);

	}
	return groupsList;
}
 
开发者ID:IHTSDO,项目名称:OTF-User-Module,代码行数:11,代码来源:BasicTest.java

示例10: buildAccounts

import com.stormpath.sdk.group.Group; //导入依赖的package包/类
private void buildAccounts(final OtfAccountStore oDir,
		final AccountStore accSt) {
	AccountList accs = null;
	SPAccountStoreVisitor spa = new SPAccountStoreVisitor();
	accSt.accept(spa);
	if (spa.getType().equals(SPAccountStoreVisitor.AccountStoreType.DIR)) {
		Directory dir = (Directory) accSt;
		accs = dir.getAccounts();
	}
	if (spa.getType().equals(SPAccountStoreVisitor.AccountStoreType.GROUP)) {
		Group grp = (Group) accSt;
		accs = grp.getAccounts();
	}

	if (accs != null) {
		for (OtfAccount oacc : oDir.getAccounts().getAccounts().values()) {
			boolean found = false;
			for (Account acc : accs) {
				if (acc.getUsername().equals(oacc.getName())) {
					buildAccount(oacc, acc, accSt);
					found = true;
				}
			}
			if (!found) {
				buildAccount(oacc, null, accSt);
			}

		}
	}
}
 
开发者ID:IHTSDO,项目名称:OTF-User-Module,代码行数:31,代码来源:Model2Storm.java

示例11: load

import com.stormpath.sdk.group.Group; //导入依赖的package包/类
public final void load() throws IllegalArgumentException {
	getOtfCb();

	if (cacheSP) {
		getOtfCb().setCacheManager(
				newCacheManager()
						.withDefaultTimeToLive(1, TimeUnit.DAYS)
						// general default
						.withDefaultTimeToIdle(2, TimeUnit.HOURS)
						// general default
						.withCache(
								forResource(Account.class)
										// Account-specific cache settings
										.withTimeToLive(1, TimeUnit.HOURS)
										.withTimeToIdle(30,
												TimeUnit.MINUTES))
						.withCache(forResource(Group.class) // Group-specific
															// cache
															// settings
								.withTimeToLive(2, TimeUnit.HOURS)).build() // build
																			// the
																			// CacheManager
				);
	}

	client = getOtfCb().build();

	tenant = client.getCurrentTenant();
}
 
开发者ID:IHTSDO,项目名称:OTF-User-Module,代码行数:30,代码来源:StormPathBaseDTO.java

示例12: addUpdateMemberLocal

import com.stormpath.sdk.group.Group; //导入依赖的package包/类
@Override
public final String addUpdateMemberLocal(final OtfGroup grpIn,
		final OtfDirectory mDirectoryIn, final boolean isNewIn) {
	Directory mdir = getStorm2Mod().getDirByName(mDirectoryIn.getName());
	if (mdir == null) {
		return DIR_NOT_FOUND;
	}
	if (isNewIn) {
		getMod2Storm().buildGroup(grpIn, null, mdir);
	} else {
		Group remoteG = getStorm2Mod().getGrpByName(grpIn.getName(), mdir);
		getMod2Storm().buildGroup(grpIn, remoteG, mdir);
	}
	return REMOTE_COMMIT_OK;
}
 
开发者ID:IHTSDO,项目名称:OTF-User-Module,代码行数:16,代码来源:StormPathUserSecurityHandler.java

示例13: addUpdateGroupLocal

import com.stormpath.sdk.group.Group; //导入依赖的package包/类
@Override
public final String addUpdateGroupLocal(final OtfGroup grpIn,
		final OtfDirectory mDirectoryIn, final boolean isNewIn) {
	Directory dir = getStorm2Mod().getDirByName(mDirectoryIn.getName());
	if (dir == null) {
		return DIR_NOT_FOUND;
	}
	if (isNewIn) {
		getMod2Storm().buildGroup(grpIn, null, dir);
	} else {
		Group grp = getStorm2Mod().getGrpByName(grpIn.getName(), dir);
		getMod2Storm().buildGroup(grpIn, grp, dir);
	}
	return REMOTE_COMMIT_OK;
}
 
开发者ID:IHTSDO,项目名称:OTF-User-Module,代码行数:16,代码来源:StormPathUserSecurityHandler.java

示例14: getGrpByName

import com.stormpath.sdk.group.Group; //导入依赖的package包/类
public final Group getGrpByName(final String grpName, final Directory dir) {
	GroupList groups = dir.getGroups();
	for (Group group : groups) {
		if (group.getName().equals(grpName)) {
			String dirHref = group.getHref();
			Group group2 = spbd.getResourceByHrefGroup(dirHref);
			return group2;
		}
	}
	return null;
}
 
开发者ID:IHTSDO,项目名称:OTF-User-Module,代码行数:12,代码来源:Storm2Model.java

示例15: buildDirectory

import com.stormpath.sdk.group.Group; //导入依赖的package包/类
public final OtfDirectory buildDirectory(final String hrefId) {

		Directory dir = null;
		OtfDirectory oDir = null;
		try {
			dir = spbd.getResourceByHrefDirectory(hrefId);
		} catch (ResourceException re) {
			LOG.severe("Directory at this href does not exist Dir = "
					+ " href = " + hrefId);
		}
		if (dir != null) {
			oDir = new OtfDirectory();
			oDir.setIdref(dir.getHref());
			oDir.setName(dir.getName());
			oDir.setDescription(dir.getDescription());
			oDir.setStatus(dir.getStatus().toString());
			GroupList groups = dir.getGroups();
			for (Group group : groups) {
				OtfGroup ogroup = buildGroup(group);
				ogroup.setParentDirName(dir.getName());
				oDir.getGroups().getGroups().put(ogroup.getName(), ogroup);
			}
			for (Account acc : dir.getAccounts()) {
				OtfAccount oacc = buildAccount(acc);
				oDir.getAccounts().getAccounts().put(oacc.getName(), oacc);
			}
		}
		return oDir;
	}
 
开发者ID:IHTSDO,项目名称:OTF-User-Module,代码行数:30,代码来源:Storm2Model.java


注:本文中的com.stormpath.sdk.group.Group类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。