Package org.apache.ws.security

Examples of org.apache.ws.security.WSUsernameTokenPrincipal


                Collection<AssertionInfo> ais = aim.get(SP12Constants.USERNAME_TOKEN);
                if (ais != null) {
                    for (AssertionInfo ai : ais) {
                        ai.setAsserted(true);
                    }
                    WSUsernameTokenPrincipal princ
                        = (WSUsernameTokenPrincipal)wser.get(WSSecurityEngineResult.TAG_PRINCIPAL);
                    for (AssertionInfo ai : ais) {
                        UsernameToken tok = (UsernameToken)ai.getAssertion();
                        if (tok.isHashPassword() != princ.isPasswordDigest()) {
                            ai.setNotAsserted("Password hashing policy not enforced");
                        }
                    }
                }
                break;
View Full Code Here


            }
           
            AbstractUsernameTokenAuthenticatingInterceptor.this.setSubject(
                user, password, ut.isHashed(), nonce, createdTime);   
           
            WSUsernameTokenPrincipal principal = new WSUsernameTokenPrincipal(user, ut.isHashed());
            principal.setNonce(nonce);
            principal.setPassword(password);
            principal.setCreatedTime(createdTime);
            principal.setPasswordType(pwType);

            return principal;
        }
View Full Code Here

        if ("PasswordDigest".equals(pwType)) {
            //CXF-2150 - we need to check the UsernameTokens
            for (WSSecurityEngineResult o : CastUtils.cast(wsResult, WSSecurityEngineResult.class)) {
                Integer actInt = (Integer)o.get(WSSecurityEngineResult.TAG_ACTION);
                if (actInt == WSConstants.UT) {
                    WSUsernameTokenPrincipal princ
                        = (WSUsernameTokenPrincipal)o.get(WSSecurityEngineResult.TAG_PRINCIPAL);
                    if (!princ.isPasswordDigest()) {
                        LOG.warning("Non-digest UsernameToken found, but digest required");
                        throw new WSSecurityException(WSSecurityException.INVALID_SECURITY);
                    }
                }
            }           
View Full Code Here

        Element el = (Element)h.getObject();
        Element child = DOMUtils.getFirstElement(el);
        while (child != null) {
            if (SPConstants.USERNAME_TOKEN.equals(child.getLocalName())) {
                try  {
                    final WSUsernameTokenPrincipal princ = getPrincipal(child, message);
                    if (princ != null) {
                        Vector<WSSecurityEngineResult>v = new Vector<WSSecurityEngineResult>();
                        v.add(0, new WSSecurityEngineResult(WSConstants.UT, princ, null, null, null));
                        List<Object> results = CastUtils.cast((List)message
                                                                  .get(WSHandlerConstants.RECV_RESULTS));
                        if (results == null) {
                            results = new Vector<Object>();
                            message.put(WSHandlerConstants.RECV_RESULTS, results);
                        }
                        WSHandlerResult rResult = new WSHandlerResult(null, v);
                        results.add(0, rResult);

                        assertUsernameTokens(message, princ);
                        message.put(WSS4JInInterceptor.PRINCIPAL_RESULT, princ);                  
                        SecurityContext sc = message.get(SecurityContext.class);
                        if (sc == null || sc.getUserPrincipal() == null) {
                            Subject subject = createSubject(princ.getName(), princ.getPassword(),
                                princ.isPasswordDigest(), princ.getNonce(), princ.getCreatedTime());
                            message.put(SecurityContext.class,
                                        createSecurityContext(princ, subject));
                        }

                    }
View Full Code Here

    protected WSUsernameTokenPrincipal parseTokenAndCreatePrincipal(Element tokenElement)
        throws WSSecurityException {
        org.apache.ws.security.message.token.UsernameToken ut =
            new org.apache.ws.security.message.token.UsernameToken(tokenElement, false);
       
        WSUsernameTokenPrincipal principal = new WSUsernameTokenPrincipal(ut.getName(), ut.isHashed());
        principal.setNonce(ut.getNonce());
        principal.setPassword(ut.getPassword());
        principal.setCreatedTime(ut.getCreated());
        principal.setPasswordType(ut.getPasswordType());

        return principal;
    }
View Full Code Here

        List<WSSecurityEngineResult> results = verify(signedDoc, null);
       
        Principal principal = (Principal)results.get(0).get(WSSecurityEngineResult.TAG_PRINCIPAL);
        assert principal instanceof WSUsernameTokenPrincipal;
        assert "wernerd".equals(principal.getName());
        WSUsernameTokenPrincipal userPrincipal = (WSUsernameTokenPrincipal)principal;
        assert userPrincipal.getCreatedTime() != null;
        assert userPrincipal.getNonce() != null;
        assert userPrincipal.getPassword() != null;
        assert userPrincipal.isPasswordDigest();
        assert WSConstants.PASSWORD_DIGEST.equals(userPrincipal.getPasswordType());
    }
View Full Code Here

            try {
                WSSecurityHandler handler = WSSecurityHandler.getCurrentHandler();
                lastPrincipalFound = verifyXMLSignature((Element) elem,
                        crypto, returnCert, returnElements, null, signatureValue, cb);
                if (lastPrincipalFound instanceof WSUsernameTokenPrincipal) {
                    WSUsernameTokenPrincipal p = (WSUsernameTokenPrincipal) lastPrincipalFound;
                    handler.checkUser(p.getName(), p.getPassword());
                } else {
                    handler.checkUser(returnCert[0].getSubjectX500Principal().getName(), returnCert[0]);
                }
            } catch (GeneralSecurityException e) {
                throw new WSSecurityException("Unable to authenticate user", e);
View Full Code Here

        if ("PasswordDigest".equals(pwType)) {
            //CXF-2150 - we need to check the UsernameTokens
            for (WSSecurityEngineResult o : CastUtils.cast(wsResult, WSSecurityEngineResult.class)) {
                Integer actInt = (Integer)o.get(WSSecurityEngineResult.TAG_ACTION);
                if (actInt == WSConstants.UT) {
                    WSUsernameTokenPrincipal princ
                        = (WSUsernameTokenPrincipal)o.get(WSSecurityEngineResult.TAG_PRINCIPAL);
                    if (!princ.isPasswordDigest()) {
                        LOG.warning("Non-digest UsernameToken found, but digest required");
                        throw new WSSecurityException(WSSecurityException.INVALID_SECURITY);
                    }
                }
            }           
View Full Code Here

             * of this token to set the alias for the encryption user
             */
            for (WSSecurityEngineResult wser : wsSecEngineResults) {
                Integer actInt = (Integer)wser.get(WSSecurityEngineResult.TAG_ACTION);
                if (actInt.intValue() == WSConstants.UT) {
                    WSUsernameTokenPrincipal principal
                        = (WSUsernameTokenPrincipal)wser.get(WSSecurityEngineResult.TAG_PRINCIPAL);
                    return principal.getName();
                }
            }
        }
        
        return null;
View Full Code Here

                    for (AssertionInfo ai : ais) {
                        ai.setAsserted(true);
                    }
                   
                    if (utWithCallbacks) {
                        WSUsernameTokenPrincipal princ
                            = (WSUsernameTokenPrincipal)wser.get(WSSecurityEngineResult.TAG_PRINCIPAL);
                        for (AssertionInfo ai : ais) {
                            UsernameToken tok = (UsernameToken)ai.getAssertion();
                            if (tok.isHashPassword() != princ.isPasswordDigest()) {
                                ai.setNotAsserted("Password hashing policy not enforced");
                            }
                        }
                    }
                }
View Full Code Here

TOP

Related Classes of org.apache.ws.security.WSUsernameTokenPrincipal

Copyright © 2018 www.massapicom. 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.