Examples of CloudsealPrincipal


Examples of com.cloudseal.client.saml2.CloudsealPrincipal

        classUnderTest = new CloudsealAuthenticationProvider();
    }

    @Test
    public void testSuccessfulAuthentication() throws VerificationException {
        CloudsealPrincipal cloudsealPrincipal = new CloudsealPrincipal();
        cloudsealPrincipal.setUsername("jdoe");
        CloudsealAssertionAuthenticationToken token = new CloudsealAssertionAuthenticationToken("http://localhost:8080/saml/sp", "123", "SAMLResponse");
        when(cloudsealManager.getPublicKey()).thenReturn(publicKey);
        when(authResponseValidator.validateAuthResponse(any(PublicKey.class), anyString(), anyString(), anyString())).thenReturn(cloudsealPrincipal);
        classUnderTest.setCloudsealManager(cloudsealManager);
        classUnderTest.setResponseValidator(authResponseValidator);
View Full Code Here

Examples of com.cloudseal.client.saml2.CloudsealPrincipal

        assertTrue(authToken.isAuthenticated());
    }

    @Test
    public void testSuccessfulAuthenticationWithRoles() throws VerificationException {
        CloudsealPrincipal cloudsealPrincipal = new CloudsealPrincipal();
        cloudsealPrincipal.getRoles().add("ROLE_USER");
        cloudsealPrincipal.getRoles().add("ROLE_ADMIN");

        CloudsealAssertionAuthenticationToken token = new CloudsealAssertionAuthenticationToken("http://localhost:8080/saml/sp", "123", "SAMLResponse");
        when(cloudsealManager.getPublicKey()).thenReturn(publicKey);
        when(authResponseValidator.validateAuthResponse(any(PublicKey.class), anyString(), anyString(), anyString())).thenReturn(cloudsealPrincipal);
        classUnderTest.setCloudsealManager(cloudsealManager);
View Full Code Here

Examples of com.cloudseal.client.saml2.CloudsealPrincipal

    @Override
    public Authentication authenticate(Authentication authentication) throws AuthenticationException {
        CloudsealAssertionAuthenticationToken token = (CloudsealAssertionAuthenticationToken) authentication;
        CloudsealAssertionAuthenticationToken.TokenDetails tokenDetails = (CloudsealAssertionAuthenticationToken.TokenDetails) token.getDetails();
        try {
            CloudsealPrincipal cloudsealPrincipal = responseValidator.validateResponse(cloudsealManager.getPublicKey(),
                    tokenDetails.getSamlResponse(), tokenDetails.getRequestId(), tokenDetails.getAudience());

            Collection<? extends GrantedAuthority> authorities = mapAuthorities(cloudsealPrincipal);
            CloudsealUserDetails userDetails = new CloudsealUserDetails(cloudsealPrincipal, authorities);
            CloudsealAuthenticationToken authenticationToken = new CloudsealAuthenticationToken(userDetails);
View Full Code Here

Examples of com.cloudseal.client.saml2.CloudsealPrincipal

    @Override
    public Authentication authenticate(Authentication authentication) throws AuthenticationException {
        CloudsealAssertionAuthenticationToken token = (CloudsealAssertionAuthenticationToken) authentication;
        CloudsealAssertionAuthenticationToken.TokenDetails tokenDetails = (CloudsealAssertionAuthenticationToken.TokenDetails) token.getDetails();
        try {
            CloudsealPrincipal cloudsealPrincipal = responseValidator.validateAuthResponse(cloudsealManager.getPublicKey(),
                    tokenDetails.getSamlResponse(), tokenDetails.getRequestId(), tokenDetails.getAudience());

            Collection<? extends GrantedAuthority> authorities = mapAuthorities(cloudsealPrincipal);
            CloudsealUserDetails userDetails = new CloudsealUserDetails(cloudsealPrincipal, authorities);
            CloudsealAuthenticationToken authenticationToken = new CloudsealAuthenticationToken(userDetails);
View Full Code Here

Examples of com.cloudseal.client.saml2.CloudsealPrincipal

    @Override
    @SuppressWarnings("unchecked")
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // Get the Cloudseal principal
        CloudsealPrincipal cloudsealPrincipal = CloudsealUtils.getPrincipal(req);

        resp.getWriter().println("<html><body>");
        resp.getWriter().println("<h3>User Properties</h3>");

        // Here we're using commons BeanUtils to create a map of all the properties on the CloudsealPrincipal
View Full Code Here

Examples of com.cloudseal.client.saml2.CloudsealPrincipal

    @Override
    public Authentication authenticate(Authentication authentication) throws AuthenticationException {
        CloudsealAssertionAuthenticationToken token = (CloudsealAssertionAuthenticationToken) authentication;
        CloudsealAssertionAuthenticationToken.TokenDetails tokenDetails = (CloudsealAssertionAuthenticationToken.TokenDetails) token.getDetails();
        try {
            CloudsealPrincipal cloudsealPrincipal = responseValidator.validateResponse(cloudsealManager.getPublicKey(),
                    tokenDetails.getSamlResponse(), tokenDetails.getRequestId(), tokenDetails.getAudience());

            Collection<? extends GrantedAuthority> authorities = mapAuthorities(cloudsealPrincipal);
            CloudsealUserDetails userDetails = new CloudsealUserDetails(cloudsealPrincipal, authorities);
            CloudsealAuthenticationToken authenticationToken = new CloudsealAuthenticationToken(userDetails);
View Full Code Here

Examples of com.cloudseal.client.saml2.CloudsealPrincipal

    @Override
    @SuppressWarnings("unchecked")
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // Get the Cloudseal principal
        CloudsealPrincipal cloudsealPrincipal = CloudsealUtils.getPrincipal(req);

        String contextRoot = req.getContextPath();
        resp.getWriter().println("<html><body>");
        resp.getWriter().println("<p><a href=\"" + contextRoot + "/logout\">logout</a></p>");
        resp.getWriter().println("<h3>User Properties</h3>");
View Full Code Here

Examples of com.cloudseal.client.saml2.CloudsealPrincipal

*/
public class CloudsealDemoServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        CloudsealPrincipal principal = (CloudsealPrincipal) request.getUserPrincipal();
        request.setAttribute("username", principal.getUsername());
        request.setAttribute("firstName", principal.getFirstName());
        request.setAttribute("lastName", principal.getLastName());
        request.setAttribute("email", principal.getEmail());
        getServletContext().getRequestDispatcher("/WEB-INF/jsp/demo.jsp").forward(request, response);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.