FRAMessageUtils.h revision 5d37db6a3aca50ba14cba8909d3ae44f7d43e407
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni/*
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni * The contents of this file are subject to the terms of the Common Development and
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni * Distribution License (the License). You may not use this file except in compliance with the
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni * License.
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni *
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni * specific language governing permission and limitations under the License.
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni *
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni * When distributing Covered Software, include this CDDL Header Notice in each file and include
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni * Header, with the fields enclosed by brackets [] replaced by your own identifying
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni * information: "Portions copyright [year] [name of copyright owner]".
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni *
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni * Copyright 2016 ForgeRock AS.
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni */
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni#import <AFNetworking.h>
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni#import <JWT.h>
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni#import <JWTAlgorithmFactory.h>
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni/*!
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni * Class that handles communication with OpenAM.
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni */
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni@interface FRAMessageUtils : NSObject
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni/*!
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni * POST request method.
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni *
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni * @param endpoint The URL string used to create the request URL.
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni * @param base64Secret The secret used to sign the JWT.
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni * @param messageId The id of the message.
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni * @param data The payload to transmit with the request.
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni * @param handler A block object to be executed when the task finishes.
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni */
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings+ (void)respondWithEndpoint:(NSString *)endpoint
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings base64Secret:(NSString *)base64Secret
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings messageId:(NSString *)messageId
5d37db6a3aca50ba14cba8909d3ae44f7d43e407Ken Stubbings loadBalancerCookieData:(NSString *)loadBalancerCookieData
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings data:(NSDictionary *)data
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings handler:(void (^)(NSInteger statusCode, NSError *error))handler;
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni/*!
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni * POST request method.
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni *
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni * @param endpoint The URL string used to create the request URL.
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni * @param base64Secret The secret used to sign the JWT.
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni * @param messageId The id of the message.
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni * @param data The payload to transmit with the request.
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni * @param protocol The protocol used to process URLs.
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni * @param handler A block object to be executed when the task finishes.
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni */
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings+ (void)respondWithEndpoint:(NSString *)endpoint
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings base64Secret:(NSString *)base64Secret
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings messageId:(NSString *)messageId
5d37db6a3aca50ba14cba8909d3ae44f7d43e407Ken Stubbings loadBalancerCookieData:(NSString *)loadBalancerCookieData
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings data:(NSDictionary *)data
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings protocol:(Class) protocol
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings handler:(void (^)(NSInteger statusCode, NSError *error))handler;
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings/*!
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings * Generate challenge response.
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings *
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings * @param challenge The challenge.
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings * @param secret The secret.
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings * @return The challenge response.
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings */
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings+ (NSString *) generateChallengeResponse:(NSString *) challenge secret:(NSString *) secret;
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings/*!
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings * Extracts the data from the body of a JWT string;
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings *
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings * @param message the compleye JWT string
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings * @NSDictionary the data from the body of the JWT
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings */
a1e92b2783be4bfeb0c7e267223cc7779a6f324cKen Stubbings+ (NSDictionary *)extractJTWBodyFromString:(NSString *)message;
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni
b3a21de0a0e0a5dea71bece7e5c0356700136fbcDiego Colantoni@end