本文整理了Java中org.apereo.cas.authentication.principal.Principal
类的一些代码示例,展示了Principal
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Principal
类的具体详情如下:
包路径:org.apereo.cas.authentication.principal.Principal
类名称:Principal
暂无
代码示例来源: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-core-services-api
@Override
protected String resolveUsernameInternal(final Principal principal, final Service service, final RegisteredService registeredService) {
try {
LOGGER.debug("Found groovy script to execute");
val result = ScriptingUtils.executeScriptEngine(this.script, new Object[]{principal.getAttributes(), principal.getId(), LOGGER}, Object.class);
if (result != null) {
LOGGER.debug("Found username [{}] from script [{}]", result, this.script);
return result.toString();
}
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
LOGGER.warn("Script [{}] returned no value for username attribute. Fallback to default [{}]", this.script, principal.getId());
return principal.getId();
}
代码示例来源:origin: org.apereo.cas/cas-server-support-surrogate-authentication
@Override
protected Map<String, Object> getPrincipalAttributesForPrincipal(final Principal principal, final Map<String, Object> principalAttributes) {
return principal.getAttributes();
}
}
代码示例来源:origin: org.apereo.cas/cas-server-support-surrogate-authentication
@Override
public Map<String, Object> getAttributes() {
return surrogate.getAttributes();
}
代码示例来源:origin: org.apereo.cas/cas-server-support-surrogate-authentication
@Override
public String getId() {
return surrogate.getId();
}
代码示例来源:origin: org.apereo.cas/cas-server-support-actions-aup-webflow
@Override
public Pair<Boolean, Principal> verify(final RequestContext requestContext, final Credential credential) {
final Principal principal = WebUtils.getPrincipalFromRequestContext(requestContext, this.ticketRegistrySupport);
final Map<String, Object> attributes = principal.getAttributes();
LOGGER.debug("Principal attributes found for [{}] are [{}]", principal.getId(), attributes);
if (attributes != null && attributes.containsKey(this.aupAttributeName)) {
final Object value = attributes.get(this.aupAttributeName);
LOGGER.debug("Evaluating attribute value [{}] found for [{}]", value, this.aupAttributeName);
if (value.toString().equalsIgnoreCase(Boolean.TRUE.toString())) {
return Pair.of(true, principal);
}
}
LOGGER.warn("Usage policy has not been accepted by [{}]", principal.getId());
return Pair.of(false, principal);
}
代码示例来源:origin: org.apereo.cas/cas-server-core-authentication-attributes
@Override
protected Map<String, Object> getPrincipalAttributes(final Principal p) {
val attributes = p.getAttributes();
LOGGER.debug("[{}] will return the collection of attributes directly associated with the principal object which are [{}]",
this.getClass().getSimpleName(), attributes);
return attributes;
}
代码示例来源: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-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-core-util-api
private static Optional<Object> getFirstAttributeByName(final Principal principal, final String attribute) {
val value = principal.getAttributes().get(attribute);
return CollectionUtils.firstElement(value);
}
代码示例来源:origin: org.apereo.cas/cas-server-support-trusted
@JsonIgnore
@Override
public String getId() {
return this.principal.getId();
}
}
代码示例来源:origin: org.apereo.cas/cas-server-support-aup-core
/**
* Is usage policy accepted by user?
* Looks into the attributes collected by the principal to find {@link #aupAttributeName}.
* If the attribute contains {@code true}, then the policy is determined as accepted.
*
* @param principal the principal
* @return true if accepted, false otherwise.
*/
protected boolean isUsagePolicyAcceptedBy(final Principal principal) {
val attributes = principal.getAttributes();
LOGGER.debug("Principal attributes found for [{}] are [{}]", principal.getId(), attributes);
if (attributes != null && attributes.containsKey(this.aupAttributeName)) {
val value = CollectionUtils.toCollection(attributes.get(this.aupAttributeName));
LOGGER.debug("Evaluating attribute value [{}] found for [{}]", value, this.aupAttributeName);
return value.stream().anyMatch(v -> v.toString().equalsIgnoreCase(Boolean.TRUE.toString()));
}
return false;
}
}
代码示例来源:origin: org.apereo.cas/cas-server-core-tickets-api
@Override
public Map<String, Object> getPrincipalAttributesFrom(final String ticketGrantingTicketId) throws RuntimeException {
val principal = getAuthenticatedPrincipalFrom(ticketGrantingTicketId);
return principal == null ? null : principal.getAttributes();
}
代码示例来源: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-services-api
@Override
public String generate(final Principal principal, final Service service) {
val attributes = principal.getAttributes();
LOGGER.debug("Found principal attributes [{}] to use when generating persistent identifiers", attributes);
val principalId = FunctionUtils.doIf(
StringUtils.isNotBlank(this.attribute) && attributes.containsKey(this.attribute),
() -> {
val attributeValue = attributes.get(this.attribute);
LOGGER.debug("Using attribute [{}] to establish principal id", this.attribute);
return CollectionUtils.firstElement(attributeValue).get().toString();
},
() -> {
LOGGER.debug("Using principal id [{}] to generate persistent identifier", principal.getId());
return principal.getId();
}
).get();
return generate(principalId, service != null ? service.getId() : null);
}
代码示例来源:origin: org.apereo.cas/cas-server-core-authentication-attributes
/***
* Convert principal attributes to person attributes.
* @param p the principal carrying attributes
* @return person attributes
*/
private static Map<String, List<Object>> convertPrincipalAttributesToPersonAttributes(final Principal p) {
val convertedAttributes = new TreeMap<String, List<Object>>(String.CASE_INSENSITIVE_ORDER);
val principalAttributes = p.getAttributes();
principalAttributes.forEach((key, values) -> {
if (values instanceof List) {
convertedAttributes.put(key, (List) values);
} else {
convertedAttributes.put(key, CollectionUtils.wrap(values));
}
});
return convertedAttributes;
}
代码示例来源: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-reports
/**
* Resolve principal attributes map.
*
* @param uid the uid
* @return the map
*/
@ReadOperation
public Map<String, Object> resolvePrincipalAttributes(@Selector final String uid) {
val p = defaultPrincipalResolver.resolve(new BasicIdentifiableCredential(uid));
val map = new HashMap<String, Object>();
map.put("uid", p.getId());
map.put("attributes", p.getAttributes());
return map;
}
}
代码示例来源:origin: org.apereo.cas/cas-server-core-authentication-mfa-api
@Override
public Set<Event> resolveEventViaPrincipalAttribute(final Principal principal,
final Collection<String> attributeNames,
final RegisteredService service,
final Optional<RequestContext> context,
final Collection<MultifactorAuthenticationProvider> providers,
final Predicate<String> predicate) {
if (attributeNames.isEmpty()) {
LOGGER.debug("No attribute names are provided to trigger a multifactor authentication provider via [{}]", getName());
return null;
}
if (providers == null || providers.isEmpty()) {
LOGGER.error("No multifactor authentication providers are available in the application context");
return null;
}
val attributes = principal.getAttributes();
return resolveEventViaAttribute(principal, attributes, attributeNames, service, context, providers, predicate);
}
}
代码示例来源:origin: org.apereo.cas/cas-server-core-services-api
private String resolveUsernameFromInlineGroovyScript(final Principal principal, final Service service, final String script) {
try {
LOGGER.debug("Found groovy script to execute [{}]", this.groovyScript);
val result = getGroovyAttributeValue(principal, script);
if (result != null) {
LOGGER.debug("Found username [{}] from script [{}]", result, this.groovyScript);
return result.toString();
}
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
LOGGER.warn("Groovy script [{}] returned no value for username attribute. Fallback to default [{}]", this.groovyScript, principal.getId());
return principal.getId();
}
内容来源于网络,如有侵权,请联系作者删除!