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


Java SecurityRealm类代码示例

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


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

示例1: validAnonymousViewStatusAccess

import hudson.security.SecurityRealm; //导入依赖的package包/类
/**
 *
 * @throws Exception
 */
@Test
public void validAnonymousViewStatusAccess() throws Exception {

    final SecurityRealm realm = j.createDummySecurityRealm();
    j.jenkins.setSecurityRealm(realm);
    GlobalMatrixAuthorizationStrategy auth = new GlobalMatrixAuthorizationStrategy();
    auth.add(VIEW_STATUS, "anonymous");
    j.getInstance().setSecurityRealm(realm);
    j.getInstance().setAuthorizationStrategy(auth);

    final FreeStyleProject project = j.createFreeStyleProject("free");

    JenkinsRule.WebClient wc = j.createWebClient();
    try {
        // try with wrong job name
        wc.goTo("buildStatus/buildIcon?job=dummy");
        fail("should fail, because there is no job with this name");
    } catch (FailingHttpStatusCodeException x) {
        assertEquals(HTTP_NOT_FOUND, x.getStatusCode());
    }

    wc.goTo("buildStatus/buildIcon?job=free", "image/svg+xml");
    j.buildAndAssertSuccess(project);
   
}
 
开发者ID:SxMShaDoW,项目名称:embeddable-badges-plugin,代码行数:30,代码来源:PublicBadgeActionTest.java

示例2: doImpersonate

import hudson.security.SecurityRealm; //导入依赖的package包/类
@RequirePOST
public HttpResponse doImpersonate(StaplerRequest req, @QueryParameter String name) {
    Authentication auth = Jenkins.getAuthentication();
    GrantedAuthority[] authorities = auth.getAuthorities();
    if (authorities == null || StringUtils.isBlank(name)) {
        return HttpResponses.redirectToContextRoot();
    }
    GrantedAuthority authority = null;
    for (GrantedAuthority a : authorities) {
        if (a.getAuthority().equals(name)) {
            authority = a;
            break;
        }
    }
    if (authority == null) {
        return HttpResponses.redirectToContextRoot();
    }
    if (!SecurityRealm.AUTHENTICATED_AUTHORITY.equals(authority)) {
        ACL.impersonate(new ImpersonationAuthentication(auth, authority, SecurityRealm.AUTHENTICATED_AUTHORITY));
    } else {
        ACL.impersonate(new ImpersonationAuthentication(auth, SecurityRealm.AUTHENTICATED_AUTHORITY));
    }
    return HttpResponses.redirectToContextRoot();
}
 
开发者ID:jenkinsci,项目名称:impersonation-plugin,代码行数:25,代码来源:ImpersonationAction.java

示例3: createSecurityComponents

import hudson.security.SecurityRealm; //导入依赖的package包/类
@Override
public SecurityComponents createSecurityComponents() {
    return new SecurityRealm.SecurityComponents(new AuthenticationManager() {
        public Authentication authenticate(Authentication authentication) throws AuthenticationException {
            if (authentication instanceof DeepinAuthenticationToken) {
                return authentication;
            }

            throw new BadCredentialsException("Unexpected authentication type: " + authentication);
        }
    }, new UserDetailsService() {
        public UserDetails loadUserByUsername(String username)  throws UserMayOrMayNotExistException, DataAccessException {
            throw new UserMayOrMayNotExistException("Cannot verify users in this context");
        }
    });
}
 
开发者ID:Iceyer,项目名称:deepin-oauth-plugin,代码行数:17,代码来源:DeepinSecurityRealm.java

示例4: fromUsernameAndEmail

import hudson.security.SecurityRealm; //导入依赖的package包/类
public static AppsCodeUserDetails fromUsernameAndEmail(String username, String email) {
  return AppsCodeUserDetails.newBuilder()
      .setUsername(username)
      .setPassword("")
      .setEmail(email)
      .setEnabled(true)
      .setAccountNonExpired(true)
      .setCredentialsNonExpired(true)
      .setAccountNonLocked(true)
      .setAuthorities(new GrantedAuthority[]{SecurityRealm.AUTHENTICATED_AUTHORITY})
      .build();
}
 
开发者ID:appscode-ci,项目名称:appscode-login-plugin,代码行数:13,代码来源:AppsCodeUserDetails.java

示例5: fromUser

import hudson.security.SecurityRealm; //导入依赖的package包/类
@Test
public void fromUser() throws Exception {
  AppsCodeUserDetails expected1 = new AppsCodeUserDetails(testUserName, "", "[email protected]",
      true, true, true, true, new GrantedAuthority[]{SecurityRealm.AUTHENTICATED_AUTHORITY});
  AppsCodeUserDetails actual1 = AppsCodeUserDetails.fromUser("user1");
  assertEquals(expected1, actual1);

  AppsCodeUserDetails expected2 = new AppsCodeUserDetails(testUserName, "", "[email protected]",
      true, true, true, true, new GrantedAuthority[]{SecurityRealm.AUTHENTICATED_AUTHORITY});
  AppsCodeUserDetails actual2 = AppsCodeUserDetails.fromUser("hello");
  assertNotEquals(expected2, actual2);
}
 
开发者ID:appscode-ci,项目名称:appscode-login-plugin,代码行数:13,代码来源:AppsCodeUserDetailsTest.java

示例6: buildRoles

import hudson.security.SecurityRealm; //导入依赖的package包/类
private static GrantedAuthority[] buildRoles(AccessToken accessToken) {
	List<GrantedAuthority> roles;
	roles = new ArrayList<GrantedAuthority>();
	if (accessToken != null && accessToken.getRealmAccess() != null) {
		for (String role : accessToken.getRealmAccess().getRoles()) {
			roles.add(new GrantedAuthorityImpl(role));
		}
	}
	roles.add(SecurityRealm.AUTHENTICATED_AUTHORITY);
	return roles.toArray(new GrantedAuthority[roles.size()]);
}
 
开发者ID:devlauer,项目名称:jenkins-keycloak-plugin,代码行数:12,代码来源:KeycloakAuthentication.java

示例7: getSecurityRealm

import hudson.security.SecurityRealm; //导入依赖的package包/类
public final T getSecurityRealm() throws InvalidSecurityRealmException {
    final SecurityRealm securityRealm = JenkinsDescriptorImpl.getJenkinsInstanceOrDie().getSecurityRealm();
    if (isRegistrationForSecurityRealm(securityRealm)) {
        //noinspection unchecked
        return (T) JenkinsDescriptorImpl.getJenkinsInstanceOrDie().getSecurityRealm();
    } else {
        throw new InvalidSecurityRealmException();
    }
}
 
开发者ID:inFullMobile,项目名称:restricted-register-plugin,代码行数:10,代码来源:SecurityRealmRegistration.java

示例8: getSecurityRealmRegistration

import hudson.security.SecurityRealm; //导入依赖的package包/类
@Override
@Nonnull
public SecurityRealmRegistration getSecurityRealmRegistration() {
    final Jenkins jenkins = JenkinsDescriptorImpl.getJenkinsInstanceOrDie();
    final SecurityRealm realm = jenkins.getSecurityRealm();
    final List<SecurityRealmRegistration> allRegistrations = PluginModule.getDefault()
            .getExtensionsProvider().getSecurityRealmRegistrations();
    for (SecurityRealmRegistration instance : allRegistrations) {
        if (instance.isRegistrationForSecurityRealm(realm)) {
            return instance;
        }
    }
    return StubSecurityRealmRegistration.INSTANCE;
}
 
开发者ID:inFullMobile,项目名称:restricted-register-plugin,代码行数:15,代码来源:PluginDescriptorImpl.java

示例9: getRedmineManager

import hudson.security.SecurityRealm; //导入依赖的package包/类
/**
 * Return instance of {@link RedmineManager}
 * 
 * @return
 */
RedmineManager getRedmineManager() {
    SecurityRealm realm = Jenkins.getInstance().getSecurityRealm();
    if (!(realm instanceof RedmineSecurityRealm)) {
        LOGGER.error("Redmine manager not found");
        return null;
    }

    return ((RedmineSecurityRealm) realm).getManager();
}
 
开发者ID:cyrilix,项目名称:jenkins-redmine-realm,代码行数:15,代码来源:RedmineUserNameResolver.java

示例10: getGroups

import hudson.security.SecurityRealm; //导入依赖的package包/类
private GrantedAuthority[] getGroups(User user) {
    Set<GrantedAuthority> groups = new HashSet<GrantedAuthority>();
    for (Group group : user.getGroups()) {
        groups.add(new RedmineGroupDetails(group.getName()));
    }
    groups.add(SecurityRealm.AUTHENTICATED_AUTHORITY);
    return groups.toArray(new GrantedAuthority[groups.size()]);
}
 
开发者ID:cyrilix,项目名称:jenkins-redmine-realm,代码行数:9,代码来源:RedmineSecurityRealm.java

示例11: getDescriptor

import hudson.security.SecurityRealm; //导入依赖的package包/类
@Override
public Descriptor<SecurityRealm> getDescriptor() {
  return DESCRIPTOR;
}
 
开发者ID:appscode-ci,项目名称:appscode-login-plugin,代码行数:5,代码来源:AppsCodeSecurityRealm.java

示例12: newInstance

import hudson.security.SecurityRealm; //导入依赖的package包/类
@Override
public SecurityRealm newInstance(StaplerRequest req, JSONObject formData)
		throws hudson.model.Descriptor.FormException {
	return super.newInstance(req, formData);
}
 
开发者ID:devlauer,项目名称:jenkins-keycloak-plugin,代码行数:6,代码来源:KeycloakSecurityRealm.java

示例13: isRegistrationForSecurityRealm

import hudson.security.SecurityRealm; //导入依赖的package包/类
@Override
public boolean isRegistrationForSecurityRealm(SecurityRealm realm) {
    return HudsonPrivateSecurityRealm.class.isInstance(realm);
}
 
开发者ID:inFullMobile,项目名称:restricted-register-plugin,代码行数:5,代码来源:HudsonSecurityRealmRegistration.java

示例14: isRegistrationForSecurityRealm

import hudson.security.SecurityRealm; //导入依赖的package包/类
@Override
public boolean isRegistrationForSecurityRealm(SecurityRealm realm) {
    return false;
}
 
开发者ID:inFullMobile,项目名称:restricted-register-plugin,代码行数:5,代码来源:StubSecurityRealmRegistration.java

示例15: getSecurityRealm

import hudson.security.SecurityRealm; //导入依赖的package包/类
@Nullable
SecurityRealm getSecurityRealm();
 
开发者ID:inFullMobile,项目名称:restricted-register-plugin,代码行数:3,代码来源:IJenkinsDescriptor.java


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