本文整理汇总了Java中org.jasig.cas.authentication.AuthenticationBuilder.addCredential方法的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationBuilder.addCredential方法的具体用法?Java AuthenticationBuilder.addCredential怎么用?Java AuthenticationBuilder.addCredential使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jasig.cas.authentication.AuthenticationBuilder
的用法示例。
在下文中一共展示了AuthenticationBuilder.addCredential方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MockTicketGrantingTicket
import org.jasig.cas.authentication.AuthenticationBuilder; //导入方法依赖的package包/类
public MockTicketGrantingTicket(final String id, final Credential credential) {
this.id = id;
final CredentialMetaData credentialMetaData = new BasicCredentialMetaData(credential);
final AuthenticationBuilder builder = new AuthenticationBuilder();
final Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put("nickname", "bob");
builder.setPrincipal(new SimplePrincipal("handymanbob", attributes));
builder.setAuthenticationDate(new Date());
builder.addCredential(credentialMetaData);
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();
}
示例2: MockTicketGrantingTicket
import org.jasig.cas.authentication.AuthenticationBuilder; //导入方法依赖的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();
}
示例3: verifyEncodeDecodeTGTImpl
import org.jasig.cas.authentication.AuthenticationBuilder; //导入方法依赖的package包/类
@Test
public void verifyEncodeDecodeTGTImpl() throws Exception {
final Credential userPassCredential = new UsernamePasswordCredential(USERNAME, PASSWORD);
final AuthenticationBuilder bldr = new DefaultAuthenticationBuilder(
new DefaultPrincipalFactory()
.createPrincipal("user", Collections.unmodifiableMap(this.principalAttributes)));
bldr.setAttributes(Collections.unmodifiableMap(this.principalAttributes));
bldr.setAuthenticationDate(new DateTime());
bldr.addCredential(new BasicCredentialMetaData(userPassCredential));
bldr.addFailure("error", AccountNotFoundException.class);
bldr.addSuccess("authn", new DefaultHandlerResult(
new AcceptUsersAuthenticationHandler(),
new BasicCredentialMetaData(userPassCredential)));
final TicketGrantingTicket expectedTGT =
new TicketGrantingTicketImpl(TGT_ID,
org.jasig.cas.services.TestUtils.getService(),
null, bldr.build(),
new NeverExpiresExpirationPolicy());
final ServiceTicket ticket = expectedTGT.grantServiceTicket(ST_ID,
org.jasig.cas.services.TestUtils.getService(),
new NeverExpiresExpirationPolicy(), false, true);
CachedData result = transcoder.encode(expectedTGT);
final TicketGrantingTicket resultTicket = (TicketGrantingTicket) transcoder.decode(result);
assertEquals(expectedTGT, resultTicket);
result = transcoder.encode(ticket);
final ServiceTicket resultStTicket = (ServiceTicket) transcoder.decode(result);
assertEquals(ticket, resultStTicket);
}
示例4: verifyEncodeDecodeTGTImpl
import org.jasig.cas.authentication.AuthenticationBuilder; //导入方法依赖的package包/类
@Test
public void verifyEncodeDecodeTGTImpl() throws Exception {
final Credential userPassCredential = new UsernamePasswordCredential(USERNAME, PASSWORD);
final AuthenticationBuilder bldr = new DefaultAuthenticationBuilder(
new DefaultPrincipalFactory()
.createPrincipal("user", Collections.unmodifiableMap(this.principalAttributes)));
bldr.setAttributes(Collections.unmodifiableMap(this.principalAttributes));
bldr.setAuthenticationDate(new Date());
bldr.addCredential(new BasicCredentialMetaData(userPassCredential));
bldr.addFailure("error", AccountNotFoundException.class);
bldr.addSuccess("authn", new DefaultHandlerResult(
new AcceptUsersAuthenticationHandler(),
new BasicCredentialMetaData(userPassCredential)));
final TicketGrantingTicket parent =
new TicketGrantingTicketImpl(TGT_ID, TestUtils.getService(), null, bldr.build(),
new NeverExpiresExpirationPolicy());
final TicketGrantingTicket expectedTGT =
new TicketGrantingTicketImpl(TGT_ID, TestUtils.getService(),
null, bldr.build(),
new NeverExpiresExpirationPolicy());
final ServiceTicket ticket = expectedTGT.grantServiceTicket(ST_ID,
TestUtils.getService(),
new NeverExpiresExpirationPolicy(), false);
CachedData result = transcoder.encode(expectedTGT);
final TicketGrantingTicket resultTicket = (TicketGrantingTicket) transcoder.decode(result);
assertEquals(expectedTGT, resultTicket);
result = transcoder.encode(ticket);
final ServiceTicket resultStTicket = (ServiceTicket) transcoder.decode(result);
assertEquals(ticket, resultStTicket);
}