本文整理汇总了Java中org.jasig.cas.authentication.RememberMeCredential类的典型用法代码示例。如果您正苦于以下问题:Java RememberMeCredential类的具体用法?Java RememberMeCredential怎么用?Java RememberMeCredential使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RememberMeCredential类属于org.jasig.cas.authentication包,在下文中一共展示了RememberMeCredential类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: prepareSamlAttributes
import org.jasig.cas.authentication.RememberMeCredential; //导入依赖的package包/类
/**
* Prepare saml attributes. Combines both principal and authentication
* attributes. If the authentication is to be remembered, uses {@link #setRememberMeAttributeName(String)}
* for the remember-me attribute name.
*
* @param model the model
* @return the final map
* @since 4.1.0
*/
private Map<String, Object> prepareSamlAttributes(final Map<String, Object> model, final Service service) {
final Map<String, Object> authnAttributes = new HashMap<>(getAuthenticationAttributesAsMultiValuedAttributes(model));
if (isRememberMeAuthentication(model)) {
authnAttributes.remove(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME);
authnAttributes.put(this.rememberMeAttributeName, Boolean.TRUE.toString());
}
final RegisteredService registeredService = this.servicesManager.findServiceBy(service);
final Map<String, Object> attributesToReturn = new HashMap<>();
attributesToReturn.putAll(getPrincipalAttributesAsMultiValuedAttributes(model));
attributesToReturn.putAll(authnAttributes);
decideIfCredentialPasswordShouldBeReleasedAsAttribute(attributesToReturn, model, registeredService);
decideIfProxyGrantingTicketShouldBeReleasedAsAttribute(attributesToReturn, model, registeredService);
final Map<String, Object> finalAttributes = this.casAttributeEncoder.encodeAttributes(attributesToReturn, service);
return finalAttributes;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:27,代码来源:Saml10SuccessResponseView.java
示例2: isExpired
import org.jasig.cas.authentication.RememberMeCredential; //导入依赖的package包/类
@Override
public boolean isExpired(final TicketState ticketState) {
if (this.rememberMeExpirationPolicy != null && this.sessionExpirationPolicy != null) {
final Boolean b = (Boolean) ticketState.getAuthentication().getAttributes().
get(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME);
if (b == null || b.equals(Boolean.FALSE)) {
LOGGER.debug("Ticket is not associated with a remember-me authentication. Invoking {}", sessionExpirationPolicy);
return this.sessionExpirationPolicy.isExpired(ticketState);
}
LOGGER.debug("Ticket is associated with a remember-me authentication. Invoking {}", rememberMeExpirationPolicy);
return this.rememberMeExpirationPolicy.isExpired(ticketState);
}
LOGGER.warn("No expiration policy settings are defined");
return false;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:19,代码来源:RememberMeDelegatingExpirationPolicy.java
示例3: addCookie
import org.jasig.cas.authentication.RememberMeCredential; //导入依赖的package包/类
/**
* Adds the cookie, taking into account {@link RememberMeCredential#REQUEST_PARAMETER_REMEMBER_ME}
* in the request.
*
* @param request the request
* @param response the response
* @param cookieValue the cookie value
*/
public void addCookie(final HttpServletRequest request, final HttpServletResponse response, final String cookieValue) {
final String theCookieValue = this.casCookieValueManager.buildCookieValue(cookieValue, request);
if (!StringUtils.hasText(request.getParameter(RememberMeCredential.REQUEST_PARAMETER_REMEMBER_ME))) {
super.addCookie(response, theCookieValue);
} else {
final Cookie cookie = createCookie(theCookieValue);
cookie.setMaxAge(this.rememberMeMaxAge);
if (isCookieSecure()) {
cookie.setSecure(true);
}
if (isCookieHttpOnly()) {
final Method setHttpOnlyMethod = ReflectionUtils.findMethod(Cookie.class, "setHttpOnly", boolean.class);
if(setHttpOnlyMethod != null) {
cookie.setHttpOnly(true);
} else {
logger.debug("Cookie cannot be marked as HttpOnly; container is not using servlet 3.0.");
}
}
response.addCookie(cookie);
}
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:31,代码来源:CookieRetrievingCookieGenerator.java
示例4: MockTicketGrantingTicket
import org.jasig.cas.authentication.RememberMeCredential; //导入依赖的package包/类
public MockTicketGrantingTicket(final String id, final Credential credential, final Map<String, Object> principalAttributes) {
this.id = id;
final CredentialMetaData credentialMetaData = new BasicCredentialMetaData(credential);
final DefaultAuthenticationBuilder builder = new DefaultAuthenticationBuilder();
builder.setPrincipal(this.principalFactory.createPrincipal(USERNAME, principalAttributes));
builder.setAuthenticationDate(new Date());
builder.addCredential(credentialMetaData);
builder.addAttribute(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME, Boolean.TRUE);
final AuthenticationHandler handler = new MockAuthenticationHandler();
try {
builder.addSuccess(handler.getName(), handler.authenticate(credential));
} catch (final Exception e) {
throw new RuntimeException(e);
}
builder.addFailure(handler.getName(), FailedLoginException.class);
this.authentication = builder.build();
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:18,代码来源:KryoTranscoderTests.java
示例5: prepareResponse
import org.jasig.cas.authentication.RememberMeCredential; //导入依赖的package包/类
@Override
protected void prepareResponse(final Response response, final Map<String, Object> model) {
final Authentication authentication = getAssertionFrom(model).getPrimaryAuthentication();
final DateTime issuedAt = response.getIssueInstant();
final Service service = getAssertionFrom(model).getService();
final Object o = authentication.getAttributes().get(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME);
final boolean isRemembered = o == Boolean.TRUE && !getAssertionFrom(model).isFromNewLogin();
// Build up the SAML assertion containing AuthenticationStatement and AttributeStatement
final Assertion assertion = newSamlObject(Assertion.class);
assertion.setID(generateId());
assertion.setIssueInstant(issuedAt);
assertion.setIssuer(this.issuer);
assertion.setConditions(newConditions(issuedAt, service.getId()));
final AuthenticationStatement authnStatement = newAuthenticationStatement(authentication);
assertion.getAuthenticationStatements().add(authnStatement);
final Map<String, Object> attributes = authentication.getPrincipal().getAttributes();
if (!attributes.isEmpty() || isRemembered) {
assertion.getAttributeStatements().add(
newAttributeStatement(newSubject(authentication.getPrincipal().getId()), attributes, isRemembered));
}
response.setStatus(newStatus(StatusCode.SUCCESS, null));
response.getAssertions().add(assertion);
}
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:26,代码来源:Saml10SuccessResponseView.java
示例6: MockTicketGrantingTicket
import org.jasig.cas.authentication.RememberMeCredential; //导入依赖的package包/类
MockTicketGrantingTicket(final String id, final Credential credential, final Map<String, Object> principalAttributes) {
this.id = id;
final CredentialMetaData credentialMetaData = new BasicCredentialMetaData(credential);
final AuthenticationBuilder builder = new DefaultAuthenticationBuilder();
builder.setPrincipal(this.principalFactory.createPrincipal(USERNAME, principalAttributes));
builder.setAuthenticationDate(new DateTime());
builder.addCredential(credentialMetaData);
builder.addAttribute(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME, Boolean.TRUE);
final AuthenticationHandler handler = new MockAuthenticationHandler();
try {
builder.addSuccess(handler.getName(), handler.authenticate(credential));
} catch (final Exception e) {
throw new RuntimeException(e);
}
builder.addFailure(handler.getName(), FailedLoginException.class);
this.authentication = builder.build();
}
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:18,代码来源:KryoTranscoderTests.java
示例7: prepareSamlAttributes
import org.jasig.cas.authentication.RememberMeCredential; //导入依赖的package包/类
/**
* Prepare saml attributes. Combines both principal and authentication
* attributes. If the authentication is to be remembered, uses {@link #setRememberMeAttributeName(String)}
* for the remember-me attribute name.
*
* @param model the model
* @param service the service
* @return the final map
* @since 4.1.0
*/
private Map<String, Object> prepareSamlAttributes(final Map<String, Object> model, final Service service) {
final Map<String, Object> authnAttributes = new HashMap<>(getAuthenticationAttributesAsMultiValuedAttributes(model));
if (isRememberMeAuthentication(model)) {
authnAttributes.remove(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME);
authnAttributes.put(this.rememberMeAttributeName, Boolean.TRUE.toString());
}
final RegisteredService registeredService = this.servicesManager.findServiceBy(service);
final Map<String, Object> attributesToReturn = new HashMap<>();
attributesToReturn.putAll(getPrincipalAttributesAsMultiValuedAttributes(model));
attributesToReturn.putAll(authnAttributes);
decideIfCredentialPasswordShouldBeReleasedAsAttribute(attributesToReturn, model, registeredService);
decideIfProxyGrantingTicketShouldBeReleasedAsAttribute(attributesToReturn, model, registeredService);
final Map<String, Object> finalAttributes = this.casAttributeEncoder.encodeAttributes(attributesToReturn, service);
return finalAttributes;
}
开发者ID:xuchengdong,项目名称:cas4.1.9,代码行数:30,代码来源:Saml10SuccessResponseView.java
示例8: MockTicketGrantingTicket
import org.jasig.cas.authentication.RememberMeCredential; //导入依赖的package包/类
MockTicketGrantingTicket(final String id, final Credential credential, final Map<String, Object> principalAttributes) {
this.id = id;
final CredentialMetaData credentialMetaData = new BasicCredentialMetaData(credential);
final DefaultAuthenticationBuilder builder = new DefaultAuthenticationBuilder();
builder.setPrincipal(this.principalFactory.createPrincipal(USERNAME, principalAttributes));
builder.setAuthenticationDate(new Date());
builder.addCredential(credentialMetaData);
builder.addAttribute(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME, Boolean.TRUE);
final AuthenticationHandler handler = new MockAuthenticationHandler();
try {
builder.addSuccess(handler.getName(), handler.authenticate(credential));
} catch (final Exception e) {
throw new RuntimeException(e);
}
builder.addFailure(handler.getName(), FailedLoginException.class);
this.authentication = builder.build();
}
开发者ID:xuchengdong,项目名称:cas4.1.9,代码行数:18,代码来源:KryoTranscoderTests.java
示例9: prepareResponse
import org.jasig.cas.authentication.RememberMeCredential; //导入依赖的package包/类
@Override
protected void prepareResponse(final Response response, final Map<String, Object> model) {
final Authentication authentication = getAssertionFrom(model).getChainedAuthentications().get(0);
final DateTime issuedAt = response.getIssueInstant();
final Service service = getAssertionFrom(model).getService();
final Object o = authentication.getAttributes().get(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME);
final boolean isRemembered = o == Boolean.TRUE && !getAssertionFrom(model).isFromNewLogin();
// Build up the SAML assertion containing AuthenticationStatement and AttributeStatement
final Assertion assertion = newSamlObject(Assertion.class);
assertion.setID(generateId());
assertion.setIssueInstant(issuedAt);
assertion.setIssuer(this.issuer);
assertion.setConditions(newConditions(issuedAt, service.getId()));
final AuthenticationStatement authnStatement = newAuthenticationStatement(authentication);
assertion.getAuthenticationStatements().add(authnStatement);
final Map<String, Object> attributes = authentication.getPrincipal().getAttributes();
if (!attributes.isEmpty() || isRemembered) {
assertion.getAttributeStatements().add(
newAttributeStatement(newSubject(authentication.getPrincipal().getId()), attributes, isRemembered));
}
response.setStatus(newStatus(StatusCode.SUCCESS, null));
response.getAssertions().add(assertion);
}
开发者ID:kevin3061,项目名称:cas-4.0.1,代码行数:26,代码来源:Saml10SuccessResponseView.java
示例10: populateAttributes
import org.jasig.cas.authentication.RememberMeCredential; //导入依赖的package包/类
@Override
public void populateAttributes(final AuthenticationBuilder builder, final Credential credential) {
final RememberMeCredential r = (RememberMeCredential) credential;
if (r.isRememberMe()) {
LOGGER.debug("Credential is configured to be remembered. Captured this as {} attribute",
RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME);
builder.addAttribute(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME, Boolean.TRUE);
}
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:10,代码来源:RememberMeAuthenticationMetaDataPopulator.java
示例11: verifyWithTrueRememberMeCredentials
import org.jasig.cas.authentication.RememberMeCredential; //导入依赖的package包/类
@Test
public void verifyWithTrueRememberMeCredentials() {
final RememberMeUsernamePasswordCredential c = new RememberMeUsernamePasswordCredential();
c.setRememberMe(true);
final AuthenticationBuilder builder = newBuilder(c);
final Authentication auth = builder.build();
assertEquals(true, auth.getAttributes().get(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME));
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:10,代码来源:RememberMeAuthenticationMetaDataPopulatorTests.java
示例12: verifyWithFalseRememberMeCredentials
import org.jasig.cas.authentication.RememberMeCredential; //导入依赖的package包/类
@Test
public void verifyWithFalseRememberMeCredentials() {
final RememberMeUsernamePasswordCredential c = new RememberMeUsernamePasswordCredential();
c.setRememberMe(false);
final AuthenticationBuilder builder = newBuilder(c);
final Authentication auth = builder.build();
assertNull(auth.getAttributes().get(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME));
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:10,代码来源:RememberMeAuthenticationMetaDataPopulatorTests.java
示例13: verifyWithoutRememberMeCredentials
import org.jasig.cas.authentication.RememberMeCredential; //导入依赖的package包/类
@Test
public void verifyWithoutRememberMeCredentials() {
final AuthenticationBuilder builder = newBuilder(TestUtils.getCredentialsWithSameUsernameAndPassword());
final Authentication auth = builder.build();
assertNull(auth.getAttributes().get(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME));
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:8,代码来源:RememberMeAuthenticationMetaDataPopulatorTests.java
示例14: verifyResponseWithoutAuthMethod
import org.jasig.cas.authentication.RememberMeCredential; //导入依赖的package包/类
@Test
public void verifyResponseWithoutAuthMethod() throws Exception {
final Map<String, Object> model = new HashMap<>();
final Map<String, Object> attributes = new HashMap<>();
attributes.put("testAttribute", "testValue");
final Principal principal = new DefaultPrincipalFactory().createPrincipal("testPrincipal", attributes);
final Map<String, Object> authnAttributes = new HashMap<>();
authnAttributes.put("authnAttribute1", "authnAttrbuteV1");
authnAttributes.put("authnAttribute2", "authnAttrbuteV2");
authnAttributes.put(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME, Boolean.TRUE);
final Authentication primary =
org.jasig.cas.authentication.TestUtils.getAuthentication(principal, authnAttributes);
final Assertion assertion = new ImmutableAssertion(
primary, Collections.singletonList(primary),
org.jasig.cas.authentication.TestUtils.getService(), true);
model.put("assertion", assertion);
final MockHttpServletResponse servletResponse = new MockHttpServletResponse();
this.response.renderMergedOutputModel(model, new MockHttpServletRequest(), servletResponse);
final String written = servletResponse.getContentAsString();
assertTrue(written.contains("testPrincipal"));
assertTrue(written.contains("testAttribute"));
assertTrue(written.contains("testValue"));
assertTrue(written.contains("authnAttribute1"));
assertTrue(written.contains("authnAttribute2"));
assertTrue(written.contains(CasProtocolConstants.VALIDATION_REMEMBER_ME_ATTRIBUTE_NAME));
assertTrue(written.contains("urn:oasis:names:tc:SAML:1.0:am:unspecified"));
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:35,代码来源:Saml10SuccessResponseViewTests.java
示例15: verifyTicketExpirationWithRememberMe
import org.jasig.cas.authentication.RememberMeCredential; //导入依赖的package包/类
@Test
public void verifyTicketExpirationWithRememberMe() {
final Authentication authentication = org.jasig.cas.authentication.TestUtils.getAuthentication(
this.principalFactory.createPrincipal("test"),
Collections.<String, Object>singletonMap(
RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME, true));
final TicketGrantingTicketImpl t = new TicketGrantingTicketImpl("111", authentication, this.p);
assertFalse(t.isExpired());
t.grantServiceTicket("55", org.jasig.cas.services.TestUtils.getService(), this.p, false, true);
assertTrue(t.isExpired());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:13,代码来源:RememberMeDelegatingExpirationPolicyTests.java
示例16: prepareSamlAttributes
import org.jasig.cas.authentication.RememberMeCredential; //导入依赖的package包/类
/**
* Prepare saml attributes. Combines both principal and authentication
* attributes. If the authentication is to be remembered, uses {@link #setRememberMeAttributeName(String)}
* for the remember-me attribute name.
*
* @param model the model
* @return the final map
* @since 4.1.0
*/
private Map<String, Object> prepareSamlAttributes(final Map<String, Object> model) {
final Map<String, Object> authnAttributes =
new HashMap<>(getAuthenticationAttributesAsMultiValuedAttributes(model));
if (isRememberMeAuthentication(model)) {
authnAttributes.remove(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME);
authnAttributes.put(this.rememberMeAttributeName, Boolean.TRUE.toString());
}
final Map<String, Object> attributesToReturn = new HashMap<>();
attributesToReturn.putAll(getPrincipalAttributesAsMultiValuedAttributes(model));
attributesToReturn.putAll(authnAttributes);
return attributesToReturn;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:Saml10SuccessResponseView.java
示例17: verifyResponseWithoutAuthMethod
import org.jasig.cas.authentication.RememberMeCredential; //导入依赖的package包/类
@Test
public void verifyResponseWithoutAuthMethod() throws Exception {
final Map<String, Object> model = new HashMap<>();
final Map<String, Object> attributes = new HashMap<>();
attributes.put("testAttribute", "testValue");
final Principal principal = new DefaultPrincipalFactory().createPrincipal("testPrincipal", attributes);
final Map<String, Object> authnAttributes = new HashMap<>();
authnAttributes.put("authnAttribute1", "authnAttrbuteV1");
authnAttributes.put("authnAttribute2", "authnAttrbuteV2");
authnAttributes.put(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME, Boolean.TRUE);
final Authentication primary = TestUtils.getAuthentication(principal, authnAttributes);
final Assertion assertion = new ImmutableAssertion(
primary, Collections.singletonList(primary), TestUtils.getService(), true);
model.put("assertion", assertion);
final MockHttpServletResponse servletResponse = new MockHttpServletResponse();
this.response.renderMergedOutputModel(model, new MockHttpServletRequest(), servletResponse);
final String written = servletResponse.getContentAsString();
assertTrue(written.contains("testPrincipal"));
assertTrue(written.contains("testAttribute"));
assertTrue(written.contains("testValue"));
assertTrue(written.contains("authnAttribute1"));
assertTrue(written.contains("authnAttribute2"));
assertTrue(written.contains(CasProtocolConstants.VALIDATION_REMEMBER_ME_ATTRIBUTE_NAME));
assertTrue(written.contains("urn:oasis:names:tc:SAML:1.0:am:unspecified"));
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:33,代码来源:Saml10SuccessResponseViewTests.java
示例18: isExpired
import org.jasig.cas.authentication.RememberMeCredential; //导入依赖的package包/类
@Override
public boolean isExpired(final TicketState ticketState) {
final Boolean b = (Boolean) ticketState.getAuthentication().getAttributes().
get(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME);
if (b == null || b.equals(Boolean.FALSE)) {
return this.sessionExpirationPolicy.isExpired(ticketState);
}
return this.rememberMeExpirationPolicy.isExpired(ticketState);
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:12,代码来源:RememberMeDelegatingExpirationPolicy.java
示例19: populateAttributes
import org.jasig.cas.authentication.RememberMeCredential; //导入依赖的package包/类
@Override
public void populateAttributes(final AuthenticationBuilder builder, final Credential credential) {
final RememberMeCredential r = (RememberMeCredential) credential;
if (r.isRememberMe()) {
builder.addAttribute(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME, Boolean.TRUE);
}
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:8,代码来源:RememberMeAuthenticationMetaDataPopulator.java
示例20: verifyTicketExpirationWithRememberMe
import org.jasig.cas.authentication.RememberMeCredential; //导入依赖的package包/类
@Test
public void verifyTicketExpirationWithRememberMe() {
final Authentication authentication = TestUtils.getAuthentication(
this.principalFactory.createPrincipal("test"),
Collections.<String, Object>singletonMap(
RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME, true));
final TicketGrantingTicketImpl t = new TicketGrantingTicketImpl("111", authentication, this.p);
assertFalse(t.isExpired());
t.grantServiceTicket("55", TestUtils.getService(), this.p, false);
assertTrue(t.isExpired());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:13,代码来源:RememberMeDelegatingExpirationPolicyTests.java
注:本文中的org.jasig.cas.authentication.RememberMeCredential类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论