Examples of WSUsernameTokenPrincipal


Examples of org.apache.ws.security.WSUsernameTokenPrincipal

            !MessageUtils.getContextualBoolean(message, SecurityConstants.USERNAME_TOKEN_NO_CALLBACKS, false);
        if (utWithCallbacks) {
            UsernameTokenProcessor p = new UsernameTokenProcessor();
            return p.handleUsernameToken(tokenElement, getCallback(message));
        } else {
            WSUsernameTokenPrincipal principal = parseTokenAndCreatePrincipal(tokenElement);
            WSS4JTokenConverter.convertToken(message, principal);
            return principal;
        }
    }
View Full Code Here

Examples of org.apache.ws.security.WSUsernameTokenPrincipal

    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

Examples of org.apache.ws.security.WSUsernameTokenPrincipal

               
                if (certs != null) {
                    returnCert[0] = certs[0];
                    return certs[0].getSubjectDN();
                } else if(ut != null){
                    WSUsernameTokenPrincipal principal = new WSUsernameTokenPrincipal(
                            ut.getName(), ut.isHashed());
                    principal.setNonce(ut.getNonce());
                    principal.setPassword(ut.getPassword());
                    principal.setCreatedTime(ut.getCreated());
                    return principal;
                } else if (dkt != null) {
                    WSDerivedKeyTokenPrincipal principal = new WSDerivedKeyTokenPrincipal(dkt.getID());
                    principal.setNonce(dkt.getNonce());
                    principal.setLabel(dkt.getLabel());
                    principal.setLength(dkt.getLength());
                    principal.setOffset(dkt.getOffset());
                    return principal;
                } else {
                    throw new WSSecurityException("Cannot determine principal");
                }
            } else {
View Full Code Here

Examples of org.apache.ws.security.WSUsernameTokenPrincipal

                throw new WSSecurityException(WSSecurityException.FAILURE,
                        "noPassword", new Object[]{user});
            }
        }

        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

Examples of org.apache.ws.security.WSUsernameTokenPrincipal

                throw new WSSecurityException(WSSecurityException.FAILURE,
                        "noPassword", new Object[]{user});
            }
        }

        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

Examples of org.apache.ws.security.WSUsernameTokenPrincipal

               
                if (certs != null) {
                    returnCert[0] = certs[0];
                    return certs[0].getSubjectDN();
                } else if(ut != null){
                    WSUsernameTokenPrincipal principal = new WSUsernameTokenPrincipal(
                            ut.getName(), ut.isHashed());
                    principal.setNonce(ut.getNonce());
                    principal.setPassword(ut.getPassword());
                    principal.setCreatedTime(ut.getCreated());
                    return principal;
                } else if (dkt != null) {
                    WSDerivedKeyTokenPrincipal principal = new WSDerivedKeyTokenPrincipal(dkt.getID());
                    principal.setNonce(dkt.getNonce());
                    principal.setLabel(dkt.getLabel());
                    principal.setLength(dkt.getLength());
                    principal.setOffset(dkt.getOffset());
                    String basetokenId = dkt.getSecuityTokenReference().getReference().getURI().substring(1);
                    principal.setBasetokenId(basetokenId);
                    return principal;
                } else {
                    throw new WSSecurityException("Cannot determine principal");
                }
            } else {
View Full Code Here

Examples of org.apache.ws.security.WSUsernameTokenPrincipal

             * 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

Examples of org.apache.ws.security.WSUsernameTokenPrincipal

                    if (sc == null || sc.getUserPrincipal() == null) {
                        if (subject != null && principal != null) {
                            message.put(SecurityContext.class,
                                    createSecurityContext(principal, subject));
                        } else if (principal instanceof WSUsernameTokenPrincipal) {
                            WSUsernameTokenPrincipal utPrincipal = (WSUsernameTokenPrincipal)principal;
                            subject = createSubject(utPrincipal.getName(), utPrincipal.getPassword(),
                                    utPrincipal.isPasswordDigest(), utPrincipal.getNonce(),
                                    utPrincipal.getCreatedTime());
                            message.put(SecurityContext.class,
                                    createSecurityContext(utPrincipal, subject));
                        }
                    }
                   
View Full Code Here

Examples of org.apache.ws.security.WSUsernameTokenPrincipal

    protected WSUsernameTokenPrincipal parseTokenAndCreatePrincipal(Element tokenElement, boolean bspCompliant)
        throws WSSecurityException {
        org.apache.ws.security.message.token.UsernameToken ut =
            new org.apache.ws.security.message.token.UsernameToken(tokenElement, false, bspCompliant);
       
        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

Examples of org.apache.ws.security.WSUsernameTokenPrincipal

            try {
                WSSecurityHandler handler = WSSecurityHandler.getCurrentHandler();
                lastPrincipalFound = verifyXMLSignature((Element) elem,
                        crypto, returnCert, returnElements, signatureValue);
                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
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.