AuthenticateScript.groovy.template revision 355e5661379644c081271b23fa8b966a098a42d2
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh/*
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh *
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh * Copyright (c) 2015 ForgeRock AS. All Rights Reserved
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh *
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh * The contents of this file are subject to the terms
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh * of the Common Development and Distribution License
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh * (the License). You may not use this file except in
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh * compliance with the License.
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh *
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh * You can obtain a copy of the License at
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh * http://forgerock.org/license/CDDLv1.0.html
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh * See the License for the specific language governing
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh * permission and limitations under the License.
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh *
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh * When distributing Covered Code, include this CDDL
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh * Header Notice in each file and include the License file
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh * at http://forgerock.org/license/CDDLv1.0.html
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh * If applicable, add the following below the CDDL Header,
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh * with the fields enclosed by brackets [] replaced by
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh * your own identifying information:
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh * "Portions Copyrighted [year] [name of copyright owner]"
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh *
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh * Version {{version}}
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh * Author {{author}}
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh */
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singhpackage org.forgerock.openicf.connectors.{{lower packageName}}
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singhimport org.forgerock.openicf.connectors.{{lower packageName}}.{{packageName}}Configuration
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singhimport org.forgerock.openicf.misc.scriptedcommon.OperationType
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singhimport org.identityconnectors.common.logging.Log
f7257ab0bcea6c41fab5a4677787f3075ecdcb64Pavel Reichlimport org.identityconnectors.framework.common.exceptions.InvalidPasswordException
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh/**
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh * Built-in accessible objects
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh **/
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh// OperationType is AUTHENTICATION for this script
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singhdef operation = operation as OperationType
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh// The configuration class created specifically for this connector
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singhdef configuration = configuration as {{packageName}}Configuration
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh// Default logging facility
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singhdef log = log as Log
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh/**
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh * Script action - Customizable
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh *
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh * Must either return an int or String convertible to a Uid object or throw an exception
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh **/
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singhdef authId = null;
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh/* Perform an action to authenticate against the external source. If no authentication is
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh required then allow authId to pass through by default. This script is required. */
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek SinghauthId = 1;
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singhif (authId == null) {
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh throw new InvalidPasswordException("Authentication Failed")
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh}
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh/* Log something to demonstrate this script executed */
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singhlog.info("Create script, operation = " + operation.toString());
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singhreturn authId
a65a64aee968bd2ac18156ced15a1e2509a8acbaAbhishek Singh