org.wso2.carbon.identity.base.IdentityConstants Java Examples

The following examples show how to use org.wso2.carbon.identity.base.IdentityConstants. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SAMLSSOServiceProviderDO.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
public SAMLSSOServiceProviderDO() {
    if (StringUtils.isNotBlank(IdentityUtil.getProperty(IdentityConstants.ServerConfig
            .SSO_DEFAULT_SIGNING_ALGORITHM))) {
        signingAlgorithmUri = IdentityUtil.getProperty(IdentityConstants.ServerConfig
                .SSO_DEFAULT_SIGNING_ALGORITHM).trim();
    } else {
        signingAlgorithmUri = IdentityCoreConstants.XML_SIGNATURE_ALGORITHM_RSA_SHA1_URI;
    }
    if (StringUtils.isNotBlank(IdentityUtil.getProperty(IdentityConstants.ServerConfig
            .SSO_DEFAULT_DIGEST_ALGORITHM))) {
        digestAlgorithmUri = IdentityUtil.getProperty(IdentityConstants.ServerConfig
                .SSO_DEFAULT_DIGEST_ALGORITHM).trim();
    } else {
        digestAlgorithmUri = IdentityCoreConstants.XML_DIGEST_ALGORITHM_SHA1;
    }
}
 
Example #2
Source File: EntitlementEngine.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
/**
 * Evaluates the given XACML request and returns the Response
 *
 * @param requestCtx Balana Object model for request
 * @param xacmlRequest Balana Object model for request
 * @return ResponseCtx  Balana Object model for response
 */
public ResponseCtx evaluate(AbstractRequestCtx requestCtx, String xacmlRequest) {

    if (log.isDebugEnabled() && IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.XACML_REQUEST)) {
        log.debug("XACML Request : " + xacmlRequest);
    }

    ResponseCtx xacmlResponse;

    if ((xacmlResponse = (ResponseCtx) getFromCache(xacmlRequest, false)) != null) {
        if (log.isDebugEnabled() && IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.XACML_RESPONSE)) {
            log.debug("XACML Response : " + xacmlResponse);
        }
        return xacmlResponse;
    }

    xacmlResponse = pdp.evaluate(requestCtx);

    addToCache(xacmlRequest, xacmlResponse, false);

    if (log.isDebugEnabled() && IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.XACML_RESPONSE)) {
        log.debug("XACML Response : " + xacmlResponse);
    }
    return xacmlResponse;
}
 
Example #3
Source File: IdentityProviderUtil.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
public static OMElement createDisplayClaim(OMElement parent, String displayTag,
                                           String displayValue, String uri) {
    OMElement claimElem = createOMElement(parent, IdentityConstants.NS,
                                          IdentityConstants.LocalNames.DISPLAY_CLAIM, IdentityConstants.PREFIX);

    claimElem.addAttribute("Uri", uri, null);

    OMElement tagElem = createOMElement(claimElem, IdentityConstants.NS,
                                        IdentityConstants.LocalNames.DISPLAY_TAG, IdentityConstants.PREFIX);
    tagElem.setText(displayTag);

    OMElement valElem = createOMElement(claimElem, IdentityConstants.NS,
                                        IdentityConstants.LocalNames.DISPLAY_VALUE, IdentityConstants.PREFIX);
    valElem.setText(displayValue);

    return claimElem;
}
 
Example #4
Source File: UserProfileAdmin.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * @return
 * @throws UserStoreException
 */
private Claim[] getAllSupportedClaims(UserRealm realm, String dialectUri)
        throws org.wso2.carbon.user.api.UserStoreException {
    ClaimMapping[] claims = null;
    List<Claim> reqClaims = null;

    claims = realm.getClaimManager().getAllSupportClaimMappingsByDefault();
    reqClaims = new ArrayList<Claim>();
    for (int i = 0; i < claims.length; i++) {
        if (dialectUri.equals(claims[i].getClaim().getDialectURI()) && (claims[i] != null && claims[i].getClaim().getDisplayTag() != null
                && !claims[i].getClaim().getClaimUri().equals(IdentityConstants.CLAIM_PPID))) {

            reqClaims.add((Claim) claims[i].getClaim());
        }
    }

    return reqClaims.toArray(new Claim[reqClaims.size()]);
}
 
Example #5
Source File: DefaultServiceURLBuilderTest.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
@BeforeMethod
public void setUp() throws Exception {

    mockStatic(CarbonUtils.class);
    mockStatic(ServerConfiguration.class);
    mockStatic(NetworkUtils.class);
    mockStatic(IdentityCoreServiceComponent.class);
    mockStatic(IdentityTenantUtil.class);
    mockStatic(PrivilegedCarbonContext.class);
    PrivilegedCarbonContext privilegedCarbonContext = mock(PrivilegedCarbonContext.class);

    when(PrivilegedCarbonContext.getThreadLocalCarbonContext()).thenReturn(privilegedCarbonContext);
    when(ServerConfiguration.getInstance()).thenReturn(mockServerConfiguration);
    when(IdentityCoreServiceComponent.getConfigurationContextService()).thenReturn(mockConfigurationContextService);
    when(mockConfigurationContextService.getServerConfigContext()).thenReturn(mockConfigurationContext);
    when(mockConfigurationContext.getAxisConfiguration()).thenReturn(mockAxisConfiguration);
    try {
        when(NetworkUtils.getLocalHostname()).thenReturn("localhost");
    } catch (SocketException e) {
        // Mock behaviour, hence ignored
    }

    System.setProperty(IdentityConstants.CarbonPlaceholders.CARBON_PORT_HTTP_PROPERTY, "9763");
    System.setProperty(IdentityConstants.CarbonPlaceholders.CARBON_PORT_HTTPS_PROPERTY, "9443");
}
 
Example #6
Source File: OpenIDProvider.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * Configure the OpenID Provider's end-point URL
 */
private OpenIDProvider() {
    // This is the OpenID provider server URL
    opAddress = OpenIDUtil.getOpenIDServerURL();
    // The URL which accepts OpenID Authentication requests, obtained by
    // performing discovery on the the User-Supplied Identifier. This value
    // must be an absolute URL
    manager.setOPEndpointUrl(opAddress);

    // default association expiry time is set to 15 minutes
    int assocExpiryTime = 15;
    String expiryTime = IdentityUtil.getProperty(IdentityConstants.ServerConfig.OPENID_ASSOCIATION_EXPIRY_TIME);
    if (expiryTime != null && !expiryTime.trim().isEmpty()) {
        try {
            assocExpiryTime = Integer.parseInt(expiryTime);
        } catch (NumberFormatException e) {
            log.warn("Error while setting association expiry time as " + expiryTime
                    +  ". Setting association expiry time to default ("+assocExpiryTime+")", e);
        }
    }
    manager.setExpireIn(assocExpiryTime);
}
 
Example #7
Source File: OpenIDRememberMeTokenManager.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * Checks if the rememberMe token is expired
 *
 * @param storedDo
 * @return
 */
private boolean isExpired(OpenIDRememberMeDO storedDo) {
    Timestamp timestamp = storedDo.getTimestamp();
    String expiry = IdentityUtil.getProperty(IdentityConstants.ServerConfig.OPENID_REMEMBER_ME_EXPIRY);
    if (timestamp != null && expiry != null) {
        long t0 = timestamp.getTime();
        long t1 = new Date().getTime();
        long delta = Long.parseLong(expiry) * 1000 * 60;

        if (t1 - t0 > delta) {
            log.debug("Remember Me token expired for user " + storedDo.getUserName());
            return true;
        }
    }
    return false;
}
 
Example #8
Source File: IdentityProviderData.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
@Override
public String getTenantDomain() throws IdentityProviderException {
    if (this.authMechanism == IdentityConstants.AUTH_TYPE_SELF_ISSUED) { //only for tenant 0
        return null;
    }

    if (userIdentifier == null) {
        // auth type is not self issued and still the user identifier is null. 
        // this is a invalid case
        throw new IllegalStateException("User identifier must NOT be null");
    }

    String domain = null;
    domain = MultitenantUtils.getTenantDomain(userIdentifier);
    return domain;
}
 
Example #9
Source File: UserInformationRecoveryService.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * This returns the user supported claims.
 *
 * @param dialect
 * @return
 * @throws IdentityException
 */
public UserIdentityClaimDTO[] getUserIdentitySupportedClaims(String dialect)
        throws IdentityException {
    IdentityClaimManager claimManager = null;
    Claim[] claims = null;
    UserRealm realm = null;

    claimManager = IdentityClaimManager.getInstance();
    realm = IdentityTenantUtil.getRealm(null, null);
    claims = claimManager.getAllSupportedClaims(dialect, realm);

    if (claims == null || claims.length == 0) {
        log.warn("Could not find any matching claims for requested dialect : " + dialect);
        return new UserIdentityClaimDTO[0];
    }

    List<UserIdentityClaimDTO> claimList = new ArrayList<UserIdentityClaimDTO>();

    for (int i = 0; i < claims.length; i++) {
        if (claims[i].getDisplayTag() != null
                && !IdentityConstants.PPID_DISPLAY_VALUE.equals(claims[i].getDisplayTag())) {
            if (UserCoreConstants.ClaimTypeURIs.ACCOUNT_STATUS.equals(claims[i].getClaimUri())) {
                continue;
            }
            if (claims[i].isSupportedByDefault() && (!claims[i].isReadOnly())) {

                UserIdentityClaimDTO claimDto = new UserIdentityClaimDTO();
                claimDto.setClaimUri(claims[i].getClaimUri());
                claimDto.setClaimValue(claims[i].getValue());
                claimList.add(claimDto);
            }
        }
    }

    return claimList.toArray(new UserIdentityClaimDTO[claimList.size()]);
}
 
Example #10
Source File: IdentityLogTokenParser.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private IdentityLogTokenParser() {

        boolean readProperties = Boolean
                .valueOf(System.getProperty(IdentityConstants.IdentityTokens.READ_LOG_TOKEN_PROPERTIES));

        if (readProperties) {
            buildConfiguration();
        }
    }
 
Example #11
Source File: FacebookAuthenticator.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public void buildClaims(AuthenticationContext context, Map<String, Object> jsonObject)
        throws ApplicationAuthenticatorException {
    if (jsonObject != null) {
        Map<ClaimMapping, String> claims = new HashMap<ClaimMapping, String>();

        for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
            claims.put(ClaimMapping.build(entry.getKey(), entry.getKey(), null,
                    false), entry.getValue().toString());
            if (log.isDebugEnabled() &&
                    IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.USER_CLAIMS)) {
                log.debug("Adding claim mapping : " + entry.getKey() + " <> " + entry.getKey() + " : "
                        + entry.getValue());
            }

        }
        if (StringUtils.isBlank(context.getExternalIdP().getIdentityProvider().getClaimConfig().getUserClaimURI())) {
            context.getExternalIdP().getIdentityProvider().getClaimConfig().setUserClaimURI
                    (FacebookAuthenticatorConstants.EMAIL);
        }
        String subjectFromClaims = FrameworkUtils.getFederatedSubjectFromClaims(
                context.getExternalIdP().getIdentityProvider(), claims);
        if (subjectFromClaims != null && !subjectFromClaims.isEmpty()) {
            AuthenticatedUser authenticatedUser =
                    AuthenticatedUser.createFederateAuthenticatedUserFromSubjectIdentifier(subjectFromClaims);
            context.setSubject(authenticatedUser);
        } else {
            setSubject(context, jsonObject);
        }

        context.getSubject().setUserAttributes(claims);

    } else {
        if (log.isDebugEnabled()) {
            log.debug("Decoded json object is null");
        }
        throw new ApplicationAuthenticatorException("Decoded json object is null");
    }
}
 
Example #12
Source File: FacebookAuthenticator.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private Map<String, Object> getUserInfoJson(String fbAuthUserInfoUrl, String userInfoFields, String token)
        throws ApplicationAuthenticatorException {

    String userInfoString = getUserInfoString(fbAuthUserInfoUrl, userInfoFields, token);
    if (log.isDebugEnabled() && IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.USER_ID_TOKEN)) {
        log.debug("UserInfoString : " + userInfoString);
    }
    Map<String, Object> jsonObject = JSONUtils.parseJSON(userInfoString);
    return jsonObject;
}
 
Example #13
Source File: OpenIDConnectAuthenticator.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
protected void buildClaimMappings(Map<ClaimMapping, String> claims, Map.Entry<String, Object> entry, String
        separator) {
    String claimValue = null;
    if (StringUtils.isBlank(separator)) {
        separator = IdentityCoreConstants.MULTI_ATTRIBUTE_SEPARATOR_DEFAULT;
    }
    try {
        JSONArray jsonArray = (JSONArray) JSONValue.parseWithException(entry.getValue().toString());
        if (jsonArray != null && jsonArray.size() > 0) {
            Iterator attributeIterator = jsonArray.iterator();
            while (attributeIterator.hasNext()) {
                if (claimValue == null) {
                    claimValue = attributeIterator.next().toString();
                } else {
                    claimValue = claimValue + separator + attributeIterator.next().toString();
                }
            }

        }
    } catch (Exception e) {
        claimValue = entry.getValue().toString();
    }

    claims.put(ClaimMapping.build(entry.getKey(), entry.getKey(), null, false), claimValue);
    if (log.isDebugEnabled() && IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.USER_CLAIMS)) {
        log.debug("Adding claim mapping : " + entry.getKey() + " <> " + entry.getKey() + " : " + claimValue);
    }

}
 
Example #14
Source File: IdentityApplicationManagementUtil.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * @return the Digest Algorithm URI defined in configuration
 */
public static String getDigestAlgoURIByConfig() {
    if (StringUtils.isNotBlank(IdentityUtil.getProperty(IdentityConstants.ServerConfig
            .SSO_DEFAULT_DIGEST_ALGORITHM))) {
        return IdentityUtil.getProperty(IdentityConstants.ServerConfig.SSO_DEFAULT_DIGEST_ALGORITHM).trim();
    } else {
        return IdentityApplicationConstants.XML.DigestAlgorithmURI.SHA1;
    }
}
 
Example #15
Source File: IdentityApplicationManagementUtil.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * @return the Signing Algorithm URI defined in configuration
 */
public static String getSigningAlgoURIByConfig() {
    if (StringUtils.isNotBlank(IdentityUtil.getProperty(IdentityConstants.ServerConfig
            .SSO_DEFAULT_SIGNING_ALGORITHM))) {
        return IdentityUtil.getProperty(IdentityConstants.ServerConfig.SSO_DEFAULT_SIGNING_ALGORITHM).trim();
    } else {
        return IdentityApplicationConstants.XML.SignatureAlgorithmURI.RSA_SHA1;
    }
}
 
Example #16
Source File: SAMLSSOProviderServlet.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private String getACSUrlWithTenantPartitioning(String acsUrl, String tenantDomain) {
    String acsUrlWithTenantDomain = acsUrl;
    if (tenantDomain != null && "true".equals(IdentityUtil.getProperty(
            IdentityConstants.ServerConfig.SSO_TENANT_PARTITIONING_ENABLED))) {
        acsUrlWithTenantDomain =
                acsUrlWithTenantDomain + "?" +
                        MultitenantConstants.TENANT_DOMAIN + "=" + tenantDomain;
    }
    return acsUrlWithTenantDomain;
}
 
Example #17
Source File: OpenIDProviderService.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * The verify method used by the OpenID Provider when using the OpenID Dumb
 * Mode
 *
 * @param params
 * @return
 * @throws Exception
 */
public String verify(OpenIDParameterDTO[] params) throws IdentityProviderException {
    String disableDumbMode = IdentityUtil.getProperty(IdentityConstants.ServerConfig.OPENID_DISABLE_DUMB_MODE);

    if ("true".equalsIgnoreCase(disableDumbMode)) {
        throw new IdentityProviderException("OpenID relying parties with dumb mode not supported");
    }

    ParameterList paramList = getParameterList(params);
    Message message = OpenIDProvider.getInstance().getManager().verify(paramList);
    return message.keyValueFormEncoding();
}
 
Example #18
Source File: EntitlementEngine.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Test request for PDP
 *
 * @param xacmlRequest XACML request as String
 * @return response as String
 */
public String test(String xacmlRequest) {

    if (log.isDebugEnabled() && IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.XACML_REQUEST)) {
        log.debug("XACML Request : " + xacmlRequest);
    }

    String xacmlResponse = pdpTest.evaluate(xacmlRequest);

    if (log.isDebugEnabled() && IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.XACML_RESPONSE)) {
        log.debug("XACML Response : " + xacmlResponse);
    }

    return xacmlResponse;
}
 
Example #19
Source File: SAMLSSOUtil.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public static String getDefaultLogoutEndpoint(){
    String defaultLogoutLocation = IdentityUtil.getProperty(IdentityConstants.ServerConfig
            .DEFAULT_LOGOUT_ENDPOINT);
    if (StringUtils.isBlank(defaultLogoutLocation)){
        defaultLogoutLocation = IdentityUtil.getServerURL(SAMLSSOConstants
                .DEFAULT_LOGOUT_ENDPOINT, false, false);
    }
    return defaultLogoutLocation;
}
 
Example #20
Source File: STSAdminService.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private void addParameters(Registry registry) throws IdentityException {
    IdentityPersistenceManager admin = IdentityPersistenceManager.getPersistanceManager();

    admin.createOrUpdateParameter(registry, IdentityConstants.PARAM_SUPPORTED_TOKEN_TYPES,
                                  IdentityConstants.SAML10_URL + "," + IdentityConstants.SAML11_URL + ","
                                  + IdentityConstants.SAML20_URL + "," + IdentityConstants.OpenId.OPENID_URL);

    admin.createOrUpdateParameter(registry, IdentityConstants.PARAM_CARD_NAME,
                                  IdentityConstants.PARAM_VALUE_CARD_NAME);
    admin.createOrUpdateParameter(registry, IdentityConstants.PARAM_VALID_PERIOD,
                                  IdentityConstants.PARAM_VALUE_VALID_PERIOD);
}
 
Example #21
Source File: GenericIdentityProviderData.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * @throws IdentityProviderException
 */
protected void loadClaims() throws IdentityProviderException {
    IdentityClaimManager claimManager = null;
    Claim[] claims = null;

    if (log.isDebugEnabled()) {
        log.debug("Loading claims");
    }

    try {
        claimManager = IdentityClaimManager.getInstance();
        claims = claimManager.getAllSupportedClaims(IdentityConstants.INFOCARD_DIALECT, IdentityTenantUtil
                .getRealm(null, userIdentifier));
        for (int i = 0; i < claims.length; i++) {
            Claim temp = claims[i];
            supportedClaims.put(temp.getClaimUri(), temp);
        }
        Claim tenant = new Claim();
        tenant.setClaimUri(IdentityConstants.CLAIM_TENANT_DOMAIN);
        tenant.setDescription("Tenant");
        tenant.setDisplayTag("Tenant");
        tenant.setSupportedByDefault(true);
        tenant.setDialectURI("http://wso2.org");
        supportedClaims.put(tenant.getClaimUri(), tenant);
    } catch (IdentityException e) {
        log.error("Error while loading claims", e);
        throw new IdentityProviderException("Error while loading claims", e);
    }
}
 
Example #22
Source File: OpenIDProviderService.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public static int getOpenIDSessionTimeout() {
    if (StringUtils.isNotBlank(IdentityUtil.getProperty(IdentityConstants.ServerConfig.OPENID_SESSION_TIMEOUT))) {
        return Integer
                .parseInt(IdentityUtil.getProperty(IdentityConstants.ServerConfig.OPENID_SESSION_TIMEOUT).trim());
    } else {
        return 36000;
    }
}
 
Example #23
Source File: IdentityProviderData.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * @param data
 * @throws IdentityProviderException
 */
@Override
protected void readAuthenticationMechanism(RahasData data) throws IdentityProviderException {
    MessageContext inContext = null;
    Vector results = null;

    if (log.isDebugEnabled()) {
        log.debug("Reading authentication mechanism");
    }

    inContext = data.getInMessageContext();

    if ((results = (Vector) inContext.getProperty(WSHandlerConstants.RECV_RESULTS)) == null) {
        log.error("Missing authentication mechanism");
        throw new IdentityProviderException("Missing authentication mechanism");
    } else {
        for (int i = 0; i < results.size(); i++) {
            WSHandlerResult rResult = (WSHandlerResult) results.get(i);
            Vector wsSecEngineResults = rResult.getResults();

            for (int j = 0; j < wsSecEngineResults.size(); j++) {
                WSSecurityEngineResult wser = (WSSecurityEngineResult) wsSecEngineResults.get(j);
                int action = ((Integer) wser.get(WSSecurityEngineResult.TAG_ACTION)).intValue();
                if (action == WSConstants.ST_UNSIGNED) {

                    this.authMechanism = IdentityConstants.AUTH_TYPE_SELF_ISSUED;
                    this.assertion = (SAMLAssertion) wser.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
                } else if (action == WSConstants.UT && wser.get(WSSecurityEngineResult.TAG_PRINCIPAL) != null) {
                    this.authMechanism = IdentityConstants.AUTH_TYPE_USERNAME_TOKEN;
                }
            }
        }
    }
}
 
Example #24
Source File: IdentityUtil.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public static int getCleanUpTimeout() {

        String cleanUpTimeout = IdentityUtil.getProperty(IdentityConstants.ServerConfig.CLEAN_UP_TIMEOUT);
        if (StringUtils.isBlank(cleanUpTimeout)) {
            cleanUpTimeout = IdentityConstants.ServerConfig.CLEAN_UP_TIMEOUT_DEFAULT;
        } else if (!StringUtils.isNumeric(cleanUpTimeout)) {
            cleanUpTimeout = IdentityConstants.ServerConfig.CLEAN_UP_TIMEOUT_DEFAULT;
        }
        return Integer.parseInt(cleanUpTimeout);
    }
 
Example #25
Source File: PrivateAssociationCryptoStore.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public PrivateAssociationCryptoStore() {
    storeId = new Random().nextInt(9999);
    counter = 0;
    String serverKey = IdentityUtil.getProperty(IdentityConstants.ServerConfig.OPENID_PRIVATE_ASSOCIATION_SERVER_KEY);
    if(StringUtils.isNotBlank(serverKey)){
        this.serverKey = serverKey;
    }
}
 
Example #26
Source File: OpenIDHandler.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the RP information of user in the database
 *
 * @param openId
 * @param profileName
 * @param params
 * @param client
 * @param
 * @param session
 * @throws IdentityProviderException
 */
private void updateRPInfo(String openId, String profileName, ParameterList params,
                          OpenIDAdminClient client, HttpSession session) throws IdentityProviderException {

    if (!client.isOpenIDUserApprovalBypassEnabled()) {

        boolean alwaysApprovedRp = Boolean.parseBoolean((String) session.getAttribute(
                OpenIDConstants.SessionAttribute.USER_APPROVED_ALWAYS));

        client.updateOpenIDUserRPInfo(params.getParameterValue(IdentityConstants.OpenId.ATTR_RETURN_TO),
                                      alwaysApprovedRp, profileName, openId);

    }
}
 
Example #27
Source File: OpenIDPape.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public OpenIDParameterDTO[] getPapeInfoFromRequest() {

        OpenIDParameterDTO[] policySet = new OpenIDParameterDTO[4];

        for (int i = 0; i < policySet.length; i++) {
            policySet[i] = new OpenIDParameterDTO();
        }

        policySet[0].setName(IdentityConstants.OpenId.PapeAttributes.PHISHING_RESISTANCE);
        policySet[0].setValue("false");

        policySet[1].setName(IdentityConstants.OpenId.PapeAttributes.MULTI_FACTOR);
        policySet[1].setValue("false");

        policySet[2].setName(IdentityConstants.OpenId.PapeAttributes.INFOCARD_BASED_MULTIFACTOR_AUTH);
        policySet[2].setValue("false");

        policySet[3].setName(IdentityConstants.OpenId.PapeAttributes.XMPP_BASED_MULTIFACTOR_AUTH);
        policySet[3].setValue("false");

        if (request.isPhishingResistanceLogin()) {
            policySet[0].setValue("true");
        }

        if (request.isMultifactorLogin()) {
            policySet[1].setValue("true");
        }

        return policySet;
    }
 
Example #28
Source File: EntitlementEngine.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Test request for PDP
 *
 * @param xacmlRequest XACML request as String
 * @return response as String
 */
public String test(String xacmlRequest) {

    if (log.isDebugEnabled() && IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.XACML_REQUEST)) {
        log.debug("XACML Request : " + xacmlRequest);
    }

    String xacmlResponse = pdpTest.evaluate(xacmlRequest);

    if (log.isDebugEnabled() && IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.XACML_RESPONSE)) {
        log.debug("XACML Response : " + xacmlResponse);
    }

    return xacmlResponse;
}
 
Example #29
Source File: SAMLSSOService.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public static boolean isOpenIDLoginAccepted() {
    if (IdentityUtil.getProperty(IdentityConstants.ServerConfig.ACCEPT_OPENID_LOGIN) != null &&
            !"".equals(IdentityUtil.getProperty(IdentityConstants.ServerConfig.ACCEPT_OPENID_LOGIN).trim())) {
        return Boolean.parseBoolean(IdentityUtil.getProperty(IdentityConstants.ServerConfig.ACCEPT_OPENID_LOGIN).trim());
    } else {
        return false;
    }
}
 
Example #30
Source File: UserRegistrationService.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
public UserFieldDTO[] readUserFieldsForUserRegistration(String dialect)
        throws IdentityException {

    IdentityClaimManager claimManager = null;
    Claim[] claims = null;
    List<UserFieldDTO> claimList = null;
    UserRealm realm = null;

    claimManager = IdentityClaimManager.getInstance();
    realm = IdentityTenantUtil.getRealm(null, null);
    claims = claimManager.getAllSupportedClaims(dialect, realm);

    if (claims == null || claims.length == 0) {
        return new UserFieldDTO[0];
    }

    claimList = new ArrayList<UserFieldDTO>();

    for (Claim claim : claims) {
        if (claim.getDisplayTag() != null
                && !IdentityConstants.PPID_DISPLAY_VALUE.equals(claim.getDisplayTag())) {
            if (UserCoreConstants.ClaimTypeURIs.ACCOUNT_STATUS.equals(claim.getClaimUri())) {
                continue;
            }
            if (!claim.isReadOnly()) {
                claimList.add(getUserFieldDTO(claim.getClaimUri(), claim.getDisplayTag(), claim.isRequired(),
                        claim.getDisplayOrder(), claim.getRegEx(), claim.isSupportedByDefault()));
            }
        }
    }
    return claimList.toArray(new UserFieldDTO[claimList.size()]);
}