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


Java Account类代码示例

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


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

示例1: validate

import com.stormpath.sdk.account.Account; //导入依赖的package包/类
@Override
public void validate(final UsernamePasswordCredentials credentials, final WebContext context) throws HttpAction {

    init(context);

    try {
        logger.debug("Attempting to authenticate user [{}] against application [{}] in Stormpath cloud...",
                credentials.getUsername(), this.application.getName());
        final Account account = authenticateAccount(credentials);
        logger.debug("Successfully authenticated user [{}]", account.getUsername());

        final StormpathProfile profile = createProfile(account);
        credentials.setUserProfile(profile);
    } catch (final ResourceException e) {
        throw new BadCredentialsException("Bad credentials for: " + credentials.getUsername(), e);
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:18,代码来源:StormpathAuthenticator.java

示例2: getItems

import com.stormpath.sdk.account.Account; //导入依赖的package包/类
/**
 * Obtiene la lista de los registros de Item asociados a un Client
 *
 * @return Colección de objetos de ItemDetailDTO
 * @generated
 */
@GET
public List<ItemDetailDTO> getItems() {
    String accountHref = req.getRemoteUser();
    if (accountHref != null) {
        Account account = Utils.getClient().getResource(accountHref, Account.class);
        Integer clientsId = (Integer) account.getCustomData().get("client_id");
        if(clientsId != null) {
            if (page != null && maxRecords != null) {
                this.response.setIntHeader("X-Total-Count", itemLogic.countItems());
                return listEntity2DTO(itemLogic.getItems(page, maxRecords, clientsId.longValue()));
            }
            return listEntity2DTO(itemLogic.getItems(clientsId.longValue()));
        }
    }
    throw new WebApplicationException("User not authorized to do this", 403);
}
 
开发者ID:Uniandes-MISO4203-backup,项目名称:turism-201620-2,代码行数:23,代码来源:UserItemResource.java

示例3: createItem

import com.stormpath.sdk.account.Account; //导入依赖的package包/类
/**
 * Asocia un Item existente a un Client
 *
 * @param dto Objeto de ItemDetailDTO con los datos nuevos
 * @return Objeto de ItemDetailDTOcon los datos nuevos y su ID.
 * @generated
 */
@POST
@StatusCreated
public ClientDetailDTO createItem(ItemDetailDTO dto) {
    String accountHref = req.getRemoteUser();
    if (accountHref != null) {
        Account account = Utils.getClient().getResource(accountHref, Account.class);
        Integer clientsId = (Integer) account.getCustomData().get("client_id");

        if(clientsId == null){
            throw new WebApplicationException("User is not client", 403);
        }

        itemLogic.createItem(clientsId.longValue(), dto.toEntity());
        ClientDetailDTO clientDetailDTO = new ClientDetailDTO();
        clientDetailDTO.setId(clientsId.longValue());
        return clientDetailDTO;
    }
    throw new WebApplicationException("User not authorized to do this", 403);
}
 
开发者ID:Uniandes-MISO4203-backup,项目名称:turism-201620-2,代码行数:27,代码来源:UserItemResource.java

示例4: getClients

import com.stormpath.sdk.account.Account; //导入依赖的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

示例5: getAgencys

import com.stormpath.sdk.account.Account; //导入依赖的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

示例6: authenticate

import com.stormpath.sdk.account.Account; //导入依赖的package包/类
/**
 * Authenticate user with given username and password
 *
 * @param username username string
 * @param password password string
 * @return Account instance or null
 */
public static Account authenticate(String username, String password) throws ResourceException {

    AuthenticationRequest request = new UsernamePasswordRequest(username, password);
    Account account = null;
    try {
        AuthenticationResult result = getStormpathApplicaiton().authenticateAccount(request);
        account = result.getAccount();
        LOGGER.info("Authenticating user with username: {} and password: {}", new Object[]{ account.getUsername(), "******"});
    } catch (ResourceException ex) {
        LOGGER.error("status: {} requestId: {} message: {} ", new Object[] { ex.getStatus(), ex.getRequestId(), ex.getMessage()});
        throw ex;
    }

    return account;
}
 
开发者ID:burakdede,项目名称:dropwizard-stormpath,代码行数:23,代码来源:StormpathApi.java

示例7: createUser

import com.stormpath.sdk.account.Account; //导入依赖的package包/类
/**
 * Create new user account with given username and password
 *
 * @param givenName given name of user
 * @param surname last name of user
 * @param email email of user
 * @param password password of user
 * @return Account instance of new user
 * @throws ResourceException
 */
public static Account createUser(String givenName, String surname, String email, String password) throws ResourceException {
    Account created = null;
    try {
        Account account = getStormpathClient().instantiate(Account.class);
        account.setGivenName(givenName);
        account.setSurname(surname);
        account.setEmail(email);
        account.setPassword(password);

        created = getStormpathApplicaiton().createAccount(account);
    } catch (ResourceException ex) {
        LOGGER.error("status: {} requestId: {} message: {} ", new Object[] { ex.getStatus(), ex.getRequestId(), ex.getMessage()});
        throw ex;
    }

    return created;
}
 
开发者ID:burakdede,项目名称:dropwizard-stormpath,代码行数:28,代码来源:StormpathApi.java

示例8: createAccount

import com.stormpath.sdk.account.Account; //导入依赖的package包/类
private Account createAccount(final String uname, final String pw) {
	// Create the account object
	Account account = client.instantiate(Account.class);

	// Set the account properties
	account.setGivenName("Bob");
	account.setSurname("Bobbin");
	account.setUsername(uname); // optional, defaults to email if unset
	account.setEmail("[email protected]");
	account.setPassword(pw);
	CustomData cd = account.getCustomData();
	cd.put("rank", "Captain");

	// Create the account using the existing Application object
	return application.createAccount(account);
}
 
开发者ID:IHTSDO,项目名称:OTF-User-Module,代码行数:17,代码来源:BasicTest.java

示例9: authAccount

import com.stormpath.sdk.account.Account; //导入依赖的package包/类
private Account authAccount(final String acName, final String pw) {
	// Create an authentication request using the credentials
	AuthenticationRequest request = new UsernamePasswordRequest(acName, pw);

	// Now let's authenticate the account with the application:
	try {
		return application.authenticateAccount(request).getAccount();
	} catch (ResourceException name) {
		// ...catch the error and print it to the syslog if it wasn't.
		LOG.severe("Auth error: " + name.getDeveloperMessage());
		return null;
	} finally {
		// Clear the request data to prevent later memory access
		request.clear();
	}
}
 
开发者ID:IHTSDO,项目名称:OTF-User-Module,代码行数:17,代码来源:BasicTest.java

示例10: buildGroup

import com.stormpath.sdk.account.Account; //导入依赖的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

示例11: authSPAccount

import com.stormpath.sdk.account.Account; //导入依赖的package包/类
public final Account authSPAccount(final String acName, final String pw) {
	// Create an authentication request using the credentials
	AuthenticationRequest<?, ?> request = new UsernamePasswordRequest(
			acName, pw);
	Application userApp = getUsersApplication(acName);
	if (userApp == null) {
		// LOG.severe("Auth error: User " + acName + " not found. ");
		return null;
	}
	// Now let's authenticate the account with the application:
	try {
		Account userAcc = userApp.authenticateAccount(request).getAccount();
		return userAcc;
	} catch (ResourceException name) {
		// ...catch the error and print it to the syslog if it wasn't.
		LOG.severe("Auth error: " + name.getDeveloperMessage());
		return null;
	} finally {
		// Clear the request data to prevent later memory access
		request.clear();
	}
}
 
开发者ID:IHTSDO,项目名称:OTF-User-Module,代码行数:23,代码来源:Storm2Model.java

示例12: getAccount

import com.stormpath.sdk.account.Account; //导入依赖的package包/类
@VisibleForTesting
Account getAccount(ClientData clientData) {
    Account account = null;

    AccountList accountList = application.getAccounts(Accounts
            .where(Accounts.username().eqIgnoreCase(clientData.getUsername().get())));

    // Iterator is necessary, because there's no size() in the ApplicationsList class and the AccountList could be empty,
    // if the username changes while the client is still connected.
    final Iterator<Account> iterator = accountList.iterator();
    if (iterator.hasNext()) {
        account = iterator.next();
    }

    return account;
}
 
开发者ID:hivemq,项目名称:hivemq-stormpath-plugin,代码行数:17,代码来源:Authorization.java

示例13: buildAttributesFromStormpathAccount

import com.stormpath.sdk.account.Account; //导入依赖的package包/类
protected Map<String, Object> buildAttributesFromStormpathAccount(final Account account) {
    final Map<String, Object> attributes = new HashMap<>();
    attributes.put("fullName", account.getFullName());
    attributes.put("email", account.getEmail());
    attributes.put("givenName", account.getGivenName());
    attributes.put("middleName", account.getMiddleName());
    attributes.put("surName", account.getSurname());
    attributes.put("groups", account.getGroups());
    attributes.put("groupMemberships", account.getGroupMemberships());
    attributes.put("status", account.getStatus());
    return attributes;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:13,代码来源:StormpathAuthenticator.java

示例14: register

import com.stormpath.sdk.account.Account; //导入依赖的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

示例15: Can_convert_an_authentication_into_user_details

import com.stormpath.sdk.account.Account; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void Can_convert_an_authentication_into_user_details() {

    final AuthenticationResult result = mock(AuthenticationResult.class);

    final Account account = mock(Account.class);
    final String username = someString();
    final GroupList groups = mock(GroupList.class);
    final Collection authorities = mock(Collection.class);

    // Given
    given(result.getAccount()).willReturn(account);
    given(account.getUsername()).willReturn(username);
    given(account.getStatus()).willReturn(ENABLED);
    given(account.getGroups()).willReturn(groups);
    given(authorityConverter.convert(groups)).willReturn(authorities);

    // When
    final AccountUserDetails actual = converter.create(result);

    // Then
    assertThat(actual.getUsername(), is(username));
    assertThat(actual.getPassword(), nullValue());
    assertThat(actual.getAuthorities(), is(authorities));
    assertThat(actual.isAccountNonExpired(), is(true));
    assertThat(actual.isAccountNonLocked(), is(true));
    assertThat(actual.isCredentialsNonExpired(), is(true));
    assertThat(actual.isEnabled(), is(true));
    assertThat(actual.getAccount(), is(account));
}
 
开发者ID:shiver-me-timbers,项目名称:smt-spring-security-parent,代码行数:32,代码来源:StormpathUserDetailsFactoryTest.java


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