< prev index next >

## src/java.security.jgss/share/classes/javax/security/auth/kerberos/ServicePermission.java

Print this page

      1 /*
      2  * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
      3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
      4  *
      5  * This code is free software; you can redistribute it and/or modify it
      6  * under the terms of the GNU General Public License version 2 only, as
      7  * published by the Free Software Foundation.  Oracle designates this
      8  * particular file as subject to the "Classpath" exception as provided
      9  * by Oracle in the LICENSE file that accompanied this code.
     10  *
     11  * This code is distributed in the hope that it will be useful, but WITHOUT
     12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     14  * version 2 for more details (a copy is included in the LICENSE file that
     15  * accompanied this code).
     16  *
     17  * You should have received a copy of the GNU General Public License version
     18  * 2 along with this work; if not, write to the Free Software Foundation,
     19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     20  *
     21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
     22  * or visit www.oracle.com if you need additional information or have any
    408                     break;
    409                 default:
    410                     throw new IllegalArgumentException(
    411                             "invalid permission: " + action);
    412                 }
    413                 i--;
    414             }
    415
    416             // point i at the location of the comma minus one (or -1).
    417             i -= matchlen;
    418         }
    419
    420         return mask;
    421     }
    422
    423
    424     /**
    425      * WriteObject is called to save the state of the ServicePermission
    426      * to a stream. The actions are serialized, and the superclass
    427      * takes care of the name.

    428      */
    429     private void writeObject(java.io.ObjectOutputStream s)
    430         throws IOException
    431     {
    432         // Write out the actions. The superclass takes care of the name
    433         // call getActions to make sure actions field is initialized
    434         if (actions == null)
    435             getActions();
    436         s.defaultWriteObject();
    437     }
    438
    439     /**
    440      * readObject is called to restore the state of the
    441      * ServicePermission from a stream.

    442      */
    443     private void readObject(java.io.ObjectInputStream s)
    444          throws IOException, ClassNotFoundException
    445     {
    446         // Read in the action, then initialize the rest
    447         s.defaultReadObject();
    448         init(getName(),getMask(actions));
    449     }
    450
    451
    452     /*
    453       public static void main(String[] args) throws Exception {
    454       ServicePermission this_ =
    455       new ServicePermission(args[0], "accept");
    456       ServicePermission that_ =
    457       new ServicePermission(args[1], "accept,initiate");
    458       System.out.println("-----\n");
    459       System.out.println("this.implies(that) = " + this_.implies(that_));
    460       System.out.println("-----\n");
    461       System.out.println("this = "+this_);
      1 /*
      2  * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
      3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
      4  *
      5  * This code is free software; you can redistribute it and/or modify it
      6  * under the terms of the GNU General Public License version 2 only, as
      7  * published by the Free Software Foundation.  Oracle designates this
      8  * particular file as subject to the "Classpath" exception as provided
      9  * by Oracle in the LICENSE file that accompanied this code.
     10  *
     11  * This code is distributed in the hope that it will be useful, but WITHOUT
     12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     14  * version 2 for more details (a copy is included in the LICENSE file that
     15  * accompanied this code).
     16  *
     17  * You should have received a copy of the GNU General Public License version
     18  * 2 along with this work; if not, write to the Free Software Foundation,
     19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     20  *
     21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
     22  * or visit www.oracle.com if you need additional information or have any
    408                     break;
    409                 default:
    410                     throw new IllegalArgumentException(
    411                             "invalid permission: " + action);
    412                 }
    413                 i--;
    414             }
    415
    416             // point i at the location of the comma minus one (or -1).
    417             i -= matchlen;
    418         }
    419
    420         return mask;
    421     }
    422
    423
    424     /**
    425      * WriteObject is called to save the state of the ServicePermission
    426      * to a stream. The actions are serialized, and the superclass
    427      * takes care of the name.
    428      *
    429      * @param  s the {@code ObjectOutputStream} to which data is written
    430      * @throws IOException if an I/O error occurs
    431      */
    432     private void writeObject(java.io.ObjectOutputStream s)
    433         throws IOException
    434     {
    435         // Write out the actions. The superclass takes care of the name
    436         // call getActions to make sure actions field is initialized
    437         if (actions == null)
    438             getActions();
    439         s.defaultWriteObject();
    440     }
    441
    442     /**
    443      * readObject is called to restore the state of the
    444      * ServicePermission from a stream.
    445      *
    446      * @param  s the {@code ObjectInputStream} from which data is read
    447      * @throws IOException if an I/O error occurs
    448      * @throws ClassNotFoundException if a serialized class cannot be loaded
    449      */
    450     private void readObject(java.io.ObjectInputStream s)
    451          throws IOException, ClassNotFoundException
    452     {
    453         // Read in the action, then initialize the rest
    454         s.defaultReadObject();
    455         init(getName(),getMask(actions));
    456     }
    457
    458
    459     /*
    460       public static void main(String[] args) throws Exception {
    461       ServicePermission this_ =
    462       new ServicePermission(args[0], "accept");
    463       ServicePermission that_ =
    464       new ServicePermission(args[1], "accept,initiate");
    465       System.out.println("-----\n");
    466       System.out.println("this.implies(that) = " + this_.implies(that_));
    467       System.out.println("-----\n");
    468       System.out.println("this = "+this_);

< prev index next >