Tabnine Logo
AssertionImpl
Code IndexAdd Tabnine to your IDE (free)

How to use
AssertionImpl
in
org.jasig.cas.client.validation

Best Java code snippets using org.jasig.cas.client.validation.AssertionImpl (Showing top 20 results out of 315)

origin: spring-projects/spring-security

  public Assertion validate(final String ticket, final String service)
      throws TicketValidationException {
    if (returnTicket) {
      return new AssertionImpl("rod");
    }
    throw new BadCredentialsException("As requested from mock");
  }
}
origin: spring-projects/spring-security

  private CasAuthenticationToken createCasAuthenticationToken() {
    User principal = new User("admin", "1234", Collections.singletonList(new SimpleGrantedAuthority("ROLE_USER")));
    Collection<? extends GrantedAuthority> authorities = Collections.singletonList(new SimpleGrantedAuthority("ROLE_USER"));
    Assertion assertion = new AssertionImpl(new AttributePrincipalImpl("assertName"), START_DATE, END_DATE, START_DATE, Collections.<String, Object>emptyMap());
    return new CasAuthenticationToken(KEY, principal, principal.getPassword(), authorities,
        new User("admin", "1234", authorities), assertion);
  }
}
origin: spring-projects/spring-security

protected CasAuthenticationToken getToken() {
  List<String> proxyList = new ArrayList<>();
  proxyList.add("https://localhost/newPortal/login/cas");
  User user = new User("rod", "password", true, true, true, true,
      AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO"));
  final Assertion assertion = new AssertionImpl("rod");
  return new CasAuthenticationToken("key", user, "ST-0-ER94xMJmn6pha35CQRoZ",
      AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO"), user,
      assertion);
}
origin: spring-projects/spring-security

@Test
public void testNotEqualsDueToDifferentAuthenticationClass() {
  final Assertion assertion = new AssertionImpl("test");
  CasAuthenticationToken token1 = new CasAuthenticationToken("key",
      makeUserDetails(), "Password", ROLES, makeUserDetails(), assertion);
  UsernamePasswordAuthenticationToken token2 = new UsernamePasswordAuthenticationToken(
      "Test", "Password", ROLES);
  assertThat(!token1.equals(token2)).isTrue();
}
origin: spring-projects/spring-security

  @Test
  public void testToString() {
    final Assertion assertion = new AssertionImpl("test");
    CasAuthenticationToken token = new CasAuthenticationToken("key",
        makeUserDetails(), "Password", ROLES, makeUserDetails(), assertion);
    String result = token.toString();
    assertThat(
        result.lastIndexOf("Credentials (Service/Proxy Ticket):") != -1).isTrue();
  }
}
origin: spring-projects/spring-security

@Test
public void testSetAuthenticated() {
  final Assertion assertion = new AssertionImpl("test");
  CasAuthenticationToken token = new CasAuthenticationToken("key",
      makeUserDetails(), "Password", ROLES, makeUserDetails(), assertion);
  assertThat(token.isAuthenticated()).isTrue();
  token.setAuthenticated(false);
  assertThat(!token.isAuthenticated()).isTrue();
}
origin: spring-projects/spring-security

@Test
public void testNotEqualsDueToAssertion() {
  final Assertion assertion = new AssertionImpl("test");
  final Assertion assertion2 = new AssertionImpl("test");
  CasAuthenticationToken token1 = new CasAuthenticationToken("key",
      makeUserDetails(), "Password", ROLES, makeUserDetails(), assertion);
  CasAuthenticationToken token2 = new CasAuthenticationToken("key",
      makeUserDetails(), "Password", ROLES, makeUserDetails(), assertion2);
  assertThat(!token1.equals(token2)).isTrue();
}
origin: spring-projects/spring-security

@Test
public void testGetters() {
  // Build the proxy list returned in the ticket from CAS
  final Assertion assertion = new AssertionImpl("test");
  CasAuthenticationToken token = new CasAuthenticationToken("key",
      makeUserDetails(), "Password", ROLES, makeUserDetails(), assertion);
  assertThat(token.getKeyHash()).isEqualTo("key".hashCode());
  assertThat(token.getPrincipal()).isEqualTo(makeUserDetails());
  assertThat(token.getCredentials()).isEqualTo("Password");
  assertThat(token.getAuthorities()).contains(
      new SimpleGrantedAuthority("ROLE_ONE"));
  assertThat(token.getAuthorities()).contains(
      new SimpleGrantedAuthority("ROLE_TWO"));
  assertThat(token.getAssertion()).isEqualTo(assertion);
  assertThat(token.getUserDetails().getUsername()).isEqualTo(
      makeUserDetails().getUsername());
}
origin: spring-projects/spring-security

@Test
public void testEqualsWhenEqual() {
  final Assertion assertion = new AssertionImpl("test");
  CasAuthenticationToken token1 = new CasAuthenticationToken("key",
      makeUserDetails(), "Password", ROLES, makeUserDetails(), assertion);
  CasAuthenticationToken token2 = new CasAuthenticationToken("key",
      makeUserDetails(), "Password", ROLES, makeUserDetails(), assertion);
  assertThat(token2).isEqualTo(token1);
}
origin: spring-projects/spring-security

@Test
public void authenticateAllNullService() throws Exception {
  String serviceUrl = "https://service/context";
  ServiceAuthenticationDetails details = mock(ServiceAuthenticationDetails.class);
  when(details.getServiceUrl()).thenReturn(serviceUrl);
  TicketValidator validator = mock(TicketValidator.class);
  when(validator.validate(any(String.class), any(String.class))).thenReturn(
      new AssertionImpl("rod"));
  ServiceProperties serviceProperties = makeServiceProperties();
  serviceProperties.setAuthenticateAllArtifacts(true);
  CasAuthenticationProvider cap = new CasAuthenticationProvider();
  cap.setAuthenticationUserDetailsService(new MockAuthoritiesPopulator());
  cap.setKey("qwerty");
  cap.setTicketValidator(validator);
  cap.setServiceProperties(serviceProperties);
  cap.afterPropertiesSet();
  String ticket = "ST-456";
  UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(
      CasAuthenticationFilter.CAS_STATELESS_IDENTIFIER, ticket);
  Authentication result = cap.authenticate(token);
}
origin: spring-projects/spring-security

@Test
public void testNotEqualsDueToAbstractParentEqualsCheck() {
  final Assertion assertion = new AssertionImpl("test");
  CasAuthenticationToken token1 = new CasAuthenticationToken("key",
      makeUserDetails(), "Password", ROLES, makeUserDetails(), assertion);
  CasAuthenticationToken token2 = new CasAuthenticationToken("key",
      makeUserDetails("OTHER_NAME"), "Password", ROLES, makeUserDetails(),
      assertion);
  assertThat(!token1.equals(token2)).isTrue();
}
origin: spring-projects/spring-security

@Test
public void testNotEqualsDueToKey() {
  final Assertion assertion = new AssertionImpl("test");
  CasAuthenticationToken token1 = new CasAuthenticationToken("key",
      makeUserDetails(), "Password", ROLES, makeUserDetails(), assertion);
  CasAuthenticationToken token2 = new CasAuthenticationToken("DIFFERENT_KEY",
      makeUserDetails(), "Password", ROLES, makeUserDetails(), assertion);
  assertThat(!token1.equals(token2)).isTrue();
}
origin: spring-projects/spring-security

TicketValidator validator = mock(TicketValidator.class);
when(validator.validate(any(String.class), any(String.class))).thenReturn(
    new AssertionImpl("rod"));
origin: spring-projects/spring-security

@Test(expected = BadCredentialsException.class)
public void invalidKeyIsDetected() throws Exception {
  final Assertion assertion = new AssertionImpl("test");
  CasAuthenticationProvider cap = new CasAuthenticationProvider();
  cap.setAuthenticationUserDetailsService(new MockAuthoritiesPopulator());
  cap.setKey("qwerty");
  StatelessTicketCache cache = new MockStatelessTicketCache();
  cap.setStatelessTicketCache(cache);
  cap.setTicketValidator(new MockTicketValidator(true));
  cap.setServiceProperties(makeServiceProperties());
  cap.afterPropertiesSet();
  CasAuthenticationToken token = new CasAuthenticationToken("WRONG_KEY",
      makeUserDetails(), "credentials",
      AuthorityUtils.createAuthorityList("XX"), makeUserDetails(), assertion);
  cap.authenticate(token);
}
origin: spring-projects/spring-security

@Test
public void testConstructorRejectsNulls() {
  final Assertion assertion = new AssertionImpl("test");
  try {
    new CasAuthenticationToken(null, makeUserDetails(), "Password", ROLES,
origin: apereo/java-cas-client

  protected Assertion parseResponseFromServer(final String response) throws TicketValidationException {
    if (!response.startsWith("yes")) {
      throw new TicketValidationException("CAS Server could not validate ticket.");
    }

    try {
      final BufferedReader reader = new BufferedReader(new StringReader(response));
      reader.readLine();
      final String name = reader.readLine();

      return new AssertionImpl(name);
    } catch (final IOException e) {
      throw new TicketValidationException("Unable to parse response.", e);
    }
  }
}
origin: org.jasig.cas/com.springsource.org.jasig.cas.client

  protected Assertion parseResponseFromServer(final String response) throws TicketValidationException {
    if (!response.startsWith("yes")) {
      throw new TicketValidationException("CAS Server could not validate ticket.");
    }

    try {
      final BufferedReader reader = new BufferedReader(new StringReader(
          response));
      reader.readLine();
      final String name = reader.readLine();

      return new AssertionImpl(name);
    } catch (final IOException e) {
      throw new TicketValidationException("Unable to parse response.", e);
    }
  }
}
origin: org.apereo.cas/cas-server-support-saml-idp-web

/**
 * Build cas assertion.
 *
 * @param principal         the principal
 * @param registeredService the registered service
 * @param attributes        the attributes
 * @return the assertion
 */
protected Assertion buildCasAssertion(final String principal,
                   final RegisteredService registeredService,
                   final Map<String, Object> attributes) {
  val p = new AttributePrincipalImpl(principal, attributes);
  return new AssertionImpl(p, DateTimeUtils.dateOf(ZonedDateTime.now()),
    null, DateTimeUtils.dateOf(ZonedDateTime.now()), attributes);
}
origin: apereo/java-cas-client

public void testAssertionValidity() throws Exception {
  final Assertion assertion = new AssertionImpl(CONST_PRINCIPAL, new Date(), new Date(), new Date(), CONST_ATTRIBUTES);
  assertTrue(assertion.isValid());
}

origin: apereo/java-cas-client

return new AssertionImpl(
    new AttributePrincipalImpl(nameId, principalAttributes),
    assertionValidityStart,
org.jasig.cas.client.validationAssertionImpl

Javadoc

Concrete Implementation of the Assertion.

Most used methods

  • <init>
    Create a new Assertion with the supplied principal and Assertion attributes.

Popular in Java

  • Reading from database using SQL prepared statement
  • getContentResolver (Context)
  • setScale (BigDecimal)
  • getApplicationContext (Context)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Collectors (java.util.stream)
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now