Package org.apache.cxf.ws.security.sts.provider

Examples of org.apache.cxf.ws.security.sts.provider.STSException


                if (!parameterBean.getAttributeValues().isEmpty()) {
                    attributeList.add(parameterBean);
                }
            }
        } catch (WSSecurityException ex) {
            throw new STSException(ex.getMessage(), ex);
        }
       
        attrBean.setSamlAttributes(attributeList);
       
        return attrBean;
View Full Code Here


    protected RequestParser parseRequest(
        RequestSecurityTokenType request,
        WebServiceContext context
    ) {
        if (context == null || context.getMessageContext() == null) {
            throw new STSException("No message context found");
        }
       
        if (stsProperties == null) {
            throw new STSException("No STSProperties object found");
        }
        stsProperties.configureProperties();
       
        RequestParser requestParser = new RequestParser();
        requestParser.parseRequest(request, context);
View Full Code Here

        String name = encryptionProperties.getEncryptionName();
        if (name == null) {
            name = stsProperties.getEncryptionUsername();
        }
        if (name == null) {
            throw new STSException("No encryption alias is configured", STSException.REQUEST_FAILED);
        }
       
        // Get the encryption algorithm to use
        String encryptionAlgorithm = keyRequirements.getEncryptionAlgorithm();
        if (encryptionAlgorithm == null) {
View Full Code Here

        String name = encryptionProperties.getEncryptionName();
        if (name == null) {
            name = stsProperties.getEncryptionUsername();
        }
        if (name == null) {
            throw new STSException("No encryption alias is configured", STSException.REQUEST_FAILED);
        }
       
        // Get the key-wrap algorithm to use
        String keyWrapAlgorithm = keyRequirements.getKeywrapAlgorithm();
        if (keyWrapAlgorithm == null) {
View Full Code Here

                    }
                }
            }
            if (!foundService) {
                LOG.log(Level.WARNING, "The Service cannot match the received AppliesTo address");
                throw new STSException(
                    "No service corresponding to " + address + " is known", STSException.REQUEST_FAILED
                );
            }
        }
       
View Full Code Here

                isBinarySecurityToken = true;
            } else if (QNameConstants.SECURITY_TOKEN_REFERENCE.equals(parentName)) {
                LOG.fine("Found SecurityTokenReference");               
            } else {
                LOG.fine("Found unknown token object: " + parentName);
                throw new STSException(
                    "An unknown element was received", STSException.BAD_REQUEST
                );
            }
            token = ((JAXBElement<?>)receivedToken).getValue();
        } else if (receivedToken instanceof Element) {
            LOG.fine("Found ValidateTarget element: " + ((Element)receivedToken).getLocalName());
            this.token = (Element)receivedToken;
            isDOMElement = true;
        } else {
            LOG.fine("Found ValidateTarget object of unknown type");
            throw new STSException(
                "An unknown element was received", STSException.BAD_REQUEST
            );
        }
    }
View Full Code Here

        KeyRequirements keyRequirements = requestParser.getKeyRequirements();
        TokenRequirements tokenRequirements = requestParser.getTokenRequirements();
       
        ReceivedToken validateTarget = tokenRequirements.getValidateTarget();
        if (validateTarget == null || validateTarget.getToken() == null) {
            throw new STSException("No element presented for validation", STSException.INVALID_REQUEST);
        }
        if (tokenRequirements.getTokenType() == null) {
            tokenRequirements.setTokenType(STSConstants.STATUS);
            LOG.fine(
                "Received TokenType is null, falling back to default token type: "
                + STSConstants.STATUS
            );
        }
       
        TokenValidatorParameters validatorParameters = new TokenValidatorParameters();
        validatorParameters.setStsProperties(stsProperties);
        validatorParameters.setPrincipal(context.getUserPrincipal());
        validatorParameters.setWebServiceContext(context);
        validatorParameters.setTokenStore(getTokenStore());
       
        validatorParameters.setKeyRequirements(keyRequirements);
        validatorParameters.setTokenRequirements(tokenRequirements);
       
        //
        // Validate token
        //
        TokenValidatorResponse tokenResponse = null;
        for (TokenValidator tokenValidator : tokenValidators) {
            if (tokenValidator.canHandleToken(validateTarget)) {
                try {
                    tokenResponse = tokenValidator.validateToken(validatorParameters);
                } catch (RuntimeException ex) {
                    LOG.log(Level.WARNING, "", ex);
                    tokenResponse = new TokenValidatorResponse();
                    tokenResponse.setValid(false);
                }
                break;
            }
        }
        if (tokenResponse == null) {
            LOG.fine("No Token Validator has been found that can handle this token");
            tokenResponse = new TokenValidatorResponse();
            tokenResponse.setValid(false);
        }
       
        //
        // Create a new token (if requested)
        //
        TokenProviderResponse tokenProviderResponse = null;
        String tokenType = tokenRequirements.getTokenType();
        if (tokenResponse.isValid() && !STSConstants.STATUS.equals(tokenType)) {
            TokenProviderParameters providerParameters =
                 createTokenProviderParameters(requestParser, context);
           
            // Map the principal (if it exists)
            Principal responsePrincipal = tokenResponse.getPrincipal();
            if (responsePrincipal != null) {
                String targetRealm = providerParameters.getRealm();
                String sourceRealm = tokenResponse.getTokenRealm();
                IdentityMapper identityMapper = stsProperties.getIdentityMapper();
                if (sourceRealm != null && !sourceRealm.equals(targetRealm) && identityMapper != null) {
                    Principal targetPrincipal =
                        identityMapper.mapPrincipal(sourceRealm, responsePrincipal, targetRealm);
                    providerParameters.setPrincipal(targetPrincipal);
                } else {
                    providerParameters.setPrincipal(responsePrincipal);
                }
            }
           
            Map<String, Object> additionalProperties = tokenResponse.getAdditionalProperties();
            if (additionalProperties != null) {
                providerParameters.setAdditionalProperties(additionalProperties);
            }
            String realm = providerParameters.getRealm();
            for (TokenProvider tokenProvider : tokenProviders) {
                if (tokenProvider.canHandleToken(tokenType, realm)) {
                    try {
                        tokenProviderResponse = tokenProvider.createToken(providerParameters);
                    } catch (STSException ex) {
                        LOG.log(Level.WARNING, "", ex);
                        throw ex;
                    } catch (RuntimeException ex) {
                        LOG.log(Level.WARNING, "", ex);
                        throw new STSException(
                            "Error in providing a token", ex, STSException.REQUEST_FAILED
                        );
                    }
                    break;
                }
            }
            if (tokenProviderResponse == null || tokenProviderResponse.getToken() == null) {
                LOG.fine("No Token Provider has been found that can handle this token");
                throw new STSException(
                    "No token provider found for requested token type: " + tokenType,
                    STSException.REQUEST_FAILED
                );
            }
        }
       
        // prepare response
        try {
            return createResponse(tokenResponse, tokenProviderResponse, tokenRequirements);
        } catch (Throwable ex) {
            LOG.log(Level.WARNING, "", ex);
            throw new STSException("Error in creating the response", ex, STSException.REQUEST_FAILED);
        }
    }
View Full Code Here

            String ldapAttribute = getClaimsLdapAttributeMapping().get(claimType.toString());
            String claimValue = ldapAttributes.get(ldapAttribute);
            if (claimValue == null) {
                if (!claim.isOptional()) {
                    LOG.warning("Mandatory claim not found in LDAP: " + claim.getClaimType());
                    throw new STSException("Mandatory claim '" + claim.getClaimType() + "' not found");
                } else {
                    LOG.fine("Claim '" + claim.getClaimType() + "' is null");
                }
            } else {
                Claim c = new Claim();
View Full Code Here

            }
       
            if (unhandledClaimTypes.size() > 0) {
                LOG.log(Level.WARNING, "The requested claim " + unhandledClaimTypes.toString()
                         + " cannot be fulfilled by the STS.");
                throw new STSException(
                    "The requested claim " + unhandledClaimTypes.toString()
                    + " cannot be fulfilled by the STS."
                );
            }
        }
       
        providerParameters.setClaimsManager(claimsManager);
       
        // create token
        TokenRequirements tokenRequirements = requestParser.getTokenRequirements();
        String tokenType = tokenRequirements.getTokenType();
        TokenProviderResponse tokenResponse = null;
        String realm = providerParameters.getRealm();
        for (TokenProvider tokenProvider : tokenProviders) {
            if (tokenProvider.canHandleToken(tokenType, realm)) {
                try {
                    tokenResponse = tokenProvider.createToken(providerParameters);
                } catch (STSException ex) {
                    LOG.log(Level.WARNING, "", ex);
                    throw ex;
                } catch (RuntimeException ex) {
                    LOG.log(Level.WARNING, "", ex);
                    throw new STSException("Error in providing a token", ex, STSException.REQUEST_FAILED);
                }
                break;
            }
        }
        if (tokenResponse == null || tokenResponse.getToken() == null) {
            LOG.log(Level.WARNING, "No token provider found for requested token type: " + tokenType);
            throw new STSException(
                "No token provider found for requested token type: " + tokenType,
                STSException.REQUEST_FAILED
            );
        }
        // prepare response
        try {
            KeyRequirements keyRequirements = requestParser.getKeyRequirements();
            EncryptionProperties encryptionProperties = providerParameters.getEncryptionProperties();
            RequestSecurityTokenResponseType response =
                createResponse(
                    encryptionProperties, tokenResponse, tokenRequirements, keyRequirements, context
                );
            return response;
        } catch (Throwable ex) {
            LOG.log(Level.WARNING, "", ex);
            throw new STSException("Error in creating the response", ex, STSException.REQUEST_FAILED);
        }
    }
View Full Code Here

    protected RequestParser parseRequest(
        RequestSecurityTokenType request,
        WebServiceContext context
    ) {
        if (context == null || context.getMessageContext() == null) {
            throw new STSException("No message context found");
        }
       
        if (stsProperties == null) {
            throw new STSException("No STSProperties object found");
        }
        stsProperties.configureProperties();
       
        RequestParser requestParser = new RequestParser();
        requestParser.parseRequest(request, context, stsProperties, claimsManager.getClaimParsers());
View Full Code Here

TOP

Related Classes of org.apache.cxf.ws.security.sts.provider.STSException

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.