AARC Pilot - Creating JWK files

From PDP/Grid Wiki
Revision as of 13:12, 15 February 2017 by Msalle@nikhef.nl (talk | contribs) (Created page with "In order to create a set of JSON Web keys for use with either an AARC Master Portal or a Delegation Server without first having to deploy the Master Portal, you can use the fo...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

In order to create a set of JSON Web keys for use with either an AARC Master Portal or a Delegation Server without first having to deploy the Master Portal, you can use the following very simple java program below. Compile it against the pre-build oa2-cli.jar, e.g.

javac -cp target/oa2-cli.jar:. CreateJWK.java

and run it similarly:

java -cp target/oa2-cli.jar:. CreateJWK

(adjust the location of the oa2-cli.jar file where needed).

Where CreateJWK.java is:

// Copyright 2017- NWO-I Nikhef
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Authors:
//      Mischa Salle, Nikhef Amsterdam, the Netherlands
//      grid-mw-security-support@nikhef.nl

import edu.uiuc.ncsa.myproxy.oauth2.tools.SigningCommands;
import edu.uiuc.ncsa.myproxy.oauth2.tools.OA2Commands;
import edu.uiuc.ncsa.myproxy.oa4mp.oauth2.OA2SE;
import edu.uiuc.ncsa.security.util.cli.InputLine;
import edu.uiuc.ncsa.security.core.util.MyLoggingFacade;
import java.util.Vector;

public class CreateJWK {
    public static void main(String args[])  {
        try {
            OA2Commands oa2Commands = new OA2Commands(null);
            OA2SE oa2se = new OA2SE(
                new MyLoggingFacade("Test"), null, null, 0, 0,
                null, null, null, null, null, null,
                null, null, null, null, null, false, null, null, 0,
                null, null, null, false, false, 0, null);
            SigningCommands sc=new SigningCommands(oa2se);
            sc.create(new InputLine(new Vector()));
        } catch (Exception e)   {
            e.printStackTrace(System.err);
            throw new RuntimeException("Error: "+e.getMessage());
        }
    }
}