Refine search
public SamlCredential(final String assertion) { if (StringUtil.isNullOrEmpty(assertion)) throw logger.nullArgumentError("assertion"); this.assertion = assertion; }
/** * Verify whether a {@link HttpServletRequest} is for Local Logout * @param request * @return */ public boolean isLocalLogoutRequest(HttpServletRequest request){ String lloStr = request.getParameter(GeneralConstants.LOCAL_LOGOUT); return isNotNull(lloStr) && "true".equalsIgnoreCase(lloStr); }
private void processIdPMetadata(SPType spConfiguration) { IDPSSODescriptorType idpssoDescriptorType = null; if (isNotNull(spConfiguration.getIdpMetadataFile())) { idpssoDescriptorType = getIdpMetadataFromFile(spConfiguration); } else { idpssoDescriptorType = getIdpMetadataFromProvider(spConfiguration); } if (idpssoDescriptorType != null) { List<EndpointType> endpoints = idpssoDescriptorType.getSingleSignOnService(); for (EndpointType endpoint : endpoints) { String endpointBinding = endpoint.getBinding().toString(); if (endpointBinding.contains("HTTP-POST")) { endpointBinding = "POST"; } else if (endpointBinding.contains("HTTP-Redirect")) { endpointBinding = "REDIRECT"; } if (spConfiguration.getBindingType().equals(endpointBinding)) { spConfiguration.setIdentityURL(endpoint.getLocation().toString()); break; } } this.idpMetadata = idpssoDescriptorType; } }
public void writeAttributeTypeWithoutRootTag(SAML11AttributeType attributeType) throws ProcessingException { String attributeName = attributeType.getAttributeName(); if (StringUtil.isNullOrEmpty(attributeName)) throw logger.writerNullValueError("attribute name"); StaxUtil.writeAttribute(writer, SAML11Constants.ATTRIBUTE_NAME, attributeName); String attributeNamespace = attributeType.getAttributeNamespace().toString(); if (StringUtil.isNullOrEmpty(attributeNamespace)) throw logger.writerNullValueError("attribute namespace"); StaxUtil.writeAttribute(writer, SAML11Constants.ATTRIBUTE_NAMESPACE, attributeNamespace); List<Object> attributeValues = attributeType.get(); if (attributeValues != null) { for (Object attributeValue : attributeValues) { if (attributeValue instanceof String) { writeStringAttributeValue((String) attributeValue); } else throw logger.writerUnsupportedAttributeValueError(attributeValue.getClass().getName()); } } }
private LogoutRequestType createLogoutRequest(SAML2HandlerRequest request, String participant) throws ConfigurationException, ProcessingException { HTTPContext httpContext = (HTTPContext) request.getContext(); HttpServletRequest httpServletRequest = httpContext.getRequest(); LogoutRequestType lort = new SAML2Request().createLogoutRequest(request.getIssuer().getValue()); Principal userPrincipal = httpServletRequest.getUserPrincipal(); if (userPrincipal == null) { throw logger.samlHandlerPrincipalNotFoundError(); } NameIDType nameID = new NameIDType(); nameID.setValue(userPrincipal.getName()); //Deal with NameID Format String nameIDFormat = (String) handlerConfig.getParameter(GeneralConstants.NAMEID_FORMAT); if (StringUtil.isNullOrEmpty(nameIDFormat)) { nameIDFormat = JBossSAMLURIConstants.NAMEID_FORMAT_PERSISTENT.get(); } nameID.setFormat(URI.create(nameIDFormat)); lort.setNameID(nameID); long assertionValidity = PicketLinkCoreSTS.instance().getConfiguration().getIssuedTokenTimeout(); lort.setNotOnOrAfter(XMLTimeUtil.add(lort.getIssueInstant(), assertionValidity)); lort.setDestination(URI.create(participant)); return lort; }
StaxUtil.writeAttribute(writer, JBossSAMLConstants.DESTINATION.get(), destination.toASCIIString()); if (StringUtil.isNotNull(consent)) StaxUtil.writeAttribute(writer, JBossSAMLConstants.CONSENT.get(), consent); write(issuer, new QName(ASSERTION_NSURI.get(), JBossSAMLConstants.ISSUER.get(), ASSERTION_PREFIX)); if (StringUtil.isNotNull(artifact)) { StaxUtil.writeStartElement(writer, PROTOCOL_PREFIX, JBossSAMLConstants.ARTIFACT.get(), PROTOCOL_NSURI.get()); StaxUtil.writeCharacters(writer, artifact);
StaxUtil.writeStartElement(writer, tag.getPrefix(), tag.getLocalPart(), tag.getNamespaceURI()); StaxUtil.writeAttribute(writer, JBossSAMLConstants.FORMAT.get(), format.toASCIIString()); if (StringUtil.isNotNull(spProvidedID)) { StaxUtil.writeAttribute(writer, JBossSAMLConstants.SP_PROVIDED_ID.get(), spProvidedID); if (StringUtil.isNotNull(spNameQualifier)) { StaxUtil.writeAttribute(writer, JBossSAMLConstants.SP_NAME_QUALIFIER.get(), spNameQualifier); if (StringUtil.isNotNull(nameQualifier)) { StaxUtil.writeAttribute(writer, JBossSAMLConstants.NAME_QUALIFIER.get(), nameQualifier); if (StringUtil.isNotNull(value)) { StaxUtil.writeCharacters(writer, value);
if (StringUtil.isNotNull(secRef.getId())) { QName wsuIDQName = new QName(WSU_NS, ID, WSU_PREFIX); StaxUtil.writeNameSpace(writer, WSU_PREFIX, WSU_NS); StaxUtil.writeAttribute(writer, wsuIDQName, secRef.getId()); QName key = entry.getKey(); if (!usedNamespaces.contains(key.getNamespaceURI())) { StaxUtil.writeNameSpace(this.writer, key.getPrefix(), key.getNamespaceURI()); usedNamespaces.add(key.getNamespaceURI());
/** * <p> * Initializes the {@link org.picketlink.identity.federation.web.core.IdentityServer}. * </p> */ protected void initIdentityServer() { // The Identity Server on the servlet context gets set // in the implementation of IdentityServer // Create an Identity Server and set it on the context IdentityServer identityServer = (IdentityServer) servletContext.getAttribute( GeneralConstants.IDENTITY_SERVER); if (identityServer == null) { identityServer = new IdentityServer(); servletContext.setAttribute(GeneralConstants.IDENTITY_SERVER, identityServer); if (StringUtil.isNotNull(this.idpConfiguration.getIdentityParticipantStack())) { try { Class<?> clazz = SecurityActions.loadClass(getClass(), this.idpConfiguration.getIdentityParticipantStack()); if (clazz == null) throw logger.classNotLoadedError(this.idpConfiguration.getIdentityParticipantStack()); identityServer.setStack((IdentityParticipantStack) clazz.newInstance()); } catch (Exception e) { logger.samlIDPUnableToSetParticipantStackUsingDefault(e); } } } }
public void write(UsernameTokenType usernameToken) throws ProcessingException { StaxUtil.writeStartElement(writer, WSSE_PREFIX, USERNAME_TOKEN, WSSE_NS); StaxUtil.writeNameSpace(writer, WSSE_PREFIX, WSSE_NS); String id = usernameToken.getId(); if (StringUtil.isNullOrEmpty(id)) throw logger.nullValueError("Id on the UsernameToken"); QName wsuIDQName = new QName(WSU_NS, ID, WSU_PREFIX); StaxUtil.writeNameSpace(writer, WSU_PREFIX, WSU_NS); StaxUtil.writeAttribute(writer, wsuIDQName, id); AttributedString userNameAttr = usernameToken.getUsername(); if (userNameAttr == null) throw logger.nullValueError("User Name is null on the UsernameToken"); StaxUtil.writeStartElement(writer, WSSE_PREFIX, USERNAME, WSSE_NS); StaxUtil.writeCharacters(writer, userNameAttr.getValue()); StaxUtil.writeEndElement(writer); StaxUtil.writeEndElement(writer); StaxUtil.flush(writer); }
/** * Parse a space delimited list of strings * * @param startElement * * @return */ public static List<String> parseProtocolEnumeration(StartElement startElement) { List<String> protocolEnum = new ArrayList<String>(); Attribute proto = startElement.getAttributeByName(new QName(JBossSAMLConstants.PROTOCOL_SUPPORT_ENUMERATION.get())); String val = StaxParserUtil.getAttributeValue(proto); if (StringUtil.isNotNull(val)) { StringTokenizer st = new StringTokenizer(val); while (st.hasMoreTokens()) { protocolEnum.add(st.nextToken()); } } return protocolEnum; } }
QName attributeQName = new QName("", PROPERTY_NAME_ATTRIBUTE); Attribute attribute = startElement.getAttributeByName(attributeQName); if (attribute != null) propertyValue = chars.getData(); if (propertyValue != null) { propertyValue = StringUtil.getSystemPropertyAsString(((String)propertyValue).trim());
/** * Write a {@code NameIDPolicyType} to stream * * @param nameIDPolicy * * @throws ProcessingException */ public void write(NameIDPolicyType nameIDPolicy) throws ProcessingException { StaxUtil.writeStartElement(writer, PROTOCOL_PREFIX, JBossSAMLConstants.NAMEID_POLICY.get(), PROTOCOL_NSURI.get()); URI format = nameIDPolicy.getFormat(); if (format != null) { StaxUtil.writeAttribute(writer, JBossSAMLConstants.FORMAT.get(), format.toASCIIString()); } String spNameQualifier = nameIDPolicy.getSPNameQualifier(); if (StringUtil.isNotNull(spNameQualifier)) { StaxUtil.writeAttribute(writer, JBossSAMLConstants.SP_NAME_QUALIFIER.get(), spNameQualifier); } Boolean allowCreate = nameIDPolicy.isAllowCreate(); if (allowCreate != null) { StaxUtil.writeAttribute(writer, JBossSAMLConstants.ALLOW_CREATE.get(), allowCreate.toString()); } StaxUtil.writeEndElement(writer); StaxUtil.flush(writer); }
protected void initializeHandlerChain(PicketLinkType picketLinkType) throws Exception { SAML2HandlerChain handlerChain; // Get the chain from config if (isNullOrEmpty(samlHandlerChainClass)) { handlerChain = SAML2HandlerChainFactory.createChain(); } else { try { handlerChain = SAML2HandlerChainFactory.createChain(this.samlHandlerChainClass); } catch (ProcessingException e1) { throw new RuntimeException(e1); } } Handlers handlers = picketLinkType.getHandlers(); if (handlers == null) { // Get the handlers String handlerConfigFileName = GeneralConstants.HANDLER_CONFIG_FILE_LOCATION; handlers = ConfigurationUtil.getHandlers(servletContext.getResourceAsStream(handlerConfigFileName)); } picketLinkType.setHandlers(handlers); handlerChain.addAll(HandlerUtil.getHandlers(handlers)); populateChainConfig(picketLinkType); SAML2HandlerChainConfig handlerChainConfig = new DefaultSAML2HandlerChainConfig(chainConfigOptions); Set<SAML2Handler> samlHandlers = handlerChain.handlers(); for (SAML2Handler handler : samlHandlers) { handler.initChainConfig(handlerChainConfig); } chain = handlerChain; }
} catch (NamingException e) { InputStream is = servletContext.getResourceAsStream("/WEB-INF/jboss-web.xml"); if (is != null) { try { if (StringUtil.isNotNull(secDomain)) return secDomain;
this.wspAppliesTo = properties.getProperty(WSP_APPLIES_TO); String batchStr = properties.getProperty(IS_BATCH); this.isBatch = StringUtil.isNotNull(batchStr) ? Boolean.parseBoolean(batchStr) : false; this.requestType = properties.getProperty(REQUEST_TYPE); if (!StringUtil.isNullOrEmpty(properties.getProperty(SOAP_BINDING))) { this.soapBinding = properties.getProperty(SOAP_BINDING); .parseInt(properties.getProperty(PicketLinkFederationConstants.ITERATION_COUNT)); try { this.password = StringUtil.decode(password, salt, iterationCount); } catch (Exception e) { throw logger.unableToDecodePasswordError(this.password);
if (StringUtil.isNullOrEmpty(salt)) throw logger.optionNotSet("Salt"); if (StringUtil.isNullOrEmpty(iCount)) throw logger.optionNotSet("Iteration Count"); builder.password(StringUtil.decode(passwordString, salt, iterationCount)); } catch (Exception e) { throw logger.unableToDecodePasswordError("Unable to decode password:" + passwordString);
@Override public void init(ServletConfig config) throws ServletException { super.init(config); String cstr = config.getInitParameter("configProvider"); if (isNotNull(cstr)) { try { configProvider = (IMetadataConfigurationStore) SecurityActions.loadClass(getClass(), cstr).newInstance(); } catch (Exception e) { throw new ServletException(e); } } }
public void setReturnURL(String returnURL) { this.returnURL = StringUtil.getSystemPropertyAsString(returnURL); }