コード例 #1
0
    @Before
    public void standUp() throws DatatypeConfigurationException {
      dataTypeFactory = DatatypeFactory.newInstance();
      when(request.getRequestURI()).thenReturn("/start/104772/resource");
      when(request.getHeader(anyString())).thenReturn("tokenId");

      Calendar expires = getCalendarWithOffset(1000);

      authResponse = new AuthenticateResponse();
      UserForAuthenticateResponse userForAuthenticateResponse = new UserForAuthenticateResponse();
      userForAuthenticateResponse.setId("104772");
      userForAuthenticateResponse.setName("user2");

      userForAuthenticateResponse.setRoles(defaultRoleList());

      Token token = new Token();
      token.setId("tokenId");
      TenantForAuthenticateResponse tenant = new TenantForAuthenticateResponse();
      tenant.setId("104772");
      tenant.setName("tenantName");
      token.setTenant(tenant);
      token.setExpires(dataTypeFactory.newXMLGregorianCalendar((GregorianCalendar) expires));

      authResponse.setToken(token);
      authResponse.setUser(userForAuthenticateResponse);
    }
コード例 #2
0
  private static AuthenticateResponse getServiceResponse() {
    AuthenticateResponse rsp = new AuthenticateResponse();

    Token token = new Token();
    token.setId("tokenid");
    GregorianCalendar cal = new GregorianCalendar(2013, 11, 12);
    token.setExpires(new XMLGregorianCalendarImpl(cal));
    TenantForAuthenticateResponse tenantForAuthenticateResponse =
        new TenantForAuthenticateResponse();
    tenantForAuthenticateResponse.setId("tenantId");
    tenantForAuthenticateResponse.setName("tenantName");
    token.setTenant(tenantForAuthenticateResponse);
    rsp.setToken(token);

    ServiceCatalog catalog = new ServiceCatalog();
    List<ServiceForCatalog> serviceCatalogList = new ArrayList<>();
    ServiceForCatalog serviceForCatalog = new ServiceForCatalog();
    serviceForCatalog.setName("catName");
    serviceForCatalog.setType("type");
    serviceCatalogList.add(serviceForCatalog);
    catalog.getService().addAll(serviceCatalogList);

    rsp.setServiceCatalog(catalog);

    UserForAuthenticateResponse user = new UserForAuthenticateResponse();
    user.setId("userId");
    user.setName("userName");
    RoleList roles = new RoleList();

    Role role = new Role();
    role.setDescription("role description");
    role.setId("roleId");
    role.setName("roleName");
    role.setServiceId("serviceId");
    role.setTenantId("roleTenantId");
    roles.getRole().add(role);

    user.setRoles(roles);

    rsp.setUser(user);

    return rsp;
  }