org.apereo.cas.authentication.principal.Principal.getId()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中org.apereo.cas.authentication.principal.Principal.getId()方法的一些代码示例,展示了Principal.getId()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Principal.getId()方法的具体详情如下:
包路径:org.apereo.cas.authentication.principal.Principal
类名称:Principal
方法名:getId

Principal.getId介绍

暂无

代码示例

代码示例来源:origin: org.apereo.cas/cas-server-support-spnego

@Override
  public String getId() {
    return this.principal != null ? this.principal.getId() : UNKNOWN_ID;
  }
}

代码示例来源:origin: org.apereo.cas/cas-server-support-surrogate-authentication

@Override
public String getId() {
  return surrogate.getId();
}

代码示例来源:origin: org.apereo.cas/cas-server-core-services-api

@Override
  public String resolveUsernameInternal(final Principal principal, final Service service, final RegisteredService registeredService) {
    LOGGER.debug("Returning the default principal id [{}] for username.", principal.getId());
    return principal.getId();
  }
}

代码示例来源:origin: org.apereo.cas/cas-server-support-trusted

@JsonIgnore
  @Override
  public String getId() {
    return this.principal.getId();
  }
}

代码示例来源:origin: org.apereo.cas/cas-server-support-surrogate-authentication

@Override
public boolean canAuthenticateAsInternal(final String surrogate, final Principal principal, final Service service) {
  if (this.eligibleAccounts.containsKey(principal.getId())) {
    val surrogates = this.eligibleAccounts.get(principal.getId());
    LOGGER.debug("Surrogate accounts authorized for [{}] are [{}]", principal.getId(), surrogates);
    return surrogates.contains(surrogate);
  }
  LOGGER.warn("[{}] is not eligible to authenticate as [{}]", principal.getId(), surrogate);
  return false;
}

代码示例来源:origin: org.apereo.cas/cas-server-core-authentication-attributes

@Override
protected Map<String, Object> getPrincipalAttributes(final Principal p) {
  try {
    return this.cache.get(p.getId(), s -> {
      LOGGER.debug("No cached attributes could be found for [{}]", p.getId());
      return new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    });
  } catch (final Exception e) {
    LOGGER.error(e.getMessage(), e);
  }
  return new HashMap<>(0);
}

代码示例来源:origin: org.apereo.cas/cas-server-support-duo-core-mfa

@Override
  public String getId() {
    return this.authentication.getPrincipal().getId();
  }
}

代码示例来源:origin: org.apereo.cas/cas-server-support-spnego

@Override
protected String extractPrincipalId(final Credential credential, final Optional<Principal> currentPrincipal) {
  val c = (SpnegoCredential) credential;
  return c.getPrincipal().getId();
}

代码示例来源:origin: org.apereo.cas/cas-server-support-trusted

@Override
protected String extractPrincipalId(final Credential credential, final Optional<Principal> currentPrincipal) {
  return ((PrincipalBearingCredential) credential).getPrincipal().getId();
}

代码示例来源:origin: org.apereo.cas/cas-server-support-aup-core

@Override
public Pair<Boolean, Principal> verify(final RequestContext requestContext, final Credential credential) {
  @NonNull
  val principal = WebUtils.getAuthentication(requestContext).getPrincipal();
  if (isUsagePolicyAcceptedBy(principal)) {
    LOGGER.debug("Usage policy has been accepted by [{}]", principal.getId());
    return Pair.of(Boolean.TRUE, principal);
  }
  LOGGER.warn("Usage policy has not been accepted by [{}]", principal.getId());
  return Pair.of(Boolean.FALSE, principal);
}

代码示例来源:origin: org.apereo.cas/cas-server-core-authentication-api

private boolean isSamePrincipalId(final Ticket t, final Principal p) {
    return FunctionUtils.doIf(TicketGrantingTicket.class.isInstance(t) && !t.isExpired(),
      () -> {
        val principal = TicketGrantingTicket.class.cast(t).getAuthentication().getPrincipal();
        return principal.getId().equalsIgnoreCase(p.getId());
      },
      () -> Boolean.TRUE).get();
  }
}

代码示例来源:origin: org.apereo.cas/cas-server-core-services-api

@Override
public String resolveUsernameInternal(final Principal principal, final Service service, final RegisteredService registeredService) {
  val matcherInline = ScriptingUtils.getMatcherForInlineGroovyScript(this.groovyScript);
  val matcherFile = ScriptingUtils.getMatcherForExternalGroovyScript(this.groovyScript);
  if (matcherInline.find()) {
    return resolveUsernameFromInlineGroovyScript(principal, service, matcherInline.group(1));
  }
  if (matcherFile.find()) {
    return resolveUsernameFromExternalGroovyScript(principal, service, matcherFile.group(1));
  }
  LOGGER.warn("Groovy script [{}] is not valid. CAS will switch to use the default principal identifier [{}]", this.groovyScript, principal.getId());
  return principal.getId();
}

代码示例来源:origin: org.apereo.cas/cas-server-support-consent-core

@Override
public ConsentDecision findConsentDecision(final Service service, final RegisteredService registeredService,
                      final Authentication authentication) {
  return this.consentDecisions.stream()
    .filter(d -> d.getPrincipal().equals(authentication.getPrincipal().getId())
      && d.getService().equals(service.getId()))
    .findFirst()
    .orElse(null);
}

代码示例来源:origin: org.apereo.cas/cas-server-core-authentication-attributes

/**
 * Convert attributes to principal attributes and cache.
 *
 * @param p                the p
 * @param sourceAttributes the source attributes
 * @return the map
 */
private Map<String, Object> convertAttributesToPrincipalAttributesAndCache(final Principal p, final Map<String, List<Object>> sourceAttributes) {
  val finalAttributes = convertPersonAttributesToPrincipalAttributes(sourceAttributes);
  addPrincipalAttributes(p.getId(), finalAttributes);
  return finalAttributes;
}

代码示例来源:origin: org.apereo.cas/cas-server-core-authentication-api

@Override
public Principal nominate(final Collection<Authentication> authentications,
             final Map<String, Object> principalAttributes) {
  val principal = getPrincipalFromAuthentication(authentications);
  val attributes = getPrincipalAttributesForPrincipal(principal, principalAttributes);
  val finalPrincipal = principalFactory.createPrincipal(principal.getId(), attributes);
  LOGGER.debug("Nominated [{}] as the primary principal", finalPrincipal);
  return finalPrincipal;
}

代码示例来源:origin: org.apereo.cas/cas-server-support-validation

private CasJsonServiceResponseAuthenticationSuccess createAuthenticationSuccess(final Map<String, Object> model) {
  val success = new CasJsonServiceResponseAuthenticationSuccess();
  success.setAttributes(getModelAttributes(model));
  val principal = getPrincipal(model);
  success.setUser(principal.getId());
  success.setProxyGrantingTicket(getProxyGrantingTicketIou(model));
  val chainedAuthentications = getChainedAuthentications(model);
  if (chainedAuthentications != null && !chainedAuthentications.isEmpty()) {
    val proxies = chainedAuthentications.stream().map(authn -> authn.getPrincipal().getId()).collect(Collectors.toList());
    success.setProxies(proxies);
  }
  return success;
}

代码示例来源:origin: org.apereo.cas/cas-server-core-services-api

private static Object getGroovyAttributeValue(final Principal principal, final String script) {
  val args = CollectionUtils.wrap("attributes", principal.getAttributes(), "id", principal.getId(), "logger", LOGGER);
  return ScriptingUtils.executeGroovyShellScript(script, (Map) args, Object.class);
}

代码示例来源:origin: org.apereo.cas/cas-server-support-yubikey-core

@Override
  protected Event doExecute(final RequestContext requestContext) {
    val uid = WebUtils.getAuthentication(requestContext).getPrincipal().getId();
    val request = WebUtils.getHttpServletRequestFromExternalWebflowContext(requestContext);
    val token = request.getParameter("token");
    if (StringUtils.isNotBlank(token) && registry.registerAccountFor(uid, token)) {
      return success();
    }
    return error();
  }
}

代码示例来源:origin: org.apereo.cas/cas-server-support-yubikey-core

@Override
  protected Event doExecute(final RequestContext requestContext) {
    @NonNull
    val authentication = WebUtils.getAuthentication(requestContext);

    val uid = authentication.getPrincipal().getId();
    if (registry.isYubiKeyRegisteredFor(uid)) {
      return success();
    }
    return new EventFactorySupport().event(this, "register");
  }
}

代码示例来源:origin: org.apereo.cas/cas-server-support-otp-mfa-core

@Override
  protected Event doExecute(final RequestContext requestContext) {
    val account = requestContext.getFlowScope().get("key", OneTimeTokenAccount.class);

    val uid = WebUtils.getAuthentication(requestContext).getPrincipal().getId();
    repository.save(uid, account.getSecretKey(), account.getValidationCode(), account.getScratchCodes());
    return success();
  }
}

相关文章