• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ApplicationUser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: renderRepoSettings

import com.atlassian.bitbucket.user.ApplicationUser; //导入依赖的package包/类
void renderRepoSettings(String projectKey, String repoSlug, String username, HttpServletResponse response) throws IOException {
  Repository repo = repoService.getBySlug(projectKey, repoSlug);
  if(repo == null) {
    logger.warn("Project/Repo [{}/{}] not found for user {}", projectKey, repoSlug, username);
    response.setStatus(HttpServletResponse.SC_NOT_FOUND);
    return;
  }

  ApplicationUser appUser = userUtils.getApplicationUserByName(username);
  if(permissionService.hasRepositoryPermission(appUser, repo, Permission.REPO_ADMIN)) {
    response.setStatus(HttpServletResponse.SC_OK);
    response.setContentType("text/html;charset=utf-8");
    renderer.render("repo-config.html", ImmutableMap.<String, Object>of(
        "projectKey", projectKey,
        "repositorySlug", repoSlug
                                                                       ), response.getWriter());
  } else {
    logger.debug("Permission denied for user [{}]", username);
    response.setStatus(HttpServletResponse.SC_FORBIDDEN);
  }
}
 
开发者ID:monitorjbl,项目名称:pr-harmony,代码行数:22,代码来源:ConfigServlet.java


示例2: renderProjectSettings

import com.atlassian.bitbucket.user.ApplicationUser; //导入依赖的package包/类
void renderProjectSettings(String projectKey, String username, HttpServletResponse response) throws IOException {
  Project project = projectService.getByKey(projectKey);
  if(project == null) {
    logger.warn("Project [{}] not found for user {}", projectKey, username);
    response.setStatus(HttpServletResponse.SC_NOT_FOUND);
    return;
  }

  ApplicationUser appUser = userUtils.getApplicationUserByName(username);
  if(permissionService.hasProjectPermission(appUser, project, Permission.PROJECT_ADMIN)) {
    response.setStatus(HttpServletResponse.SC_OK);
    response.setContentType("text/html;charset=utf-8");
    renderer.render("project-config.html", ImmutableMap.<String, Object>of(
        "projectKey", projectKey
                                                                          ), response.getWriter());
  } else {
    logger.debug("Permission denied for user [{}]", username);
    response.setStatus(HttpServletResponse.SC_FORBIDDEN);
  }
}
 
开发者ID:monitorjbl,项目名称:pr-harmony,代码行数:21,代码来源:ConfigServlet.java


示例3: authenticate

import com.atlassian.bitbucket.user.ApplicationUser; //导入依赖的package包/类
@Nullable
@Override
public ApplicationUser authenticate(HttpAuthenticationContext ctx) {
  HttpServletRequest request = ctx.getRequest();
  String username = request.getHeader(USER_HEADER);
  String token = request.getHeader(TOKEN_HEADER);
  String path = request.getRequestURI().replaceFirst(request.getContextPath(), "");

  if(isNotEmpty(username) && isNotEmpty(token) && path.startsWith("/rest/")) {
    if(isTokenValid(path, username, token)) {
      return userService.getUserByName(username);
    }
  }

  return null;
}
 
开发者ID:monitorjbl,项目名称:stash-token-auth,代码行数:17,代码来源:TokenAuthenticationHandler.java


示例4: notifyUserOfExpiredKey

import com.atlassian.bitbucket.user.ApplicationUser; //导入依赖的package包/类
public void notifyUserOfExpiredKey(int userId) {
    ApplicationUser user = userService.getUserById(userId);
    String pageUrl = applicationPropertiesService.getBaseUrl() + KEY_GEN_CONTEXT;
    String subject = i18nService.getMessage("stash.ssh.reset.email.subject");
    int maxDays = pluginSettingsService.getDaysAllowedForUserKeys();
    String body = i18nService.getMessage("stash.ssh.reset.email.body",pageUrl,maxDays);
    String policyUrl = pluginSettingsService.getInternalKeyPolicyLink();
    if( null != policyUrl){
        body = body + "\n " + i18nService.getMessage("stash.ssh.reset.email.policy",policyUrl);
    }
    if (null != user) {
        if(log.isDebugEnabled()){
            log.debug("Sending email to: " + user.getEmailAddress());
        }
        MailMessage message = new MailMessage.Builder()
                .to(user.getEmailAddress())
                .subject(subject)
                .text(body).build();
        mailService.submit(message);
    } else {
        throw new UserNotFoundException();
    }
}
 
开发者ID:libertymutual,项目名称:ssh-key-enforcer-stash,代码行数:24,代码来源:NotificationService.java


示例5: createOrUpdateUserKey

import com.atlassian.bitbucket.user.ApplicationUser; //导入依赖的package包/类
@Override
public SshKeyEntity createOrUpdateUserKey(ApplicationUser user, String text, String label) {
    return ao.executeInTransaction(new TransactionCallback<SshKeyEntity>() {

        @Override
        public SshKeyEntity doInTransaction() {
            SshKeyEntity key = findSingleUserKey(user);
            if (null != key) {
                key.setText(text);
                key.setLabel(label);
                key.setCreatedDate(new Date());
                key.save();
                log.debug("Updated existing key for user");
            } else {
                key = ao.create(SshKeyEntity.class, new DBParam("TYPE", SshKeyEntity.KeyType.USER), new DBParam("USERID", user.getId()), new DBParam("TEXT", text), new DBParam("LABEL", label), new DBParam("CREATED", new Date()));
                log.debug("created new key for user");
            }

            return key;
        }
    });
}
 
开发者ID:libertymutual,项目名称:ssh-key-enforcer-stash,代码行数:23,代码来源:EnterpriseKeyRepositoryImpl.java


示例6: getAllKeysForUser

import com.atlassian.bitbucket.user.ApplicationUser; //导入依赖的package包/类
@GET
@Path("/user/{username}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getAllKeysForUser(@PathParam("username") String username) {
    ApplicationUser user = userService.getUserBySlug(username);
    try {
        List<SshKeyEntity> keyEntities = enterpriseKeyService.getKeysForUser(username);
        List<KeyDetailsResourceModel> keyResources = new ArrayList<KeyDetailsResourceModel>();
        for (SshKeyEntity keyEntity : keyEntities) {
            keyResources.add(KeyDetailsResourceModel.from(keyEntity,user));
        }
        return Response.ok(keyResources).build();
    } catch (EnterpriseKeyGenerationException e) {
        return Response.serverError().build();
    }

}
 
开发者ID:libertymutual,项目名称:ssh-key-enforcer-stash,代码行数:18,代码来源:KeyDetailsResource.java


示例7: addAllowedBypass

import com.atlassian.bitbucket.user.ApplicationUser; //导入依赖的package包/类
/**
 * If allowed user ID or Group exception this will add meta to our own records, and return true
 * returns boolean: attempt was valid and added
 */
private boolean addAllowedBypass(SshKey key, ApplicationUser stashUser) {
    String bambooUser =  pluginSettingsService.getAuthorizedUser();
    String userGroup = pluginSettingsService.getAuthorizedGroup();
    if( bambooUser != null && bambooUser.equals(stashUser.getName())){
        log.debug("Username matches configured 'bambooUser', adding record");
        log.info("Bamboo Key {} created by an authorized bamboo system ID {} ", key.getId(), stashUser.getSlug());
        enterpriseKeyRepository.saveExternallyGeneratedKeyDetails(key,stashUser,SshKeyEntity.KeyType.BAMBOO);
        return true;
    }else if( userGroup != null && userService.existsGroup(userGroup) && userService.isUserInGroup(stashUser, userGroup)){
        log.debug("Username matches configured 'authorizedGroup', adding record");
        log.info("Bypass Key {} created by an authorized user {} in authorized group", key.getId(), stashUser.getSlug());
        enterpriseKeyRepository.saveExternallyGeneratedKeyDetails(key,stashUser,SshKeyEntity.KeyType.BYPASS);
        return true;
    }
    log.debug("User not in excused roles, do not allow.");
    return false;
}
 
开发者ID:libertymutual,项目名称:ssh-key-enforcer-stash,代码行数:22,代码来源:EnterpriseSshKeyServiceImpl.java


示例8: replaceExpiredKeysAndNotifyUsers

import com.atlassian.bitbucket.user.ApplicationUser; //导入依赖的package包/类
@Override
public void replaceExpiredKeysAndNotifyUsers() {
    DateTime dateTime = new DateTime();
    Date oldestAllowed = dateTime.minusDays(pluginSettingsService.getDaysAllowedForUserKeys()).toDate();
    //Date oldestAllowed = dateTime.minusMillis(100).toDate(); //for live demos
    List<SshKeyEntity> expiredStashKeys = enterpriseKeyRepository.listOfExpiredKeys( oldestAllowed, KeyType.USER);
   
    
    for (SshKeyEntity keyRecord : expiredStashKeys) {
        try{
            ApplicationUser user = userService.getUserById(keyRecord.getUserId());
            String username = ( null != user ? user.getSlug() : "UNKNOWN_ID:"+keyRecord.getUserId());
            log.info("Removing Key for user: {}. KeyId: {}" , username, keyRecord.getKeyId());
            sshKeyService.remove(keyRecord.getKeyId());
            enterpriseKeyRepository.removeRecord(keyRecord);
            notificationService.notifyUserOfExpiredKey(keyRecord.getUserId());
            log.info("Key Removed");
        }catch(Exception e){
            log.error("Key removal failed for user: " + keyRecord.getUserId());
            e.printStackTrace();
        }
    }
}
 
开发者ID:libertymutual,项目名称:ssh-key-enforcer-stash,代码行数:24,代码来源:EnterpriseSshKeyServiceImpl.java


示例9: dereferenceGroups

import com.atlassian.bitbucket.user.ApplicationUser; //导入依赖的package包/类
public List<String> dereferenceGroups(List<String> groups) {
  List<String> users = newArrayList();
  for(String group : groups) {
    List<ApplicationUser> results = newArrayList(userService.findUsersByGroup(group, new PageRequestImpl(0, RESULTS_PER_REQUEST)).getValues());
    for(int i = 1; results.size() > 0; i++) {
      users.addAll(results.stream()
          .map(ApplicationUser::getSlug)
          .collect(Collectors.toList()));
      results = newArrayList(userService.findUsersByGroup(group, new PageRequestImpl(i * RESULTS_PER_REQUEST, RESULTS_PER_REQUEST)).getValues());
    }
  }
  return users;
}
 
开发者ID:monitorjbl,项目名称:pr-harmony,代码行数:14,代码来源:UserUtils.java


示例10: mockParticipant

import com.atlassian.bitbucket.user.ApplicationUser; //导入依赖的package包/类
public static PullRequestParticipant mockParticipant(String name, boolean approved) {
  PullRequestParticipant p = mock(PullRequestParticipant.class);
  ApplicationUser user = mockApplicationUser(name);
  when(p.getUser()).thenReturn(user);
  when(p.isApproved()).thenReturn(approved);
  return p;
}
 
开发者ID:monitorjbl,项目名称:pr-harmony,代码行数:8,代码来源:TestUtils.java


示例11: setup

import com.atlassian.bitbucket.user.ApplicationUser; //导入依赖的package包/类
@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
  MockitoAnnotations.initMocks(this);
  ApplicationUser userA = mockApplicationUser("userA");
  ApplicationUser userB = mockApplicationUser("userB");
  ApplicationUser user1 = mockApplicationUser("user1");
  ApplicationUser user2 = mockApplicationUser("user2");
  ApplicationUser user3 = mockApplicationUser("user3");
  ApplicationUser user4 = mockApplicationUser("user4");
  List<ApplicationUser> userList1 = newArrayList(user1, user2);
  List<ApplicationUser> userList2 = newArrayList(user3, user4);

  Page p1 = mock(Page.class);
  Page p2 = mock(Page.class);
  Page empty = mock(Page.class);
  when(p1.getValues()).thenReturn(userList1);
  when(p2.getValues()).thenReturn(userList2);
  when(empty.getValues()).thenReturn(emptyList());
  when(userService.findUsersByGroup(any(String.class), any(PageRequest.class))).then((Answer<Page>) invocation -> {
    String group = (String) invocation.getArguments()[0];
    PageRequest pageRequest = (PageRequest) invocation.getArguments()[1];

    if("group1".equals(group) && pageRequest.getStart() == 0) {
      return p1;
    } else if("group2".equals(group) && pageRequest.getStart() == 0) {
      return p2;
    } else {
      return empty;
    }
  });

  when(userService.getUserBySlug("userA")).thenReturn(userA);
  when(userService.getUserBySlug("userB")).thenReturn(userB);
  when(userService.getUserBySlug("user1")).thenReturn(user1);
  when(userService.getUserBySlug("user2")).thenReturn(user2);
  when(userService.getUserBySlug("user3")).thenReturn(user3);
  when(userService.getUserBySlug("user4")).thenReturn(user4);
}
 
开发者ID:monitorjbl,项目名称:pr-harmony,代码行数:40,代码来源:UserUtilsTest.java


示例12: findSingleUserKey

import com.atlassian.bitbucket.user.ApplicationUser; //导入依赖的package包/类
@Override
public SshKeyEntity findSingleUserKey(ApplicationUser user) {
    SshKeyEntity[] keys = ao.find(SshKeyEntity.class, Query.select().where("USERID = ? AND TYPE = ?", user.getId(), KeyType.USER));
    if( null != keys && keys.length == 1 ){
        SshKeyEntity key = keys[0];
        return key;
    }else{
        return null;
    }
}
 
开发者ID:libertymutual,项目名称:ssh-key-enforcer-stash,代码行数:11,代码来源:EnterpriseKeyRepositoryImpl.java


示例13: from

import com.atlassian.bitbucket.user.ApplicationUser; //导入依赖的package包/类
public static KeyDetailsResourceModel from(SshKeyEntity keyEntity,ApplicationUser user){
    KeyDetailsResourceModel result = new KeyDetailsResourceModel();
    result.keyType = keyEntity.getKeyType();
    result.publicKey = keyEntity.getText();
    result.label = keyEntity.getLabel();
    result.user = new UserDetails(user);
    result.stashKeyId = keyEntity.getKeyId();
    result.created = keyEntity.getCreatedDate();
    return result;
}
 
开发者ID:libertymutual,项目名称:ssh-key-enforcer-stash,代码行数:11,代码来源:KeyDetailsResourceModel.java


示例14: generateNewPair

import com.atlassian.bitbucket.user.ApplicationUser; //导入依赖的package包/类
/**
 * Generate a new Key for this user per rules of service (1 active key, etc)
 */
@POST
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response generateNewPair() {

    ApplicationUser user = stashAuthenticationContext.getCurrentUser();
    KeyPairResourceModel keyPair;
    try {
        keyPair = enterpriseKeyService.generateNewKeyPairFor(user);
    } catch (EnterpriseKeyGenerationException e) {
        return Response.serverError().build();
    }

    return Response.ok(keyPair).build();
}
 
开发者ID:libertymutual,项目名称:ssh-key-enforcer-stash,代码行数:18,代码来源:KeyDetailsResource.java


示例15: removeKeyIfNotLegal

import com.atlassian.bitbucket.user.ApplicationUser; //导入依赖的package包/类
@Override
public void removeKeyIfNotLegal(SshKey key, ApplicationUser user) {
    log.debug(">>>removeKeyIfNotLegal");
    if ( pluginIsAwareOf(user,key) ||  addAllowedBypass(key,user)) {
        log.debug("No action required, valid key.");
    }else{
        sshKeyService.remove(key.getId());
        log.info("Invalid or illegal key removed for user {} ({})", user.getId(), user.getSlug());
        // TODO issue custom audit event
    }
    log.debug("<<<removeKeyIfNotLegal");
}
 
开发者ID:libertymutual,项目名称:ssh-key-enforcer-stash,代码行数:13,代码来源:EnterpriseSshKeyServiceImpl.java


示例16: generateNewKeyPairFor

import com.atlassian.bitbucket.user.ApplicationUser; //导入依赖的package包/类
@Override
public KeyPairResourceModel generateNewKeyPairFor(ApplicationUser user) {
    //purge old key for this user
    removeExistingUserKeysFor(user);
    //create new one
    String keyComment = "SYSTEM GENERATED";
    KeyPairResourceModel result = sshKeyPairGenerator.generateKeyPair(keyComment);
    // must add to our repo before calling stash SSH service since audit
    // listener will otherwise revoke it.
    SshKeyEntity newRecord = enterpriseKeyRepository.createOrUpdateUserKey(user, result.getPublicKey(), keyComment);
    SshKey newKey = sshKeyService.addForUser(user, result.getPublicKey());
    enterpriseKeyRepository.updateRecordWithKeyId(newRecord, newKey);
    log.info("New managed key " + newKey.getId() +" of type USER created user {} ({})", user.getId(), user.getSlug());
    return result;
}
 
开发者ID:libertymutual,项目名称:ssh-key-enforcer-stash,代码行数:16,代码来源:EnterpriseSshKeyServiceImpl.java


示例17: removeExistingUserKeysFor

import com.atlassian.bitbucket.user.ApplicationUser; //导入依赖的package包/类
private void removeExistingUserKeysFor(ApplicationUser user) {
    List<SshKeyEntity> allKeys = enterpriseKeyRepository.keysForUser(user);
    for(SshKeyEntity key: allKeys){
        if(key.getKeyType() == KeyType.USER){
            //this call fires an event that #forgetDeletedKey() will handle
            sshKeyService.remove(key.getKeyId());
        }
    }
}
 
开发者ID:libertymutual,项目名称:ssh-key-enforcer-stash,代码行数:10,代码来源:EnterpriseSshKeyServiceImpl.java


示例18: aKeyCanBeSaved

import com.atlassian.bitbucket.user.ApplicationUser; //导入依赖的package包/类
@Test
@NonTransactional
public void aKeyCanBeSaved() {
    ApplicationUser user = mock(ApplicationUser.class);
    when(user.getId()).thenReturn(ADHOC_USER_ID);
    String comment = "No Comment123";

    keyRepo.createOrUpdateUserKey(user, PUBLIC_KEY_ONE, comment);

    SshKeyEntity[] createdRecords = ao.find(SshKeyEntity.class, Query.select().where("USERID = ?", ADHOC_USER_ID));
    assertThat(createdRecords.length, is(1));
    assertThat(createdRecords[0].getLabel(), is(comment));
    assertThat(createdRecords[0].getText(), is(PUBLIC_KEY_ONE));
}
 
开发者ID:libertymutual,项目名称:ssh-key-enforcer-stash,代码行数:15,代码来源:EnterpriseSshKeyRepositoryTest.java


示例19: setup

import com.atlassian.bitbucket.user.ApplicationUser; //导入依赖的package包/类
@Before
public void setup(){
    sshKey = mock(SshKeyEntity.class);
    when(sshKey.getCreatedDate()).thenReturn(STATIC_DATE);
    user = mock(ApplicationUser.class);
    when(user.getId()).thenReturn(USER_ID);
    when(user.getSlug()).thenReturn(USERNAME);
}
 
开发者ID:libertymutual,项目名称:ssh-key-enforcer-stash,代码行数:9,代码来源:KeyDetailsResourceModelTest.java


示例20: createActor

import com.atlassian.bitbucket.user.ApplicationUser; //导入依赖的package包/类
public static BitbucketServerRepositoryOwner createActor(ApplicationUser user)
{
    return new BitbucketServerRepositoryOwner(user.getName(), user.getDisplayName());
}
 
开发者ID:Eernie,项目名称:bitbucket-webhooks-plugin,代码行数:5,代码来源:Models.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GelfMessage类代码示例发布时间:2022-05-23
下一篇:
Java CloseResourceAction类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap