protected void trace(MessageContext msgContext) { if (logger.isTraceEnabled()) { if (msgContext instanceof SOAPMessageContext) { SOAPMessageContext soapMessageContext = (SOAPMessageContext) msgContext; logger.trace("WSDL_PORT=" + soapMessageContext.get(SOAPMessageContext.WSDL_PORT)); logger.trace("WSDL_OPERATION=" + soapMessageContext.get(SOAPMessageContext.WSDL_OPERATION)); logger.trace("WSDL_INTERFACE=" + soapMessageContext.get(SOAPMessageContext.WSDL_INTERFACE)); logger.trace("WSDL_SERVICE=" + soapMessageContext.get(SOAPMessageContext.WSDL_SERVICE)); } } }
public IssuerInfoHolder(NameIDType issuer) { if (issuer == null) throw logger.nullArgumentError("issuer"); this.issuer = issuer; }
/** * Once the {@code KeyProviderType} is derived, get the {@code TrustKeyManager} * * @param keyProvider * * @return */ public static TrustKeyManager getTrustKeyManager(KeyProviderType keyProvider) { TrustKeyManager trustKeyManager = null; try { String keyManagerClassName = keyProvider.getClassName(); if (keyManagerClassName == null) throw logger.nullValueError("KeyManager class name"); Class<?> clazz = SecurityActions.loadClass(CoreConfigUtil.class, keyManagerClassName); if (clazz == null) throw logger.classNotLoadedError(keyManagerClassName); trustKeyManager = (TrustKeyManager) clazz.newInstance(); } catch (Exception e) { logger.trustKeyManagerCreationError(e); } return trustKeyManager; }
public static SAML2HandlerChain createChain(String fqn) throws ProcessingException { if (fqn == null) throw logger.nullArgumentError("fqn"); Class<?> clazz = SecurityActions.loadClass(SAML2HandlerChainFactory.class, fqn); if (clazz == null) throw logger.classNotLoadedError(fqn); try { return (SAML2HandlerChain) clazz.newInstance(); } catch (Exception e) { throw logger.couldNotCreateInstance(fqn, e); } } }
public InputStream getByteStream() { URL url = SecurityActions.loadResource(getClass(), loc); InputStream is; try { is = url.openStream(); } catch (IOException e) { throw new RuntimeException(logger.classNotLoadedError(loc)); } if (is == null) throw logger.nullValueError("inputstream is null for " + loc); return is; }
is = new FileInputStream(this.configFile); } catch (FileNotFoundException e) { throw logger.samlIDPConfigurationError(e); spConfiguration = configProvider.getSPConfiguration(); } catch (ProcessingException e) { throw logger.samlSPConfigurationError(e); } catch (ParsingException e) { throw logger.samlSPConfigurationError(e); spConfiguration = (SPType) picketLinkConfiguration.getIdpOrSP(); } catch (ParsingException e) { logger.trace(e); throw logger.samlSPConfigurationError(e); throw logger.configurationFileMissing(configFile); spConfiguration = ConfigurationUtil.getSPConfiguration(is); this.canonicalizationMethod = spConfiguration.getCanonicalizationMethod(); logger.samlSPSettingCanonicalizationMethod(canonicalizationMethod); XMLSignatureUtil.setCanonicalizationMethodType(canonicalizationMethod); logger.trace("Identity Provider URL=" + this.identityURL); } catch (Exception e) { throw new RuntimeException(e);
protected void initKeyManager() { if (this.idpConfiguration.isSupportsSignature() || this.idpConfiguration.isEncrypt()) { KeyProviderType keyProvider = this.idpConfiguration.getKeyProvider(); if (keyProvider == null) throw new RuntimeException( logger.nullValueError("Key Provider is null for context=" + servletContext.getContextPath())); //$NON-NLS-1$ try { this.keyManager = CoreConfigUtil.getTrustKeyManager(keyProvider); List<AuthPropertyType> authProperties = CoreConfigUtil.getKeyProviderProperties(keyProvider); keyManager.setAuthProperties(authProperties); keyManager.setValidatingAlias(keyProvider.getValidatingAlias()); } catch (Exception e) { logger.trustKeyManagerCreationError(e); throw new RuntimeException(e.getLocalizedMessage()); } logger.samlIDPSettingCanonicalizationMethod(idpConfiguration.getCanonicalizationMethod()); XMLSignatureUtil.setCanonicalizationMethodType(idpConfiguration.getCanonicalizationMethod()); logger.trace("Key Provider=" + keyProvider.getClassName()); //$NON-NLS-1$ } }
is = new FileInputStream(this.configFile); } catch (FileNotFoundException e) { throw logger.samlIDPConfigurationError(e); idpConfiguration = configProvider.getIDPConfiguration(); } catch (ProcessingException e) { throw logger.samlIDPConfigurationError(e); } catch (ParsingException e) { throw logger.samlIDPConfigurationError(e); idpConfiguration = (IDPType) picketLinkConfiguration.getIdpOrSP(); } catch (ParsingException e) { logger.trace(e); logger.samlIDPConfigurationError(e); throw logger.configurationFileMissing(DEPRECATED_CONFIG_FILE_LOCATION); try { idpConfiguration = ConfigurationUtil.getIDPConfiguration(is); } catch (ParsingException e) { logger.samlIDPConfigurationError(e); logger.trace("Identity Provider URL=" + getIdentityURL()); //$NON-NLS-1$ Class<?> clazz = SecurityActions.loadClass(getClass(), attributeManager); if (clazz == null) throw new RuntimeException(logger.classNotLoadedError(attributeManager)); AttributeManager delegate = (AttributeManager) clazz.newInstance(); this.attribManager.setDelegate(delegate);
this.rawOptions.putAll(options); if (logger.isTraceEnabled()) { logger.trace(options.toString()); throw logger.optionNotSet(SecurityConstants.SECURITY_DOMAIN_OPTION); logger.error(ErrorCodes.LOCAL_VALIDATION_SEC_DOMAIN_MUST_BE_SPECIFIED); throw logger.optionNotSet("localValidationSecurityDomain");
public void sessionDestroyed(HttpSessionEvent se) { HttpSession httpSession = se.getSession(); if (httpSession == null) throw logger.nullArgumentError("session"); AssertionType assertion = (AssertionType) httpSession.getAttribute(GeneralConstants.ASSERTION); // If the user had logged out, then the assertion would not be available in the session. // The case when the user closes the browser and does not logout, the session will time out on the // server. So we know that the token has not been canceled by the STS. if (assertion != null) { logger.trace("User has closed the browser. So we proceed to cancel the STS issued token."); PicketLinkCoreSTS sts = PicketLinkCoreSTS.instance(); SAMLProtocolContext samlProtocolContext = new SAMLProtocolContext(); samlProtocolContext.setIssuedAssertion(assertion); try { sts.cancelToken(samlProtocolContext); } catch (ProcessingException e) { logger.error(e); } httpSession.removeAttribute(GeneralConstants.ASSERTION); } } }
int keySize, QName wrappingElementQName, boolean addEncryptedKeyInKeyInfo) throws ProcessingException { if (elementQName == null) throw logger.nullArgumentError("elementQName"); if (document == null) throw logger.nullArgumentError("document"); String wrappingElementPrefix = wrappingElementQName.getPrefix(); if (wrappingElementPrefix == null || wrappingElementPrefix == "") throw logger.wrongTypeError("Wrapping element prefix invalid"); throw logger.domMissingDocElementError(elementQName.toString()); cipher.init(XMLCipher.ENCRYPT_MODE, secretKey); } catch (XMLEncryptionException e1) { throw logger.processingError(e1); encryptedDoc = cipher.doFinal(document, documentElement); } catch (Exception e) { throw logger.processingError(e); throw logger.domMissingElementError("xenc:EncryptedData"); Element encryptedDataElement = (Element) cipherElements.item(0); throw logger.domMissingElementError("xenc:CipherData"); Element cipherDataElement = (Element) nodeList.item(0); Node cipherParent = cipherDataElement.getParentNode();
logger.trustKeyManagerCreationError(e); throw new RuntimeException(e.getLocalizedMessage()); logger.trace("Key Provider=" + keyProvider.getClassName());
@Override protected boolean handleInbound(MessageContext msgContext) { String username = getUserPrincipalName(msgContext); SOAPMessage sm = ((SOAPMessageContext) msgContext).getMessage(); SOAPEnvelope envelope; try { envelope = sm.getSOAPPart().getEnvelope(); SOAPBodyElement rst = (SOAPBodyElement) Util .findElement(envelope, new QName(WSTrustConstants.BASE_NAMESPACE, WSTrustConstants.RST)); if (rst != null) { rst.addChildElement(createUsernameToken(username)); } } catch (SOAPException e) { logger.jbossWSUnableToCreateBinaryToken(e); } if (logger.isTraceEnabled()) { logger.trace("SOAPMessage(SamlRequestSecurityTokenHandler)=" + SOAPUtil.soapMessageAsString(sm)); } return true; }
private InputStream parseSAMLRequestPostBinding(String samlMessage) { InputStream is; byte[] samlBytes = SamlPostBindingUtil.base64Decode(samlMessage); logger.trace("SAML Request Document: " + new String(samlBytes)); //$NON-NLS-1$ is = new ByteArrayInputStream(samlBytes); return is; }
String wrappingElementPrefix = wrappingElementQName.getPrefix(); if (wrappingElementPrefix == null || wrappingElementPrefix == "") throw logger.wrongTypeError("Wrapping element prefix invalid"); cipher.init(XMLCipher.ENCRYPT_MODE, secretKey); } catch (XMLEncryptionException e1) { throw logger.configurationError(e1); encryptedDoc = cipher.doFinal(document, document.getDocumentElement()); } catch (Exception e) { throw logger.processingError(e); throw logger.domMissingElementError("xenc:CipherData");
public Source invoke(Source request) { try { Document doc = (Document) DocumentUtil.getNodeFromSource(request); if (logger.isTraceEnabled()) { logger.trace("XACML Received Message: " + DocumentUtil.asString(doc)); } XACMLAuthzDecisionQueryType xacmlQuery = SOAPSAMLXACMLUtil.getXACMLQueryType(doc); ResponseType samlResponseType = SOAPSAMLXACMLUtil.handleXACMLQuery(pdp, issuer, xacmlQuery); ByteArrayOutputStream baos = new ByteArrayOutputStream(); XMLStreamWriter xmlStreamWriter = StaxUtil.getXMLStreamWriter(baos); SAMLResponseWriter samlResponseWriter = new SAMLResponseWriter(xmlStreamWriter); samlResponseWriter.write(samlResponseType); Document responseDocument = DocumentUtil.getDocument(new ByteArrayInputStream(baos.toByteArray())); return new DOMSource(responseDocument.getDocumentElement()); } catch (Exception e) { throw logger.xacmlPDPMessageProcessingError(e); } }
@Override protected boolean handleInbound(MessageContext msgContext) { logger.trace("Handling Inbound Message"); authenticationManager = getAuthenticationManager(msgContext); } catch (ConfigurationException e) { logger.authenticationManagerError(e); throw new RuntimeException(e); logger.error(msg); SecurityException e = new SecurityException(msg); throw new RuntimeException(e); logger.trace("Successfully Authenticated:Principal = " + principal + " ::subject = " + subject);
protected InputStream getWSSE(ServletContext context) { if (context == null) { throw logger.nullValueError("Servlet Context"); } InputStream is = context.getResourceAsStream("/WEB-INF/jboss-wsse.xml"); return is; }
@Override public void transform(Source xmlSource, Result outputTarget) throws TransformerException { if (!(xmlSource instanceof StAXSource)) throw logger.wrongTypeError("xmlSource should be a stax source"); if (outputTarget instanceof DOMResult == false) throw logger.wrongTypeError("outputTarget should be a dom result"); XMLEventReader xmlEventReader = staxSource.getXMLEventReader(); if (xmlEventReader == null) throw new TransformerException(logger.nullValueError("XMLEventReader"));