Java Code Examples for org.jasig.cas.authentication.Credential#getId()

The following examples show how to use org.jasig.cas.authentication.Credential#getId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AcceptableUsagePolicyFormAction.java    From springboot-shiro-cas-mybatis with MIT License 5 votes vote down vote up
/**
 * Verify whether the policy is accepted.
 *
 * @param context the context
 * @param credential the credential
 * @param messageContext the message context
 * @return success if policy is accepted. {@link #EVENT_ID_MUST_ACCEPT} otherwise.
 */
public Event verify(final RequestContext context, final Credential credential,
                          final MessageContext messageContext)  {
    final String key = credential.getId();
    if (this.policyMap.containsKey(key)) {
        final Boolean hasAcceptedPolicy = this.policyMap.get(key);
        return hasAcceptedPolicy ? success() : accept();
    }
    return accept();
}
 
Example 2
Source File: AbstractMultiFactorAuthenticationViaFormAction.java    From cas-mfa with Apache License 2.0 5 votes vote down vote up
@Override
protected final Event doExecute(final RequestContext ctx) throws Exception {
    final Credential credentials = WebUtils.getCredential(ctx);
    final MessageContext messageContext = ctx.getMessageContext();


    if (credentials != null) {
        final String id = credentials.getId();
        return submit(ctx, credentials, messageContext, id);
    }
    logger.warn("Credentials could not be determined, or no username was associated with the request.");
    return getErrorEvent(ctx);
}
 
Example 3
Source File: GenerateMultiFactorCredentialsAction.java    From cas-mfa with Apache License 2.0 5 votes vote down vote up
@Override
protected Event doExecute(final RequestContext context) {
    final FlowSession session = context.getFlowExecutionContext().getActiveSession();
    LOGGER.debug("Authentication has entered the flow [{}] executing state [{}",
            context.getActiveFlow().getId(), session.getState().getId());
    final Credential creds = WebUtils.getCredential(context);
    final String id = creds != null ? creds.getId() : null;

    final Credential mfaCreds = createCredentials(context, creds, id);
    final AttributeMap map = new LocalAttributeMap(ATTRIBUTE_ID_MFA_CREDENTIALS, mfaCreds);
    return new Event(this, EVENT_ID_SUCCESS, map);
}
 
Example 4
Source File: BasicPrincipalResolver.java    From springboot-shiro-cas-mybatis with MIT License 4 votes vote down vote up
@Override
public boolean supports(final Credential credential) {
    return credential.getId() != null;
}
 
Example 5
Source File: BasicPrincipalResolver.java    From cas4.0.x-server-wechat with Apache License 2.0 4 votes vote down vote up
@Override
public Principal resolve(final Credential credential) {
    return new SimplePrincipal(credential.getId());
}
 
Example 6
Source File: BasicPrincipalResolver.java    From cas4.0.x-server-wechat with Apache License 2.0 4 votes vote down vote up
@Override
public boolean supports(final Credential credential) {
    return credential.getId() != null;
}
 
Example 7
Source File: PrincipalBearingCredentialsAuthenticationHandler.java    From cas4.0.x-server-wechat with Apache License 2.0 4 votes vote down vote up
@Override
public HandlerResult authenticate(final Credential credential) throws GeneralSecurityException {
    logger.debug("Trusting credential for: {}", credential);
    return new HandlerResult(
            this, (PrincipalBearingCredential) credential, new SimplePrincipal(credential.getId()));
}
 
Example 8
Source File: PersonDirectoryPrincipalResolver.java    From springboot-shiro-cas-mybatis with MIT License 2 votes vote down vote up
/**
 * Extracts the id of the user from the provided credential. This method should be overridded by subclasses to
 * achieve more sophisticated strategies for producing a principal ID from a credential.
 *
 * @param credential the credential provided by the user.
 * @return the username, or null if it could not be resolved.
 */
protected String extractPrincipalId(final Credential credential) {
    return credential.getId();
}
 
Example 9
Source File: PersonDirectoryPrincipalResolver.java    From cas4.0.x-server-wechat with Apache License 2.0 2 votes vote down vote up
/**
 * Extracts the id of the user from the provided credential. This method should be overridded by subclasses to
 * achieve more sophisticated strategies for producing a principal ID from a credential.
 *
 * @param credential the credential provided by the user.
 * @return the username, or null if it could not be resolved.
 */
protected String extractPrincipalId(final Credential credential) {
    return credential.getId();
}