本文整理了Java中org.apereo.cas.authentication.Authentication.getPrincipal()
方法的一些代码示例,展示了Authentication.getPrincipal()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Authentication.getPrincipal()
方法的具体详情如下:
包路径:org.apereo.cas.authentication.Authentication
类名称:Authentication
方法名:getPrincipal
暂无
代码示例来源:origin: org.apereo.cas/cas-server-core-authentication-mfa-api
/**
* Gets principal attributes for multifactor authentication.
*
* @param authentication the authentication
* @return the principal attributes for multifactor authentication
*/
protected Principal getPrincipalForMultifactorAuthentication(final Authentication authentication) {
return authentication.getPrincipal();
}
代码示例来源:origin: org.apereo.cas/cas-server-core-authentication-api
/**
* Gets principal from authentication.
*
* @param authentications the authentications
* @return the principal from authentication
*/
protected Principal getPrincipalFromAuthentication(final Collection<Authentication> authentications) {
return authentications.iterator().next().getPrincipal();
}
}
代码示例来源:origin: org.apereo.cas/cas-server-core
private static Authentication evaluatePossibilityOfMixedPrincipals(final AuthenticationResult context, final TicketGrantingTicket ticketGrantingTicket) {
if (context == null) {
return null;
}
val currentAuthentication = context.getAuthentication();
if (currentAuthentication != null) {
val original = ticketGrantingTicket.getAuthentication();
if (!currentAuthentication.getPrincipal().equals(original.getPrincipal())) {
throw new MixedPrincipalException(currentAuthentication, currentAuthentication.getPrincipal(), original.getPrincipal());
}
}
return currentAuthentication;
}
}
代码示例来源:origin: org.apereo.cas/cas-server-core-web-api
/**
* Gets the principal from the model.
*
* @param model the model
* @return the assertion from
* @since 4.1.0
*/
protected Principal getPrincipal(final Map<String, Object> model) {
return getPrimaryAuthenticationFrom(model).getPrincipal();
}
代码示例来源: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-core-tickets-api
@Override
public Principal getAuthenticatedPrincipalFrom(final String ticketGrantingTicketId) throws RuntimeException {
val auth = getAuthenticationFrom(ticketGrantingTicketId);
return auth == null ? null : auth.getPrincipal();
}
代码示例来源:origin: org.apereo.cas/cas-server-core-authentication-api
private Optional<Exception> getScriptExecutionResult(final Authentication auth, final Matcher matcherInline) {
if (matcherInline.find()) {
val args = CollectionUtils.wrap("principal", auth.getPrincipal(), "logger", LOGGER);
val inlineScript = matcherInline.group(1);
return ScriptingUtils.executeGroovyShellScript(inlineScript, args, Optional.class);
}
val res = this.resourceLoader.getResource(script);
final Object[] args = {auth.getPrincipal(), LOGGER};
return ScriptingUtils.executeGroovyScript(res, args, Optional.class, true);
}
}
代码示例来源:origin: org.apereo.cas/cas-server-support-consent-core
@Override
public Map<String, Object> resolveConsentableAttributesFrom(final Authentication authentication,
final Service service,
final RegisteredService registeredService) {
LOGGER.debug("Retrieving consentable attributes for [{}]", registeredService);
val policy = registeredService.getAttributeReleasePolicy();
if (policy != null) {
return policy.getConsentableAttributes(authentication.getPrincipal(), service, registeredService);
}
return new LinkedHashMap<>();
}
}
代码示例来源: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-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-support-interrupt-core
@Override
public InterruptResponse inquireInternal(final Authentication authentication, final RegisteredService registeredService,
final Service service, final Credential credential,
final RequestContext requestContext) {
val user = authentication.getPrincipal().getId();
readResourceForInterrupts();
if (interrupts.containsKey(user)) {
return interrupts.get(user);
}
return InterruptResponse.none();
}
代码示例来源:origin: org.apereo.cas/cas-server-core-authentication-mfa-api
@Override
public Set<Event> resolveEventViaAuthenticationAttribute(final Authentication authentication,
final Collection<String> attributeNames,
final RegisteredService service,
final Optional<RequestContext> context,
final Collection<MultifactorAuthenticationProvider> providers,
final Predicate<String> predicate) {
return resolveEventViaAttribute(authentication.getPrincipal(), authentication.getAttributes(),
attributeNames, service, context, providers, predicate);
}
代码示例来源: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-support-openid
/**
* Determine identity.
*
* @param service the service
* @param assertion the assertion
* @return the string
*/
protected String determineIdentity(final OpenIdService service, final Assertion assertion) {
if (assertion != null && OpenIdProtocolConstants.OPENID_IDENTIFIERSELECT.equals(service.getIdentity())) {
return this.openIdPrefixUrl + '/' + assertion.getPrimaryAuthentication().getPrincipal().getId();
}
return service.getIdentity();
}
代码示例来源: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-core-webflow-mfa-api
@Override
public Set<Event> resolveInternal(final RequestContext context) {
val registeredService = resolveRegisteredServiceInRequestContext(context);
val service = resolveServiceFromAuthenticationRequest(context);
val authentication = WebUtils.getAuthentication(context);
val request = WebUtils.getHttpServletRequestFromExternalWebflowContext(context);
val result = multifactorAuthenticationTrigger.isActivated(authentication, registeredService, request, service);
return result.map(provider -> {
LOGGER.trace("Attempting to build an event based on the authentication provider [{}] and service [{}]", provider, registeredService);
val event = MultifactorAuthenticationUtils.validateEventIdForMatchingTransitionInContext(provider.getId(), Optional.of(context),
MultifactorAuthenticationUtils.buildEventAttributeMap(authentication.getPrincipal(), Optional.ofNullable(registeredService), provider));
return CollectionUtils.wrapSet(event);
}).orElse(null);
}
代码示例来源: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-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-openid
@Override
public AuthenticationHandlerExecutionResult authenticate(final Credential credential) throws GeneralSecurityException {
val c = (OpenIdCredential) credential;
val t = this.ticketRegistry.getTicket(c.getTicketGrantingTicketId(), TicketGrantingTicket.class);
if (t == null || t.isExpired()) {
throw new FailedLoginException("Ticket-granting ticket is null or expired.");
}
val principal = t.getAuthentication().getPrincipal();
if (!principal.getId().equals(c.getUsername())) {
throw new FailedLoginException("Principal ID mismatch");
}
return new DefaultAuthenticationHandlerExecutionResult(this, new BasicCredentialMetaData(c), principal);
}
代码示例来源: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();
}
}
内容来源于网络,如有侵权,请联系作者删除!